Socket
Socket
Sign inDemoInstall

@linaria/utils

Package Overview
Dependencies
Maintainers
4
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@linaria/utils - npm Package Compare versions

Comparing version 4.3.3 to 4.3.4

46

esm/collectExportsAndImports.js

@@ -10,4 +10,4 @@ /* eslint @typescript-eslint/no-use-before-define: ["error", { "functions": false }] */

import isTypedNode from './isTypedNode';
export const sideEffectImport = item => item.imported === null;
export const explicitImport = item => item.imported !== null;
export const sideEffectImport = item => item.imported === 'side-effect';
export const explicitImport = item => item.imported !== 'side-effect';
function getValue({

@@ -62,3 +62,3 @@ node

state.imports.push({
imported: null,
imported: 'side-effect',
local: path,

@@ -206,7 +206,6 @@ source

}
function getImportExportTypeByInteropFunction(path) {
function getCalleeName(path) {
const callee = path.get('callee');
let name;
if (callee.isIdentifier()) {
name = callee.node.name;
return callee.node.name;
}

@@ -216,5 +215,9 @@ if (callee.isMemberExpression()) {

if (property.isIdentifier()) {
name = property.node.name;
return property.node.name;
}
}
return undefined;
}
function getImportExportTypeByInteropFunction(path) {
const name = getCalleeName(path);
if (name === undefined) {

@@ -372,3 +375,3 @@ return undefined;

state.imports.push({
imported: null,
imported: 'side-effect',
local: container,

@@ -566,3 +569,28 @@ source

}
if (parentPath?.isExportSpecifier()) {
if (parentPath?.isCallExpression() && referencePath.listKey === 'arguments') {
// The defined variable is used as a function argument. Let's try to figure out what is imported.
const importType = getImportExportTypeByInteropFunction(parentPath);
if (!importType) {
// Imported value is used as an unknown function argument,
// so we can't predict usage and import it as is.
result.push(importItem);
break;
}
if (importType === 'default') {
result.push({
...importItem,
imported: 'default',
local: parentPath.get('id')
});
continue;
}
if (importType === 'import:*') {
result.push(importItem);
break;
}
warn('evaluator:collectExportsAndImports:unfoldNamespaceImports', 'Unknown import type', importType);
result.push(importItem);
continue;
}
if (parentPath?.isExportSpecifier() || parentPath?.isExportDefaultDeclaration()) {
// The whole namespace is re-exported

@@ -569,0 +597,0 @@ result.push(importItem);

@@ -18,5 +18,5 @@ "use strict";

const sideEffectImport = item => item.imported === null;
const sideEffectImport = item => item.imported === 'side-effect';
exports.sideEffectImport = sideEffectImport;
const explicitImport = item => item.imported !== null;
const explicitImport = item => item.imported !== 'side-effect';
exports.explicitImport = explicitImport;

@@ -72,3 +72,3 @@ function getValue({

state.imports.push({
imported: null,
imported: 'side-effect',
local: path,

@@ -216,7 +216,6 @@ source

}
function getImportExportTypeByInteropFunction(path) {
function getCalleeName(path) {
const callee = path.get('callee');
let name;
if (callee.isIdentifier()) {
name = callee.node.name;
return callee.node.name;
}

@@ -226,5 +225,9 @@ if (callee.isMemberExpression()) {

if (property.isIdentifier()) {
name = property.node.name;
return property.node.name;
}
}
return undefined;
}
function getImportExportTypeByInteropFunction(path) {
const name = getCalleeName(path);
if (name === undefined) {

@@ -382,3 +385,3 @@ return undefined;

state.imports.push({
imported: null,
imported: 'side-effect',
local: container,

@@ -578,3 +581,28 @@ source

}
if (parentPath !== null && parentPath !== void 0 && parentPath.isExportSpecifier()) {
if (parentPath !== null && parentPath !== void 0 && parentPath.isCallExpression() && referencePath.listKey === 'arguments') {
// The defined variable is used as a function argument. Let's try to figure out what is imported.
const importType = getImportExportTypeByInteropFunction(parentPath);
if (!importType) {
// Imported value is used as an unknown function argument,
// so we can't predict usage and import it as is.
result.push(importItem);
break;
}
if (importType === 'default') {
result.push({
...importItem,
imported: 'default',
local: parentPath.get('id')
});
continue;
}
if (importType === 'import:*') {
result.push(importItem);
break;
}
(0, _logger.warn)('evaluator:collectExportsAndImports:unfoldNamespaceImports', 'Unknown import type', importType);
result.push(importItem);
continue;
}
if (parentPath !== null && parentPath !== void 0 && parentPath.isExportSpecifier() || parentPath !== null && parentPath !== void 0 && parentPath.isExportDefaultDeclaration()) {
// The whole namespace is re-exported

@@ -581,0 +609,0 @@ result.push(importItem);

2

package.json
{
"name": "@linaria/utils",
"version": "4.3.3",
"version": "4.3.4",
"description": "Blazing fast zero-runtime CSS in JS library",

@@ -5,0 +5,0 @@ "keywords": [

import type { NodePath } from '@babel/traverse';
import type { Identifier, MemberExpression } from '@babel/types';
export interface ISideEffectImport {
imported: null;
imported: 'side-effect';
local: NodePath;

@@ -6,0 +6,0 @@ source: string;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc