@eslint-react/var 3.0.0-next.66 → 3.0.0-next.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +8 -19
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -182,32 +182,21 @@ function isValueEqual(context, a, b) {
182
182
  case a.type === AST_NODE_TYPES.Literal && b.type === AST_NODE_TYPES.Literal: return a.value === b.value;
183
183
  case a.type === AST_NODE_TYPES.TemplateElement && b.type === AST_NODE_TYPES.TemplateElement: return a.value.cooked === b.value.cooked;
184
184
  case a.type === AST_NODE_TYPES.Identifier && b.type === AST_NODE_TYPES.Identifier: {
185
+ const aDefNode = resolve(context, a);
186
+ const bDefNode = resolve(context, b);
187
+ const aDefNodeParent = aDefNode?.parent;
188
+ const bDefNodeParent = bDefNode?.parent;
185
189
  const aVar = findVariable(aScope, a);
186
190
  const bVar = findVariable(bScope, b);
187
- const resolve = (variable) => {
188
- if (variable == null) return null;
189
- const def = variable.defs.at(0);
190
- if (def != null) switch (true) {
191
- case def.type === DefinitionType.FunctionName && def.node.type === AST_NODE_TYPES.FunctionDeclaration: return def.node;
192
- case def.type === DefinitionType.ClassName && def.node.type === AST_NODE_TYPES.ClassDeclaration: return def.node;
193
- case "init" in def.node && def.node.init != null && !("declarations" in def.node.init): return def.node.init;
194
- }
195
- if (def?.type === DefinitionType.Parameter && ast.isFunction(def.node)) return def.node;
196
- return null;
197
- };
198
- const aVarInit = resolve(aVar);
199
- const bVarInit = resolve(bVar);
200
- const aVarInitParent = aVarInit?.parent;
201
- const bVarInitParent = bVarInit?.parent;
202
191
  const aDef = aVar?.defs.at(0);
203
192
  const bDef = bVar?.defs.at(0);
204
193
  const aDefParentParent = aDef?.parent?.parent;
205
194
  const bDefParentParent = bDef?.parent?.parent;
206
195
  switch (true) {
207
- case aVarInitParent?.type === AST_NODE_TYPES.CallExpression && bVarInitParent?.type === AST_NODE_TYPES.CallExpression && ast.isFunction(aVarInit) && ast.isFunction(bVarInit): {
208
- if (!ast.isNodeEqual(aVarInitParent.callee, bVarInitParent.callee)) return false;
209
- const aParams = aVarInit.params;
210
- const bParams = bVarInit.params;
196
+ case aDefNodeParent?.type === AST_NODE_TYPES.CallExpression && bDefNodeParent?.type === AST_NODE_TYPES.CallExpression && ast.isFunction(aDefNode) && ast.isFunction(bDefNode): {
197
+ if (!ast.isNodeEqual(aDefNodeParent.callee, bDefNodeParent.callee)) return false;
198
+ const aParams = aDefNode.params;
199
+ const bParams = bDefNode.params;
211
200
  const aPos = aParams.findIndex((x) => ast.isNodeEqual(x, a));
212
201
  const bPos = bParams.findIndex((x) => ast.isNodeEqual(x, b));
213
202
  return aPos !== -1 && bPos !== -1 && aPos === bPos;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/var",
3
- "version": "3.0.0-next.66",
3
+ "version": "3.0.0-next.68",
4
4
  "description": "ESLint React's TSESTree AST utility module for static analysis of variables.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -34,9 +34,9 @@
34
34
  "@typescript-eslint/types": "canary",
35
35
  "@typescript-eslint/utils": "canary",
36
36
  "ts-pattern": "^5.9.0",
37
- "@eslint-react/ast": "3.0.0-next.66",
38
- "@eslint-react/eff": "3.0.0-next.66",
39
- "@eslint-react/shared": "3.0.0-next.66"
37
+ "@eslint-react/ast": "3.0.0-next.68",
38
+ "@eslint-react/eff": "3.0.0-next.68",
39
+ "@eslint-react/shared": "3.0.0-next.68"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@typescript-eslint/typescript-estree": "canary",