@eslint-react/var 1.24.0-beta.0 → 1.24.0-beta.1

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.js CHANGED
@@ -29,7 +29,7 @@ var AST3__namespace = /*#__PURE__*/_interopNamespace(AST3);
29
29
 
30
30
  // src/find-variable.ts
31
31
  var findVariable2 = eff.dual(2, (nameOrNode, initialScope) => {
32
- if (nameOrNode === eff._) return eff._;
32
+ if (nameOrNode == null) return eff._;
33
33
  return ASTUtils__namespace.findVariable(initialScope, nameOrNode) ?? eff._;
34
34
  });
35
35
 
@@ -42,7 +42,7 @@ function getChidScopes(scope) {
42
42
  return scopes;
43
43
  }
44
44
  function getVariableDeclaratorId(node, prev) {
45
- if (node === eff._) return eff._;
45
+ if (node == null) return eff._;
46
46
  switch (true) {
47
47
  case (node.type === types.AST_NODE_TYPES.VariableDeclarator && node.init === prev):
48
48
  return node.id;
@@ -55,9 +55,9 @@ function getVariableDeclaratorId(node, prev) {
55
55
  }
56
56
  }
57
57
  function getVariableNode(variable, at) {
58
- if (variable === eff._) return eff._;
58
+ if (variable == null) return eff._;
59
59
  const def = variable.defs.at(at);
60
- if (def === eff._) return eff._;
60
+ if (def == null) return eff._;
61
61
  switch (true) {
62
62
  case (def.type === scopeManager.DefinitionType.FunctionName && def.node.type === types.AST_NODE_TYPES.FunctionDeclaration):
63
63
  return def.node;
@@ -82,7 +82,7 @@ function getVariables(initialScope) {
82
82
  }
83
83
  function isInitializedFromSource(name, source, initialScope) {
84
84
  const latestDef = findVariable2(name, initialScope)?.defs.at(-1);
85
- if (latestDef === eff._) return false;
85
+ if (latestDef == null) return false;
86
86
  const { node, parent } = latestDef;
87
87
  if (node.type === types.AST_NODE_TYPES.VariableDeclarator && node.init != null) {
88
88
  const { init } = node;
@@ -119,7 +119,7 @@ function toResolved(sv) {
119
119
  if (kind !== "lazy") {
120
120
  return sv;
121
121
  }
122
- const resolvedValue = initialScope === eff._ ? ASTUtils.getStaticValue(node) : ASTUtils.getStaticValue(node, initialScope);
122
+ const resolvedValue = initialScope == null ? ASTUtils.getStaticValue(node) : ASTUtils.getStaticValue(node, initialScope);
123
123
  return resolvedValue == null ? { kind: "none", node, initialScope } : { kind: "some", node, initialScope, value: resolvedValue.value };
124
124
  }
125
125
 
@@ -175,7 +175,7 @@ function isNodeValueEqual(a, b, initialScopes) {
175
175
  return AST3__namespace.isNodeEqual(aRight, bRight);
176
176
  }
177
177
  default: {
178
- return aVar !== eff._ && bVar !== eff._ && aVar === bVar;
178
+ return aVar != null && bVar != null && aVar === bVar;
179
179
  }
180
180
  }
181
181
  }
@@ -202,7 +202,7 @@ var ValueConstructionHint = {
202
202
  StrictCallExpression: 1n << 0n
203
203
  };
204
204
  function getValueConstruction(node, initialScope, hint = ValueConstructionHint.None) {
205
- if (node === eff._) return eff._;
205
+ if (node == null) return eff._;
206
206
  switch (node.type) {
207
207
  case types.AST_NODE_TYPES.JSXElement:
208
208
  case types.AST_NODE_TYPES.JSXFragment: {
@@ -241,12 +241,12 @@ function getValueConstruction(node, initialScope, hint = ValueConstructionHint.N
241
241
  }
242
242
  case types.AST_NODE_TYPES.LogicalExpression: {
243
243
  const lvc = getValueConstruction(node.left, initialScope, hint);
244
- if (lvc === eff._) return eff._;
244
+ if (lvc == null) return eff._;
245
245
  return getValueConstruction(node.right, initialScope, hint);
246
246
  }
247
247
  case types.AST_NODE_TYPES.ConditionalExpression: {
248
248
  const cvc = getValueConstruction(node.consequent, initialScope, hint);
249
- if (cvc === eff._) return eff._;
249
+ if (cvc == null) return eff._;
250
250
  return getValueConstruction(node.alternate, initialScope, hint);
251
251
  }
252
252
  case types.AST_NODE_TYPES.Identifier: {
package/dist/index.mjs CHANGED
@@ -7,7 +7,7 @@ import { DefinitionType, ScopeType } from '@typescript-eslint/scope-manager';
7
7
 
8
8
  // src/find-variable.ts
9
9
  var findVariable2 = dual(2, (nameOrNode, initialScope) => {
10
- if (nameOrNode === _) return _;
10
+ if (nameOrNode == null) return _;
11
11
  return ASTUtils.findVariable(initialScope, nameOrNode) ?? _;
12
12
  });
13
13
 
@@ -20,7 +20,7 @@ function getChidScopes(scope) {
20
20
  return scopes;
21
21
  }
22
22
  function getVariableDeclaratorId(node, prev) {
23
- if (node === _) return _;
23
+ if (node == null) return _;
24
24
  switch (true) {
25
25
  case (node.type === AST_NODE_TYPES.VariableDeclarator && node.init === prev):
26
26
  return node.id;
@@ -33,9 +33,9 @@ function getVariableDeclaratorId(node, prev) {
33
33
  }
34
34
  }
35
35
  function getVariableNode(variable, at) {
36
- if (variable === _) return _;
36
+ if (variable == null) return _;
37
37
  const def = variable.defs.at(at);
38
- if (def === _) return _;
38
+ if (def == null) return _;
39
39
  switch (true) {
40
40
  case (def.type === DefinitionType.FunctionName && def.node.type === AST_NODE_TYPES.FunctionDeclaration):
41
41
  return def.node;
@@ -60,7 +60,7 @@ function getVariables(initialScope) {
60
60
  }
61
61
  function isInitializedFromSource(name, source, initialScope) {
62
62
  const latestDef = findVariable2(name, initialScope)?.defs.at(-1);
63
- if (latestDef === _) return false;
63
+ if (latestDef == null) return false;
64
64
  const { node, parent } = latestDef;
65
65
  if (node.type === AST_NODE_TYPES.VariableDeclarator && node.init != null) {
66
66
  const { init } = node;
@@ -97,7 +97,7 @@ function toResolved(sv) {
97
97
  if (kind !== "lazy") {
98
98
  return sv;
99
99
  }
100
- const resolvedValue = initialScope === _ ? getStaticValue(node) : getStaticValue(node, initialScope);
100
+ const resolvedValue = initialScope == null ? getStaticValue(node) : getStaticValue(node, initialScope);
101
101
  return resolvedValue == null ? { kind: "none", node, initialScope } : { kind: "some", node, initialScope, value: resolvedValue.value };
102
102
  }
103
103
 
@@ -153,7 +153,7 @@ function isNodeValueEqual(a, b, initialScopes) {
153
153
  return AST3.isNodeEqual(aRight, bRight);
154
154
  }
155
155
  default: {
156
- return aVar !== _ && bVar !== _ && aVar === bVar;
156
+ return aVar != null && bVar != null && aVar === bVar;
157
157
  }
158
158
  }
159
159
  }
@@ -180,7 +180,7 @@ var ValueConstructionHint = {
180
180
  StrictCallExpression: 1n << 0n
181
181
  };
182
182
  function getValueConstruction(node, initialScope, hint = ValueConstructionHint.None) {
183
- if (node === _) return _;
183
+ if (node == null) return _;
184
184
  switch (node.type) {
185
185
  case AST_NODE_TYPES.JSXElement:
186
186
  case AST_NODE_TYPES.JSXFragment: {
@@ -219,12 +219,12 @@ function getValueConstruction(node, initialScope, hint = ValueConstructionHint.N
219
219
  }
220
220
  case AST_NODE_TYPES.LogicalExpression: {
221
221
  const lvc = getValueConstruction(node.left, initialScope, hint);
222
- if (lvc === _) return _;
222
+ if (lvc == null) return _;
223
223
  return getValueConstruction(node.right, initialScope, hint);
224
224
  }
225
225
  case AST_NODE_TYPES.ConditionalExpression: {
226
226
  const cvc = getValueConstruction(node.consequent, initialScope, hint);
227
- if (cvc === _) return _;
227
+ if (cvc == null) return _;
228
228
  return getValueConstruction(node.alternate, initialScope, hint);
229
229
  }
230
230
  case AST_NODE_TYPES.Identifier: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/var",
3
- "version": "1.24.0-beta.0",
3
+ "version": "1.24.0-beta.1",
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": {
@@ -38,9 +38,9 @@
38
38
  "@typescript-eslint/utils": "^8.19.1",
39
39
  "string-ts": "^2.2.0",
40
40
  "ts-pattern": "^5.6.0",
41
- "@eslint-react/ast": "1.24.0-beta.0",
42
- "@eslint-react/types": "1.24.0-beta.0",
43
- "@eslint-react/eff": "1.24.0-beta.0"
41
+ "@eslint-react/ast": "1.24.0-beta.1",
42
+ "@eslint-react/eff": "1.24.0-beta.1",
43
+ "@eslint-react/types": "1.24.0-beta.1"
44
44
  },
45
45
  "devDependencies": {
46
46
  "tsup": "^8.3.5",