@eslint-react/var 5.2.3-next.1 → 5.2.4-beta.0

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 +16 -16
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -127,23 +127,23 @@ function computeObjectType(context, node) {
127
127
  return computeObjectType(context, node.expressions[node.expressions.length - 1] ?? null);
128
128
  case AST_NODE_TYPES.CallExpression:
129
129
  switch (true) {
130
- case Check.identifier(node.callee, "Boolean"): return null;
131
- case Check.identifier(node.callee, "String"): return null;
132
- case Check.identifier(node.callee, "Number"): return null;
133
- case Check.identifier(node.callee, "Object"): return {
130
+ case Check.isIdentifier("Boolean")(node.callee): return null;
131
+ case Check.isIdentifier("String")(node.callee): return null;
132
+ case Check.isIdentifier("Number")(node.callee): return null;
133
+ case Check.isIdentifier("Object")(node.callee): return {
134
134
  kind: "plain",
135
135
  node
136
136
  };
137
- case Check.identifier(node.callee, "Array"): return {
137
+ case Check.isIdentifier("Array")(node.callee): return {
138
138
  kind: "array",
139
139
  node
140
140
  };
141
- case Check.identifier(node.callee, "RegExp"): return {
141
+ case Check.isIdentifier("RegExp")(node.callee): return {
142
142
  kind: "regexp",
143
143
  node
144
144
  };
145
145
  }
146
- if (node.callee.type === AST_NODE_TYPES.MemberExpression && Check.identifier(node.callee.object) && Check.identifier(node.callee.property)) {
146
+ if (node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.object.type === AST_NODE_TYPES.Identifier && node.callee.property.type === AST_NODE_TYPES.Identifier) {
147
147
  const objName = node.callee.object.name;
148
148
  const methodName = node.callee.property.name;
149
149
  switch (objName) {
@@ -337,8 +337,8 @@ const thisBlockTypes = [
337
337
  * @returns `true` if node value equal
338
338
  */
339
339
  function isValueEqual(context, a, b) {
340
- a = Check.isTypeExpression(a) ? Extract.unwrapped(a) : a;
341
- b = Check.isTypeExpression(b) ? Extract.unwrapped(b) : b;
340
+ a = Check.isTypeExpression(a) ? Extract.unwrap(a) : a;
341
+ b = Check.isTypeExpression(b) ? Extract.unwrap(b) : b;
342
342
  const [aScope, bScope] = [context.sourceCode.getScope(a), context.sourceCode.getScope(b)];
343
343
  switch (true) {
344
344
  case a === b: return true;
@@ -357,11 +357,11 @@ function isValueEqual(context, a, b) {
357
357
  const bDefParentParent = bDef?.parent?.parent;
358
358
  switch (true) {
359
359
  case aDefNodeParent?.type === AST_NODE_TYPES.CallExpression && bDefNodeParent?.type === AST_NODE_TYPES.CallExpression && Check.isFunction(aDefNode) && Check.isFunction(bDefNode): {
360
- if (!Compare.areEqual(aDefNodeParent.callee, bDefNodeParent.callee)) return false;
360
+ if (!Compare.isEqual(aDefNodeParent.callee, bDefNodeParent.callee)) return false;
361
361
  const aParams = aDefNode.params;
362
362
  const bParams = bDefNode.params;
363
- const aPos = aParams.findIndex((x) => Compare.areEqual(x, a));
364
- const bPos = bParams.findIndex((x) => Compare.areEqual(x, b));
363
+ const aPos = aParams.findIndex((x) => Compare.isEqual(x, a));
364
+ const bPos = bParams.findIndex((x) => Compare.isEqual(x, b));
365
365
  return aPos !== -1 && bPos !== -1 && aPos === bPos;
366
366
  }
367
367
  case aDefParentParent?.type === AST_NODE_TYPES.ForOfStatement && bDefParentParent?.type === AST_NODE_TYPES.ForOfStatement: {
@@ -370,14 +370,14 @@ function isValueEqual(context, a, b) {
370
370
  if (aLeft.type !== bLeft.type) return false;
371
371
  const aRight = aDefParentParent.right;
372
372
  const bRight = bDefParentParent.right;
373
- if (!Compare.areEqual(aRight, bRight)) return false;
373
+ if (!Compare.isEqual(aRight, bRight)) return false;
374
374
  if (aDefParentParent === bDefParentParent) return aVar != null && bVar != null && aVar === bVar;
375
375
  return true;
376
376
  }
377
377
  default: return aVar != null && bVar != null && aVar === bVar;
378
378
  }
379
379
  }
380
- case a.type === AST_NODE_TYPES.MemberExpression && b.type === AST_NODE_TYPES.MemberExpression: return (a.computed && b.computed ? isValueEqual(context, a.property, b.property) : Compare.areEqual(a.property, b.property)) && isValueEqual(context, a.object, b.object);
380
+ case a.type === AST_NODE_TYPES.MemberExpression && b.type === AST_NODE_TYPES.MemberExpression: return (a.computed && b.computed ? isValueEqual(context, a.property, b.property) : Compare.isEqual(a.property, b.property)) && isValueEqual(context, a.object, b.object);
381
381
  case a.type === AST_NODE_TYPES.ThisExpression && b.type === AST_NODE_TYPES.ThisExpression:
382
382
  if (aScope.block === bScope.block) return true;
383
383
  return Traverse.findParent(a, isOneOf(thisBlockTypes)) === Traverse.findParent(b, isOneOf(thisBlockTypes));
@@ -401,7 +401,7 @@ function isValueEqual(context, a, b) {
401
401
  * @internal
402
402
  */
403
403
  function isAssignmentTargetEqual(context, a, b) {
404
- return Compare.areEqual(a, b) || isValueEqual(context, a, b);
404
+ return Compare.isEqual(a, b) || isValueEqual(context, a, b);
405
405
  }
406
406
 
407
407
  //#endregion
@@ -436,7 +436,7 @@ function resolveImportSource(name, initialScope, visited = /* @__PURE__ */ new S
436
436
  if (init.type === AST_NODE_TYPES.MemberExpression && init.object.type === AST_NODE_TYPES.Identifier) return resolveImportSource(init.object.name, initialScope, visited);
437
437
  if (init.type === AST_NODE_TYPES.Identifier) return resolveImportSource(init.name, initialScope, visited);
438
438
  const arg0 = getRequireExpressionArguments(init)?.[0];
439
- if (arg0 == null || !Check.literal(arg0, "string")) return null;
439
+ if (arg0 == null || !Check.isLiteral("string")(arg0)) return null;
440
440
  return arg0.value;
441
441
  }
442
442
  if (parent?.type === AST_NODE_TYPES.ImportDeclaration) return parent.source.value;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/var",
3
- "version": "5.2.3-next.1",
3
+ "version": "5.2.4-beta.0",
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": "^8.58.2",
35
35
  "@typescript-eslint/utils": "^8.58.2",
36
36
  "ts-pattern": "^5.9.0",
37
- "@eslint-react/ast": "5.2.3-next.1",
38
- "@eslint-react/eslint": "5.2.3-next.1",
39
- "@eslint-react/shared": "5.2.3-next.1"
37
+ "@eslint-react/ast": "5.2.4-beta.0",
38
+ "@eslint-react/eslint": "5.2.4-beta.0",
39
+ "@eslint-react/shared": "5.2.4-beta.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@typescript-eslint/typescript-estree": "^8.58.2",