Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@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.2.2 to 4.2.3

2

esm/findIdentifiers.js

@@ -24,3 +24,3 @@ import { getScope } from './getScope';

export function nonType(path) {
return !path.find(p => p.isTSTypeReference() || p.isTSTypeQuery() || p.isFlowType() || p.isFlowDeclaration());
return !path.find(p => p.isTSTypeReference() || p.isTSTypeQuery() || p.isFlowType() || p.isFlowDeclaration() || p.isTSInterfaceDeclaration());
}

@@ -27,0 +27,0 @@ export default function findIdentifiers(expressions, type = 'referenced') {

export { default as asyncResolveFallback, syncResolve } from './asyncResolveFallback';
export { default as collectExportsAndImports } from './collectExportsAndImports';
export * from './collectExportsAndImports';
export { default as findIdentifiers } from './findIdentifiers';
export { default as findIdentifiers, nonType } from './findIdentifiers';
export { default as getFileIdx } from './getFileIdx';

@@ -6,0 +6,0 @@ export { default as isExports } from './isExports';

/* eslint-disable no-restricted-syntax */
/* eslint @typescript-eslint/no-use-before-define: ["error", { "functions": false }] */
import { NODE_FIELDS } from '@babel/types';
import findIdentifiers, { nonType } from './findIdentifiers';

@@ -9,2 +10,14 @@ import { getScope } from './getScope';

function validateField(node, key, val, field) {
if (!(field != null && field.validate)) return true;
if (field.optional && val == null) return true;
try {
field.validate(node, key, val);
return true;
} catch {
return false;
}
}
function getBinding(path) {

@@ -173,18 +186,2 @@ const binding = getScope(path).getBinding(path.node.name);

if (parent.isExportDefaultDeclaration()) {
return findParentForDelete(parent);
}
if (parent.isTryStatement()) {
return findParentForDelete(parent);
}
if (parent.isExportSpecifier()) {
return findParentForDelete(parent);
}
if (parent.isConditionalExpression()) {
return findParentForDelete(parent);
}
for (const key of ['body', 'declarations', 'specifiers']) {

@@ -200,2 +197,15 @@ if (path.listKey === key && typeof path.key === 'number') {

if (parent.isTryStatement()) {
return findParentForDelete(parent);
}
if (!path.listKey) {
const field = NODE_FIELDS[parent.type][path.key];
if (!validateField(parent.node, path.key, null, field)) {
// The parent node isn't valid without this field, so we should remove it also.
return findParentForDelete(parent);
}
}
for (const key of ['argument', 'block', 'body', 'callee', 'discriminant', 'expression', 'id', 'left', 'object', 'property', 'right', 'test']) {

@@ -202,0 +212,0 @@ if (path.key === key && parent.get(key) === path) {

@@ -35,3 +35,3 @@ "use strict";

function nonType(path) {
return !path.find(p => p.isTSTypeReference() || p.isTSTypeQuery() || p.isFlowType() || p.isFlowDeclaration());
return !path.find(p => p.isTSTypeReference() || p.isTSTypeQuery() || p.isFlowType() || p.isFlowDeclaration() || p.isTSInterfaceDeclaration());
}

@@ -38,0 +38,0 @@

@@ -11,2 +11,3 @@ "use strict";

findIdentifiers: true,
nonType: true,
getFileIdx: true,

@@ -88,2 +89,8 @@ isExports: true,

});
Object.defineProperty(exports, "nonType", {
enumerable: true,
get: function () {
return _findIdentifiers.nonType;
}
});
Object.defineProperty(exports, "slugify", {

@@ -118,3 +125,3 @@ enumerable: true,

var _findIdentifiers = _interopRequireDefault(require("./findIdentifiers"));
var _findIdentifiers = _interopRequireWildcard(require("./findIdentifiers"));

@@ -121,0 +128,0 @@ var _getFileIdx = _interopRequireDefault(require("./getFileIdx"));

@@ -13,2 +13,4 @@ "use strict";

var _types = require("@babel/types");
var _findIdentifiers = _interopRequireWildcard(require("./findIdentifiers"));

@@ -31,2 +33,14 @@

/* eslint @typescript-eslint/no-use-before-define: ["error", { "functions": false }] */
function validateField(node, key, val, field) {
if (!(field != null && field.validate)) return true;
if (field.optional && val == null) return true;
try {
field.validate(node, key, val);
return true;
} catch {
return false;
}
}
function getBinding(path) {

@@ -197,18 +211,2 @@ const binding = (0, _getScope.getScope)(path).getBinding(path.node.name);

if (parent.isExportDefaultDeclaration()) {
return findParentForDelete(parent);
}
if (parent.isTryStatement()) {
return findParentForDelete(parent);
}
if (parent.isExportSpecifier()) {
return findParentForDelete(parent);
}
if (parent.isConditionalExpression()) {
return findParentForDelete(parent);
}
for (const key of ['body', 'declarations', 'specifiers']) {

@@ -224,2 +222,15 @@ if (path.listKey === key && typeof path.key === 'number') {

if (parent.isTryStatement()) {
return findParentForDelete(parent);
}
if (!path.listKey) {
const field = _types.NODE_FIELDS[parent.type][path.key];
if (!validateField(parent.node, path.key, null, field)) {
// The parent node isn't valid without this field, so we should remove it also.
return findParentForDelete(parent);
}
}
for (const key of ['argument', 'block', 'body', 'callee', 'discriminant', 'expression', 'id', 'left', 'object', 'property', 'right', 'test']) {

@@ -226,0 +237,0 @@ if (path.key === key && parent.get(key) === path) {

{
"name": "@linaria/utils",
"description": "Blazing fast zero-runtime CSS in JS library",
"version": "4.2.2",
"version": "4.2.3",
"bugs": "https://github.com/callstack/linaria/issues",

@@ -6,0 +6,0 @@ "dependencies": {

@@ -5,3 +5,3 @@ export type { IVariableContext } from './IVariableContext';

export * from './collectExportsAndImports';
export { default as findIdentifiers } from './findIdentifiers';
export { default as findIdentifiers, nonType } from './findIdentifiers';
export { default as getFileIdx } from './getFileIdx';

@@ -8,0 +8,0 @@ export { default as isExports } from './isExports';

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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