@eslint-react/var 3.0.0-next.59 → 3.0.0-next.60

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.
package/dist/index.d.ts CHANGED
@@ -17,15 +17,6 @@ declare function findEnclosingAssignmentTarget(node: TSESTree.Node): TSESTree.Ar
17
17
  */
18
18
  type AssignmentTarget = ReturnType<typeof findEnclosingAssignmentTarget>;
19
19
  //#endregion
20
- //#region src/find-import-source.d.ts
21
- /**
22
- * Find the import source of a variable
23
- * @param name The variable name
24
- * @param initialScope The initial scope to search
25
- * @returns The import source or undefined if not found
26
- */
27
- declare function findImportSource(name: string, initialScope: Scope): string | undefined;
28
- //#endregion
29
20
  //#region src/find-variable.d.ts
30
21
  /**
31
22
  * Find a variable by name or identifier node in the scope chain
@@ -117,4 +108,4 @@ declare function isAssignmentTargetEqual(context: RuleContext, a: TSESTree.Node,
117
108
  */
118
109
  declare function isValueEqual(a: TSESTree.Node, b: TSESTree.Node, initialScopes: [aScope: Scope, bScope: Scope]): boolean;
119
110
  //#endregion
120
- export { AssignmentTarget, ObjectType, findEnclosingAssignmentTarget, findImportSource, findVariable, getObjectType, getVariableInitializer, getVariableInitializerLoose, isAssignmentTargetEqual, isValueEqual };
111
+ export { AssignmentTarget, ObjectType, findEnclosingAssignmentTarget, findVariable, getObjectType, getVariableInitializer, getVariableInitializerLoose, isAssignmentTargetEqual, isValueEqual };
package/dist/index.js CHANGED
@@ -1,9 +1,8 @@
1
- import { dual, identity, unit } from "@eslint-react/eff";
1
+ import { dual, unit } from "@eslint-react/eff";
2
2
  import { AST_NODE_TYPES } from "@typescript-eslint/types";
3
- import * as ast from "@eslint-react/ast";
4
- import { P, match } from "ts-pattern";
5
3
  import * as astUtils from "@typescript-eslint/utils/ast-utils";
6
4
  import { getStaticValue } from "@typescript-eslint/utils/ast-utils";
5
+ import * as ast from "@eslint-react/ast";
7
6
  import { DefinitionType } from "@typescript-eslint/scope-manager";
8
7
 
9
8
  //#region src/find-enclosing-assignment-target.ts
@@ -40,48 +39,6 @@ const findVariable = dual(2, (nameOrNode, initialScope) => {
40
39
  return astUtils.findVariable(initialScope, nameOrNode) ?? unit;
41
40
  });
42
41
 
43
- //#endregion
44
- //#region src/find-import-source.ts
45
- /**
46
- * Get the arguments of a require expression
47
- * @param node The node to match
48
- * @returns The require expression arguments or undefined if the node is not a require expression
49
- */
50
- function getRequireExpressionArguments(node) {
51
- return match(node).with({
52
- type: AST_NODE_TYPES.CallExpression,
53
- arguments: P.select(),
54
- callee: {
55
- type: AST_NODE_TYPES.Identifier,
56
- name: "require"
57
- }
58
- }, identity).with({
59
- type: AST_NODE_TYPES.MemberExpression,
60
- object: P.select()
61
- }, getRequireExpressionArguments).otherwise(() => null);
62
- }
63
- /**
64
- * Find the import source of a variable
65
- * @param name The variable name
66
- * @param initialScope The initial scope to search
67
- * @returns The import source or undefined if not found
68
- */
69
- function findImportSource(name, initialScope) {
70
- const latestDef = findVariable(name, initialScope)?.defs.at(-1);
71
- if (latestDef == null) return unit;
72
- const { node, parent } = latestDef;
73
- if (node.type === AST_NODE_TYPES.VariableDeclarator && node.init != null) {
74
- const { init } = node;
75
- if (init.type === AST_NODE_TYPES.MemberExpression && init.object.type === AST_NODE_TYPES.Identifier) return findImportSource(init.object.name, initialScope);
76
- if (init.type === AST_NODE_TYPES.Identifier) return findImportSource(init.name, initialScope);
77
- const arg0 = getRequireExpressionArguments(init)?.[0];
78
- if (arg0 == null || !ast.isLiteral(arg0, "string")) return unit;
79
- return arg0.value;
80
- }
81
- if (parent?.type === AST_NODE_TYPES.ImportDeclaration) return parent.source.value;
82
- return unit;
83
- }
84
-
85
42
  //#endregion
86
43
  //#region src/get-variable-initializer.ts
87
44
  /**
@@ -269,4 +226,4 @@ function isAssignmentTargetEqual(context, a, b) {
269
226
  }
270
227
 
271
228
  //#endregion
272
- export { findEnclosingAssignmentTarget, findImportSource, findVariable, getObjectType, getVariableInitializer, getVariableInitializerLoose, isAssignmentTargetEqual, isValueEqual };
229
+ export { findEnclosingAssignmentTarget, findVariable, getObjectType, getVariableInitializer, getVariableInitializerLoose, isAssignmentTargetEqual, isValueEqual };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/var",
3
- "version": "3.0.0-next.59",
3
+ "version": "3.0.0-next.60",
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.59",
38
- "@eslint-react/eff": "3.0.0-next.59",
39
- "@eslint-react/shared": "3.0.0-next.59"
37
+ "@eslint-react/eff": "3.0.0-next.60",
38
+ "@eslint-react/ast": "3.0.0-next.60",
39
+ "@eslint-react/shared": "3.0.0-next.60"
40
40
  },
41
41
  "devDependencies": {
42
42
  "tsdown": "^0.21.0-beta.2",