@eslint-react/var 2.8.1-next.4 → 2.8.2-next.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 +15 -15
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { dual, identity, unit } from "@eslint-react/eff";
2
2
  import { AST_NODE_TYPES } from "@typescript-eslint/types";
3
- import * as AST from "@eslint-react/ast";
3
+ import * as ast from "@eslint-react/ast";
4
4
  import { P, match } from "ts-pattern";
5
5
  import { DefinitionType, ScopeType } from "@typescript-eslint/scope-manager";
6
- import * as ASTUtils from "@typescript-eslint/utils/ast-utils";
6
+ import * as astUtils from "@typescript-eslint/utils/ast-utils";
7
7
  import { getStaticValue } from "@typescript-eslint/utils/ast-utils";
8
8
 
9
9
  //#region src/find-enclosing-assignment-target.ts
@@ -43,7 +43,7 @@ function getVariables(initialScope) {
43
43
  }
44
44
  const findVariable = dual(2, (nameOrNode, initialScope) => {
45
45
  if (nameOrNode == null) return unit;
46
- return ASTUtils.findVariable(initialScope, nameOrNode) ?? unit;
46
+ return astUtils.findVariable(initialScope, nameOrNode) ?? unit;
47
47
  });
48
48
 
49
49
  //#endregion
@@ -81,7 +81,7 @@ function findImportSource(name, initialScope) {
81
81
  if (init.type === AST_NODE_TYPES.MemberExpression && init.object.type === AST_NODE_TYPES.Identifier) return findImportSource(init.object.name, initialScope);
82
82
  if (init.type === AST_NODE_TYPES.Identifier) return findImportSource(init.name, initialScope);
83
83
  const arg0 = getRequireExpressionArguments(init)?.[0];
84
- if (arg0 == null || !AST.isLiteral(arg0, "string")) return unit;
84
+ if (arg0 == null || !ast.isLiteral(arg0, "string")) return unit;
85
85
  return arg0.value;
86
86
  }
87
87
  if (parent?.type === AST_NODE_TYPES.ImportDeclaration) return parent.source.value;
@@ -106,7 +106,7 @@ function getVariableDefinitionNodeLoose(variable, at) {
106
106
  const node = getVariableDefinitionNode(variable, at);
107
107
  if (node != null) return node;
108
108
  const def = variable.defs.at(at);
109
- if (def?.type === DefinitionType.Parameter && AST.isFunction(def.node)) return def.node;
109
+ if (def?.type === DefinitionType.Parameter && ast.isFunction(def.node)) return def.node;
110
110
  return unit;
111
111
  }
112
112
 
