@eslint-react/var 2.0.0-next.169 → 2.0.0-next.170

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
@@ -58,33 +58,6 @@ declare function getConstruction(node: TSESTree.Node | unit, initialScope: Scope
58
58
  */
59
59
  declare function isNodeValueEqual(a: TSESTree.Node, b: TSESTree.Node, initialScopes: [aScope: Scope, bScope: Scope]): boolean;
60
60
  //#endregion
61
- //#region src/value-helper.d.ts
62
- type LazyValue = {
63
- kind: "lazy";
64
- node: TSESTree.Node;
65
- initialScope: Scope | unit;
66
- } | {
67
- kind: "none";
68
- node: TSESTree.Node;
69
- initialScope: Scope | unit;
70
- } | {
71
- kind: "some";
72
- node: TSESTree.Node;
73
- value: unknown;
74
- initialScope: Scope | unit;
75
- };
76
- declare function toStaticValue(lazyValue: LazyValue): {
77
- readonly kind: "none";
78
- readonly node: TSESTree.Node;
79
- readonly initialScope: Scope | undefined;
80
- readonly value?: never;
81
- } | {
82
- readonly kind: "some";
83
- readonly node: TSESTree.Node;
84
- readonly initialScope: Scope | undefined;
85
- readonly value: unknown;
86
- };
87
- //#endregion
88
61
  //#region src/variable-assignment.d.ts
89
62
  declare function findAssignmentTarget(node: TSESTree.Node | unit, prev?: TSESTree.Node): TSESTree.BindingName | TSESTree.Expression | unit;
90
63
  //#endregion
@@ -103,4 +76,4 @@ declare const findVariable: {
103
76
  //#region src/variable-resolver.d.ts
104
77
  declare function getVariableDefinitionNode(variable: Variable | unit, at: number): unit | TSESTree.ClassDeclaration | TSESTree.ClassDeclarationWithName | TSESTree.ClassDeclarationWithOptionalName | TSESTree.Expression | TSESTree.FunctionDeclaration | TSESTree.FunctionDeclarationWithName | TSESTree.FunctionDeclarationWithOptionalName;
105
78
  //#endregion
106
- export { Construction, ConstructionDetectionHint, LazyValue, findAssignmentTarget, findProperty, findVariable, getChildScopes, getConstruction, getVariableDefinitionNode, getVariables, isNodeValueEqual, toStaticValue };
79
+ export { Construction, ConstructionDetectionHint, findAssignmentTarget, findProperty, findVariable, getChildScopes, getConstruction, getVariableDefinitionNode, getVariables, isNodeValueEqual };
package/dist/index.js CHANGED
@@ -150,24 +150,6 @@ function getConstruction(node, initialScope, hint = ConstructionDetectionHint.No
150
150
  }
151
151
  }
152
152
 
153
- //#endregion
154
- //#region src/value-helper.ts
155
- function toStaticValue(lazyValue) {
156
- const { kind, node, initialScope } = lazyValue;
157
- if (kind !== "lazy") return lazyValue;
158
- const staticValue = initialScope == null ? getStaticValue(node) : getStaticValue(node, initialScope);
159
- return staticValue == null ? {
160
- kind: "none",
161
- node,
162
- initialScope
163
- } : {
164
- kind: "some",
165
- node,
166
- initialScope,
167
- value: staticValue.value
168
- };
169
- }
170
-
171
153
  //#endregion
172
154
  //#region src/value-equal.ts
173
155
  const thisBlockTypes = [
@@ -228,17 +210,9 @@ function isNodeValueEqual(a, b, initialScopes) {
228
210
  return aFunction === bFunction;
229
211
  }
230
212
  default: {
231
- const aStatic = toStaticValue({
232
- kind: "lazy",
233
- node: a,
234
- initialScope: aScope
235
- });
236
- const bStatic = toStaticValue({
237
- kind: "lazy",
238
- node: b,
239
- initialScope: bScope
240
- });
241
- return aStatic.kind !== "none" && bStatic.kind !== "none" && aStatic.value === bStatic.value;
213
+ const aStatic = getStaticValue(a, aScope);
214
+ const bStatic = getStaticValue(b, bScope);
215
+ return aStatic != null && bStatic != null && aStatic.value === bStatic.value;
242
216
  }
243
217
  }
244
218
  }
@@ -264,4 +238,4 @@ function findAssignmentTarget(node, prev) {
264
238
  }
265
239
 
266
240
  //#endregion
267
- export { ConstructionDetectionHint, findAssignmentTarget, findProperty, findVariable, getChildScopes, getConstruction, getVariableDefinitionNode, getVariables, isNodeValueEqual, toStaticValue };
241
+ export { ConstructionDetectionHint, findAssignmentTarget, findProperty, findVariable, getChildScopes, getConstruction, getVariableDefinitionNode, getVariables, isNodeValueEqual };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/var",
3
- "version": "2.0.0-next.169",
3
+ "version": "2.0.0-next.170",
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": {
@@ -32,8 +32,8 @@
32
32
  "@typescript-eslint/utils": "^8.42.0",
33
33
  "string-ts": "^2.2.1",
34
34
  "ts-pattern": "^5.8.0",
35
- "@eslint-react/ast": "2.0.0-next.169",
36
- "@eslint-react/eff": "2.0.0-next.169"
35
+ "@eslint-react/ast": "2.0.0-next.170",
36
+ "@eslint-react/eff": "2.0.0-next.170"
37
37
  },
38
38
  "devDependencies": {
39
39
  "tsdown": "^0.14.2",