@eslint-react/var 1.23.2 → 1.23.3-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.
package/dist/index.js CHANGED
@@ -41,8 +41,12 @@ function getScope(node, scopeManager) {
41
41
  const { type, parent } = node;
42
42
  const inner = type !== types.AST_NODE_TYPES.Program;
43
43
  const scope = scopeManager.acquire(node, inner);
44
- if (scope) return scope;
45
- if (parent) return getScope(parent, scopeManager);
44
+ if (scope) {
45
+ return scope;
46
+ }
47
+ if (parent) {
48
+ return getScope(parent, scopeManager);
49
+ }
46
50
  return null;
47
51
  }
48
52
  function getStaticValue2(node, initialScope) {
@@ -96,7 +100,9 @@ function getVariables(initialScope) {
96
100
  }
97
101
  function isInitializedFromSource(name, source, initialScope) {
98
102
  const latestDef = eff.O.flatMapNullable(findVariable2(name, initialScope), (v) => v.defs.at(-1));
99
- if (eff.O.isNone(latestDef)) return false;
103
+ if (eff.O.isNone(latestDef)) {
104
+ return false;
105
+ }
100
106
  const { node, parent } = latestDef.value;
101
107
  if (node.type === types.AST_NODE_TYPES.VariableDeclarator && node.init) {
102
108
  const { init } = node;
@@ -166,7 +172,9 @@ function isNodeValueEqual(a, b, initialScopes) {
166
172
  eff.O.bind("bCallee", () => eff.O.map(bVarNodeParent, (n) => n.callee)),
167
173
  eff.O.exists(({ aCallee, bCallee }) => AST3__namespace.isNodeEqual(aCallee, bCallee))
168
174
  );
169
- if (!hasSameCallee) return false;
175
+ if (!hasSameCallee) {
176
+ return false;
177
+ }
170
178
  return eff.F.pipe(
171
179
  eff.O.Do,
172
180
  eff.O.bind("aParams", () => eff.O.map(aVarNode, (n) => n.params)),
@@ -197,7 +205,9 @@ function isNodeValueEqual(a, b, initialScopes) {
197
205
  return AST3__namespace.isNodeEqual(a.property, b.property) && isNodeValueEqual(a.object, b.object, initialScopes);
198
206
  }
199
207
  case (a.type === types.AST_NODE_TYPES.ThisExpression && b.type === types.AST_NODE_TYPES.ThisExpression): {
200
- if (aScope.block === bScope.block) return true;
208
+ if (aScope.block === bScope.block) {
209
+ return true;
210
+ }
201
211
  return eff.F.pipe(
202
212
  eff.O.Do,
203
213
  eff.O.bind("aFunction", () => AST3__namespace.findParentNode(a, AST3__namespace.isOneOf(thisBlockTypes))),
@@ -248,33 +258,45 @@ function getValueConstruction(node, initialScope, hint = ValueConstructionHint.N
248
258
  return { kind: "None", node };
249
259
  }
250
260
  case types.AST_NODE_TYPES.MemberExpression: {
251
- if (!("object" in node)) return { kind: "None", node };
261
+ if (!("object" in node)) {
262
+ return { kind: "None", node };
263
+ }
252
264
  return getValueConstruction(node.object, initialScope, hint);
253
265
  }
254
266
  case types.AST_NODE_TYPES.AssignmentExpression:
255
267
  case types.AST_NODE_TYPES.AssignmentPattern: {
256
- if (!("right" in node)) return { kind: "None", node };
268
+ if (!("right" in node)) {
269
+ return { kind: "None", node };
270
+ }
257
271
  return getValueConstruction(node.right, initialScope, hint);
258
272
  }
259
273
  case types.AST_NODE_TYPES.LogicalExpression: {
260
274
  const lvc = getValueConstruction(node.left, initialScope, hint);
261
- if (lvc.kind !== "None") return lvc;
275
+ if (lvc.kind !== "None") {
276
+ return lvc;
277
+ }
262
278
  return getValueConstruction(node.right, initialScope, hint);
263
279
  }
264
280
  case types.AST_NODE_TYPES.ConditionalExpression: {
265
281
  const cvc = getValueConstruction(node.consequent, initialScope, hint);
266
- if (cvc.kind !== "None") return cvc;
282
+ if (cvc.kind !== "None") {
283
+ return cvc;
284
+ }
267
285
  return getValueConstruction(node.alternate, initialScope, hint);
268
286
  }
269
287
  case types.AST_NODE_TYPES.Identifier: {
270
- if (!("name" in node && eff.isString(node.name))) return { kind: "None", node };
288
+ if (!("name" in node && eff.isString(node.name))) {
289
+ return { kind: "None", node };
290
+ }
271
291
  const construction = eff.F.pipe(
272
292
  eff.O.fromNullable(initialScope.set.get(node.name)),
273
293
  eff.O.flatMap(getVariableNode(-1)),
274
294
  eff.O.map((node2) => getValueConstruction(node2, initialScope, hint)),
275
295
  eff.O.filter((vc) => vc.kind !== "None")
276
296
  );
277
- if (eff.O.isNone(construction)) return { kind: "None", node };
297
+ if (eff.O.isNone(construction)) {
298
+ return { kind: "None", node };
299
+ }
278
300
  return {
279
301
  ...construction.value
280
302
  };
package/dist/index.mjs CHANGED
@@ -18,8 +18,12 @@ function getScope(node, scopeManager) {
18
18
  const { type, parent } = node;
19
19
  const inner = type !== AST_NODE_TYPES.Program;
20
20
  const scope = scopeManager.acquire(node, inner);
21
- if (scope) return scope;
22
- if (parent) return getScope(parent, scopeManager);
21
+ if (scope) {
22
+ return scope;
23
+ }
24
+ if (parent) {
25
+ return getScope(parent, scopeManager);
26
+ }
23
27
  return null;
24
28
  }
25
29
  function getStaticValue2(node, initialScope) {
@@ -73,7 +77,9 @@ function getVariables(initialScope) {
73
77
  }
74
78
  function isInitializedFromSource(name, source, initialScope) {
75
79
  const latestDef = O.flatMapNullable(findVariable2(name, initialScope), (v) => v.defs.at(-1));
76
- if (O.isNone(latestDef)) return false;
80
+ if (O.isNone(latestDef)) {
81
+ return false;
82
+ }
77
83
  const { node, parent } = latestDef.value;
78
84
  if (node.type === AST_NODE_TYPES.VariableDeclarator && node.init) {
79
85
  const { init } = node;
@@ -143,7 +149,9 @@ function isNodeValueEqual(a, b, initialScopes) {
143
149
  O.bind("bCallee", () => O.map(bVarNodeParent, (n) => n.callee)),
144
150
  O.exists(({ aCallee, bCallee }) => AST3.isNodeEqual(aCallee, bCallee))
145
151
  );
146
- if (!hasSameCallee) return false;
152
+ if (!hasSameCallee) {
153
+ return false;
154
+ }
147
155
  return F.pipe(
148
156
  O.Do,
149
157
  O.bind("aParams", () => O.map(aVarNode, (n) => n.params)),
@@ -174,7 +182,9 @@ function isNodeValueEqual(a, b, initialScopes) {
174
182
  return AST3.isNodeEqual(a.property, b.property) && isNodeValueEqual(a.object, b.object, initialScopes);
175
183
  }
176
184
  case (a.type === AST_NODE_TYPES.ThisExpression && b.type === AST_NODE_TYPES.ThisExpression): {
177
- if (aScope.block === bScope.block) return true;
185
+ if (aScope.block === bScope.block) {
186
+ return true;
187
+ }
178
188
  return F.pipe(
179
189
  O.Do,
180
190
  O.bind("aFunction", () => AST3.findParentNode(a, AST3.isOneOf(thisBlockTypes))),
@@ -225,33 +235,45 @@ function getValueConstruction(node, initialScope, hint = ValueConstructionHint.N
225
235
  return { kind: "None", node };
226
236
  }
227
237
  case AST_NODE_TYPES.MemberExpression: {
228
- if (!("object" in node)) return { kind: "None", node };
238
+ if (!("object" in node)) {
239
+ return { kind: "None", node };
240
+ }
229
241
  return getValueConstruction(node.object, initialScope, hint);
230
242
  }
231
243
  case AST_NODE_TYPES.AssignmentExpression:
232
244
  case AST_NODE_TYPES.AssignmentPattern: {
233
- if (!("right" in node)) return { kind: "None", node };
245
+ if (!("right" in node)) {
246
+ return { kind: "None", node };
247
+ }
234
248
  return getValueConstruction(node.right, initialScope, hint);
235
249
  }
236
250
  case AST_NODE_TYPES.LogicalExpression: {
237
251
  const lvc = getValueConstruction(node.left, initialScope, hint);
238
- if (lvc.kind !== "None") return lvc;
252
+ if (lvc.kind !== "None") {
253
+ return lvc;
254
+ }
239
255
  return getValueConstruction(node.right, initialScope, hint);
240
256
  }
241
257
  case AST_NODE_TYPES.ConditionalExpression: {
242
258
  const cvc = getValueConstruction(node.consequent, initialScope, hint);
243
- if (cvc.kind !== "None") return cvc;
259
+ if (cvc.kind !== "None") {
260
+ return cvc;
261
+ }
244
262
  return getValueConstruction(node.alternate, initialScope, hint);
245
263
  }
246
264
  case AST_NODE_TYPES.Identifier: {
247
- if (!("name" in node && isString(node.name))) return { kind: "None", node };
265
+ if (!("name" in node && isString(node.name))) {
266
+ return { kind: "None", node };
267
+ }
248
268
  const construction = F.pipe(
249
269
  O.fromNullable(initialScope.set.get(node.name)),
250
270
  O.flatMap(getVariableNode(-1)),
251
271
  O.map((node2) => getValueConstruction(node2, initialScope, hint)),
252
272
  O.filter((vc) => vc.kind !== "None")
253
273
  );
254
- if (O.isNone(construction)) return { kind: "None", node };
274
+ if (O.isNone(construction)) {
275
+ return { kind: "None", node };
276
+ }
255
277
  return {
256
278
  ...construction.value
257
279
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/var",
3
- "version": "1.23.2",
3
+ "version": "1.23.3-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": {
@@ -13,6 +13,7 @@
13
13
  },
14
14
  "license": "MIT",
15
15
  "author": "Eva1ent<rel1cx@proton.me>",
16
+ "sideEffects": false,
16
17
  "exports": {
17
18
  ".": {
18
19
  "import": {
@@ -27,6 +28,7 @@
27
28
  "./package.json": "./package.json"
28
29
  },
29
30
  "main": "dist/index.js",
31
+ "module": "dist/index.mjs",
30
32
  "types": "dist/index.d.ts",
31
33
  "files": [
32
34
  "dist",
@@ -38,9 +40,9 @@
38
40
  "@typescript-eslint/utils": "^8.19.1",
39
41
  "string-ts": "^2.2.0",
40
42
  "ts-pattern": "^5.6.0",
41
- "@eslint-react/ast": "1.23.2",
42
- "@eslint-react/eff": "1.23.2",
43
- "@eslint-react/types": "1.23.2"
43
+ "@eslint-react/ast": "1.23.3-next.0",
44
+ "@eslint-react/eff": "1.23.3-next.0",
45
+ "@eslint-react/types": "1.23.3-next.0"
44
46
  },
45
47
  "devDependencies": {
46
48
  "tsup": "^8.3.5",
@@ -50,8 +52,6 @@
50
52
  "bun": ">=1.0.15",
51
53
  "node": ">=18.18.0"
52
54
  },
53
- "sideEffects": false,
54
- "module": "dist/index.mjs",
55
55
  "scripts": {
56
56
  "build": "tsup",
57
57
  "lint:publish": "publint",