@@ -227,8 +227,8 @@ const thisBlockTypes = [
227
227
  * @returns `true` if node value equal
228
228
  */
229
229
  function isNodeValueEqual(a, b, initialScopes) {
230
- a = AST.isTypeExpression(a) ? AST.getUnderlyingExpression(a) : a;
231
- b = AST.isTypeExpression(b) ? AST.getUnderlyingExpression(b) : b;
230
+ a = ast.isTypeExpression(a) ? ast.getUnderlyingExpression(a) : a;
231
+ b = ast.isTypeExpression(b) ? ast.getUnderlyingExpression(b) : b;
232
232
  const [aScope, bScope] = initialScopes;
233
233
  switch (true) {
234
234
  case a === b: return true;
@@ -246,12 +246,12 @@ function isNodeValueEqual(a, b, initialScopes) {
246
246
  const aDefParentParent = aDef?.parent?.parent;
247
247
  const bDefParentParent = bDef?.parent?.parent;
248
248
  switch (true) {
249
- case aVarNodeParent?.type === AST_NODE_TYPES.CallExpression && bVarNodeParent?.type === AST_NODE_TYPES.CallExpression && AST.isFunction(aVarNode) && AST.isFunction(bVarNode): {
250
- if (!AST.isNodeEqual(aVarNodeParent.callee, bVarNodeParent.callee)) return false;
249
+ case aVarNodeParent?.type === AST_NODE_TYPES.CallExpression && bVarNodeParent?.type === AST_NODE_TYPES.CallExpression && ast.isFunction(aVarNode) && ast.isFunction(bVarNode): {
250
+ if (!ast.isNodeEqual(aVarNodeParent.callee, bVarNodeParent.callee)) return false;
251
251
  const aParams = aVarNode.params;
252
252
  const bParams = bVarNode.params;
253
- const aPos = aParams.findIndex((x) => AST.isNodeEqual(x, a));
254
- const bPos = bParams.findIndex((x) => AST.isNodeEqual(x, b));
253
+ const aPos = aParams.findIndex((x) => ast.isNodeEqual(x, a));
254
+ const bPos = bParams.findIndex((x) => ast.isNodeEqual(x, b));
255
255
  return aPos !== -1 && bPos !== -1 && aPos === bPos;
256
256
  }
257
257
  case aDefParentParent?.type === AST_NODE_TYPES.ForOfStatement && bDefParentParent?.type === AST_NODE_TYPES.ForOfStatement: {
@@ -260,15 +260,15 @@ function isNodeValueEqual(a, b, initialScopes) {
260
260
  if (aLeft.type !== bLeft.type) return false;
261
261
  const aRight = aDefParentParent.right;
262
262
  const bRight = bDefParentParent.right;
263
- return AST.isNodeEqual(aRight, bRight);
263
+ return ast.isNodeEqual(aRight, bRight);
264
264
  }
265
265
  default: return aVar != null && bVar != null && aVar === bVar;
266
266
  }
267
267
  }
268
- case a.type === AST_NODE_TYPES.MemberExpression && b.type === AST_NODE_TYPES.MemberExpression: return AST.isNodeEqual(a.property, b.property) && isNodeValueEqual(a.object, b.object, initialScopes);
268
+ case a.type === AST_NODE_TYPES.MemberExpression && b.type === AST_NODE_TYPES.MemberExpression: return ast.isNodeEqual(a.property, b.property) && isNodeValueEqual(a.object, b.object, initialScopes);
269
269
  case a.type === AST_NODE_TYPES.ThisExpression && b.type === AST_NODE_TYPES.ThisExpression:
270
270
  if (aScope.block === bScope.block) return true;
271
- return AST.findParentNode(a, AST.isOneOf(thisBlockTypes)) === AST.findParentNode(b, AST.isOneOf(thisBlockTypes));
271
+ return ast.findParentNode(a, ast.isOneOf(thisBlockTypes)) === ast.findParentNode(b, ast.isOneOf(thisBlockTypes));
272
272
  default: {
273
273
  const aStatic = getStaticValue(a, aScope);
274
274
  const bStatic = getStaticValue(b, bScope);
@@ -281,7 +281,7 @@ function isNodeValueEqual(a, b, initialScopes) {
281
281
  //#region src/is-assignment-target-equal.ts
282
282
  /** @internal */
283
283
  function isAssignmentTargetEqual(context, a, b) {
284
- return AST.isNodeEqual(a, b) || isNodeValueEqual(a, b, [context.sourceCode.getScope(a), context.sourceCode.getScope(b)]);
284
+ return ast.isNodeEqual(a, b) || isNodeValueEqual(a, b, [context.sourceCode.getScope(a), context.sourceCode.getScope(b)]);
285
285
  }
286
286
 
287
287
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/var",
3
- "version": "2.8.1-next.4",
3
+ "version": "2.8.2-next.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.54.0",
35
35
  "@typescript-eslint/utils": "^8.54.0",
36
36
  "ts-pattern": "^5.9.0",
37
- "@eslint-react/ast": "2.8.1-next.4",
38
- "@eslint-react/eff": "2.8.1-next.4",
39
- "@eslint-react/shared": "2.8.1-next.4"
37
+ "@eslint-react/ast": "2.8.2-next.0",
38
+ "@eslint-react/eff": "2.8.2-next.0",
39
+ "@eslint-react/shared": "2.8.2-next.0"
40
40
  },
41
41
  "devDependencies": {
42
42
  "tsdown": "^0.20.1",