@eslint-react/var
Advanced tools
+8
-19
@@ -185,19 +185,8 @@ import { DefinitionType } from "@typescript-eslint/scope-manager"; | ||
| case a.type === AST_NODE_TYPES.Identifier && b.type === AST_NODE_TYPES.Identifier: { | ||
| const aDefNode = resolve(context, a); | ||
| const bDefNode = resolve(context, b); | ||
| const aDefNodeParent = aDefNode?.parent; | ||
| const bDefNodeParent = bDefNode?.parent; | ||
| const aVar = findVariable(aScope, a); | ||
| const bVar = findVariable(bScope, b); | ||
| const resolve = (variable) => { | ||
| if (variable == null) return null; | ||
| const def = variable.defs.at(0); | ||
| if (def != null) switch (true) { | ||
| case def.type === DefinitionType.FunctionName && def.node.type === AST_NODE_TYPES.FunctionDeclaration: return def.node; | ||
| case def.type === DefinitionType.ClassName && def.node.type === AST_NODE_TYPES.ClassDeclaration: return def.node; | ||
| case "init" in def.node && def.node.init != null && !("declarations" in def.node.init): return def.node.init; | ||
| } | ||
| if (def?.type === DefinitionType.Parameter && ast.isFunction(def.node)) return def.node; | ||
| return null; | ||
| }; | ||
| const aVarInit = resolve(aVar); | ||
| const bVarInit = resolve(bVar); | ||
| const aVarInitParent = aVarInit?.parent; | ||
| const bVarInitParent = bVarInit?.parent; | ||
| const aDef = aVar?.defs.at(0); | ||
@@ -208,6 +197,6 @@ const bDef = bVar?.defs.at(0); | ||
| switch (true) { | ||
| case aVarInitParent?.type === AST_NODE_TYPES.CallExpression && bVarInitParent?.type === AST_NODE_TYPES.CallExpression && ast.isFunction(aVarInit) && ast.isFunction(bVarInit): { | ||
| if (!ast.isNodeEqual(aVarInitParent.callee, bVarInitParent.callee)) return false; | ||
| const aParams = aVarInit.params; | ||
| const bParams = bVarInit.params; | ||
| case aDefNodeParent?.type === AST_NODE_TYPES.CallExpression && bDefNodeParent?.type === AST_NODE_TYPES.CallExpression && ast.isFunction(aDefNode) && ast.isFunction(bDefNode): { | ||
| if (!ast.isNodeEqual(aDefNodeParent.callee, bDefNodeParent.callee)) return false; | ||
| const aParams = aDefNode.params; | ||
| const bParams = bDefNode.params; | ||
| const aPos = aParams.findIndex((x) => ast.isNodeEqual(x, a)); | ||
@@ -214,0 +203,0 @@ const bPos = bParams.findIndex((x) => ast.isNodeEqual(x, b)); |
+4
-4
| { | ||
| "name": "@eslint-react/var", | ||
| "version": "3.0.0-beta.67", | ||
| "version": "3.0.0-beta.68", | ||
| "description": "ESLint React's TSESTree AST utility module for static analysis of variables.", | ||
@@ -37,5 +37,5 @@ "homepage": "https://github.com/Rel1cx/eslint-react", | ||
| "ts-pattern": "^5.9.0", | ||
| "@eslint-react/ast": "3.0.0-beta.67", | ||
| "@eslint-react/shared": "3.0.0-beta.67", | ||
| "@eslint-react/eff": "3.0.0-beta.67" | ||
| "@eslint-react/ast": "3.0.0-beta.68", | ||
| "@eslint-react/shared": "3.0.0-beta.68", | ||
| "@eslint-react/eff": "3.0.0-beta.68" | ||
| }, | ||
@@ -42,0 +42,0 @@ "devDependencies": { |
19779
-3.03%353
-3.02%+ Added
+ Added
+ Added
- Removed
- Removed
- Removed