🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →

@eslint-react/var

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eslint-react/var - npm Package Compare versions

Comparing version

to
2.0.0-next.44

import { Scope, Variable } from '@typescript-eslint/scope-manager';
import { TSESTree } from '@typescript-eslint/types';
import { _ } from '@eslint-react/eff';
import { unit } from '@eslint-react/eff';

@@ -12,6 +12,6 @@ /**

declare const findVariable: {
(initialScope: Scope): (nameOrNode: string | TSESTree.Identifier | _) => Variable | _;
(nameOrNode: string | TSESTree.Identifier | _, initialScope: Scope): Variable | _;
(initialScope: Scope): (nameOrNode: string | TSESTree.Identifier | unit) => Variable | unit;
(nameOrNode: string | TSESTree.Identifier | unit, initialScope: Scope): Variable | unit;
};
declare function findPropertyInProperties(name: string, properties: (TSESTree.Property | TSESTree.RestElement | TSESTree.SpreadElement)[], initialScope: Scope, seen?: Set<string>): (typeof properties)[number] | _;
declare function findPropertyInProperties(name: string, properties: (TSESTree.Property | TSESTree.RestElement | TSESTree.SpreadElement)[], initialScope: Scope, seen?: Set<string>): (typeof properties)[number] | unit;

@@ -57,7 +57,7 @@ declare const ConstructionDetectionHint: {

*/
declare function getConstruction(node: TSESTree.Node | _, initialScope: Scope, hint?: bigint): Construction | _;
declare function getConstruction(node: TSESTree.Node | unit, initialScope: Scope, hint?: bigint): Construction | unit;
declare function getVariableDeclaratorId(node: TSESTree.Node | _, prev?: TSESTree.Node): TSESTree.BindingName | TSESTree.Expression | _;
declare function getVariableDeclaratorId(node: TSESTree.Node | unit, prev?: TSESTree.Node): TSESTree.BindingName | TSESTree.Expression | unit;
declare function getVariableInitNode(variable: Variable | _, at: number): _ | TSESTree.ClassDeclaration | TSESTree.ClassDeclarationWithName | TSESTree.ClassDeclarationWithOptionalName | TSESTree.Expression | TSESTree.FunctionDeclaration | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName;
declare function getVariableInitNode(variable: Variable | unit, at: number): unit | TSESTree.ClassDeclaration | TSESTree.ClassDeclarationWithName | TSESTree.ClassDeclarationWithOptionalName | TSESTree.Expression | TSESTree.FunctionDeclaration | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName;

@@ -69,7 +69,7 @@ declare function getChidScopes(scope: Scope): readonly Scope[];

node: TSESTree.Node;
initialScope: Scope | _;
initialScope: Scope | unit;
} | {
kind: "none";
node: TSESTree.Node;
initialScope: Scope | _;
initialScope: Scope | unit;
} | {

@@ -79,3 +79,3 @@ kind: "some";

value: unknown;
initialScope: Scope | _;
initialScope: Scope | unit;
};

@@ -82,0 +82,0 @@ declare function toStaticValue(lazyValue: LazyValue): {

@@ -1,2 +0,2 @@

import { dual, _ } from '@eslint-react/eff';
import { dual, unit } from '@eslint-react/eff';
import { DefinitionType, ScopeType } from '@typescript-eslint/scope-manager';

@@ -10,5 +10,5 @@ import { AST_NODE_TYPES } from '@typescript-eslint/types';

function getVariableInitNode(variable, at) {
if (variable == null) return _;
if (variable == null) return unit;
const def = variable.defs.at(at);
if (def == null) return _;
if (def == null) return unit;
switch (true) {

@@ -22,3 +22,3 @@ case (def.type === DefinitionType.FunctionName && def.node.type === AST_NODE_TYPES.FunctionDeclaration):

default:
return _;
return unit;
}

@@ -38,4 +38,4 @@ }

var findVariable2 = dual(2, (nameOrNode, initialScope) => {
if (nameOrNode == null) return _;
return ASTUtils.findVariable(initialScope, nameOrNode) ?? _;
if (nameOrNode == null) return unit;
return ASTUtils.findVariable(initialScope, nameOrNode) ?? unit;
});

@@ -84,3 +84,3 @@ function findPropertyInProperties(name, properties, initialScope, seen = /* @__PURE__ */ new Set()) {

function getConstruction(node, initialScope, hint = ConstructionDetectionHint.None) {
if (node == null) return _;
if (node == null) return unit;
switch (node.type) {

@@ -105,6 +105,6 @@ case AST_NODE_TYPES.JSXElement:

}
return _;
return unit;
}
case AST_NODE_TYPES.MemberExpression: {
if (!("object" in node)) return _;
if (!("object" in node)) return unit;
return getConstruction(node.object, initialScope, hint);

@@ -114,3 +114,3 @@ }

case AST_NODE_TYPES.AssignmentPattern: {
if (!("right" in node)) return _;
if (!("right" in node)) return unit;
return getConstruction(node.right, initialScope, hint);

@@ -120,3 +120,3 @@ }

const lvc = getConstruction(node.left, initialScope, hint);
if (lvc == null) return _;
if (lvc == null) return unit;
return getConstruction(node.right, initialScope, hint);

@@ -126,3 +126,3 @@ }

const cvc = getConstruction(node.consequent, initialScope, hint);
if (cvc == null) return _;
if (cvc == null) return unit;
return getConstruction(node.alternate, initialScope, hint);

@@ -132,3 +132,3 @@ }

if (!("name" in node) || typeof node.name !== "string") {
return _;
return unit;
}

@@ -143,7 +143,7 @@ const variable = initialScope.set.get(node.name);

}
return _;
return unit;
}
default: {
if (!("expression" in node) || typeof node.expression !== "object") {
return _;
return unit;
}

@@ -155,3 +155,3 @@ return getConstruction(node.expression, initialScope, hint);

function getVariableDeclaratorId(node, prev) {
if (node == null) return _;
if (node == null) return unit;
switch (true) {

@@ -163,3 +163,3 @@ case (node.type === AST_NODE_TYPES.VariableDeclarator && node.init === prev):

case (node.type === AST_NODE_TYPES.BlockStatement || node.type === AST_NODE_TYPES.Program || node.parent === node):
return _;
return unit;
default:

@@ -260,3 +260,3 @@ return getVariableDeclaratorId(node.parent, node);

function getVariableInitNodeLoose(variable, at) {
if (variable == null) return _;
if (variable == null) return unit;
const node = getVariableInitNode(variable, at);

@@ -266,5 +266,5 @@ if (node != null) return node;

if (def?.type === DefinitionType.Parameter && AST.isFunction(def.node)) return def.node;
return _;
return unit;
}
export { ConstructionDetectionHint, findPropertyInProperties, findVariable2 as findVariable, getChidScopes, getConstruction, getVariableDeclaratorId, getVariableInitNode, getVariables, isNodeValueEqual, toStaticValue };
{
"name": "@eslint-react/var",
"version": "2.0.0-next.43",
"version": "2.0.0-next.44",
"description": "ESLint React's TSESTree AST utility module for static analysis of variables.",

@@ -35,4 +35,4 @@ "homepage": "https://github.com/Rel1cx/eslint-react",

"ts-pattern": "^5.7.1",
"@eslint-react/ast": "2.0.0-next.43",
"@eslint-react/eff": "2.0.0-next.43"
"@eslint-react/eff": "2.0.0-next.44",
"@eslint-react/ast": "2.0.0-next.44"
},

@@ -39,0 +39,0 @@ "devDependencies": {