@eslint-react/var 1.17.3 → 1.17.4-beta.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
@@ -236,46 +236,45 @@ function isNodeValueEqual(a, b, initialScopes) {
236
236
  const bStatic = astUtils.getStaticValue(b, bScope);
237
237
  if (aStatic && bStatic) return aStatic.value === bStatic.value;
238
238
  if (a.type === types.AST_NODE_TYPES.Identifier && b.type === types.AST_NODE_TYPES.Identifier) {
239
- const va = findVariable(a, aScope);
240
- const vb = findVariable(b, bScope);
241
- const da = tools.O.flatMap(va, getVariableDef(0));
242
- const db = tools.O.flatMap(vb, getVariableDef(0));
243
- const dapp = tools.O.flatMapNullable(da, (d) => d.parent?.parent);
244
- const dbpp = tools.O.flatMapNullable(db, (d) => d.parent?.parent);
245
- const na = tools.O.flatMap(va, getVariableNode(0));
246
- const nb = tools.O.flatMap(vb, getVariableNode(0));
247
- const nap = tools.O.flatMapNullable(na, (n) => n.parent);
248
- const nbp = tools.O.flatMapNullable(nb, (n) => n.parent);
239
+ const aVar = findVariable(a, aScope);
240
+ const bVar = findVariable(b, bScope);
241
+ const aVarNode = tools.O.flatMap(aVar, getVariableNode(0));
242
+ const bVarNode = tools.O.flatMap(bVar, getVariableNode(0));
243
+ const aVarNodeParent = tools.O.flatMapNullable(aVarNode, (n) => n.parent);
244
+ const bVarNodeParent = tools.O.flatMapNullable(bVarNode, (n) => n.parent);
245
+ const aDef = tools.O.flatMap(aVar, getVariableDef(0));
246
+ const bDef = tools.O.flatMap(bVar, getVariableDef(0));
247
+ const aDefParentParent = tools.O.flatMapNullable(aDef, (d) => d.parent?.parent);
248
+ const bDefParentParent = tools.O.flatMapNullable(bDef, (d) => d.parent?.parent);
249
249
  switch (true) {
250
- case (tools.O.exists(nap, AST__namespace.is(types.AST_NODE_TYPES.CallExpression)) && tools.O.exists(nbp, AST__namespace.is(types.AST_NODE_TYPES.CallExpression)) && tools.O.exists(na, AST__namespace.isFunction) && tools.O.exists(nb, AST__namespace.isFunction)): {
250
+ case (tools.O.exists(aVarNodeParent, AST__namespace.is(types.AST_NODE_TYPES.CallExpression)) && tools.O.exists(bVarNodeParent, AST__namespace.is(types.AST_NODE_TYPES.CallExpression)) && tools.O.exists(aVarNode, AST__namespace.isFunction) && tools.O.exists(bVarNode, AST__namespace.isFunction)): {
251
251
  const hasSameCallee = tools.F.pipe(
252
252
  tools.O.Do,
253
- tools.O.bind("ca", () => tools.O.map(nap, (n) => n.callee)),
254
- tools.O.bind("cb", () => tools.O.map(nbp, (n) => n.callee)),
255
- tools.O.exists(({ ca, cb }) => AST__namespace.isNodeEqual(ca, cb))
253
+ tools.O.bind("aCallee", () => tools.O.map(aVarNodeParent, (n) => n.callee)),
254
+ tools.O.bind("bCallee", () => tools.O.map(bVarNodeParent, (n) => n.callee)),
255
+ tools.O.exists(({ aCallee, bCallee }) => AST__namespace.isNodeEqual(aCallee, bCallee))
256
256
  );
257
257
  if (!hasSameCallee) return false;
258
258
  return tools.F.pipe(
259
259
  tools.O.Do,
260
- tools.O.bind("paramsA", () => tools.O.map(na, (n) => n.params)),
261
- tools.O.bind("paramsB", () => tools.O.map(nb, (n) => n.params)),
262
- tools.O.let("posA", ({ paramsA }) => paramsA.findIndex((p) => AST__namespace.isNodeEqual(p, a))),
263
- tools.O.let("posB", ({ paramsB }) => paramsB.findIndex((p) => AST__namespace.isNodeEqual(p, b))),
264
- tools.O.filter(({ posA, posB }) => posA !== -1 && posB !== -1),
265
- tools.O.exists(({ posA, posB }) => posA === posB)
260
+ tools.O.bind("aParams", () => tools.O.map(aVarNode, (n) => n.params)),
261
+ tools.O.bind("bParams", () => tools.O.map(bVarNode, (n) => n.params)),
262
+ tools.O.let("aPos", ({ aParams }) => aParams.findIndex((p) => AST__namespace.isNodeEqual(p, a))),
263
+ tools.O.let("bPos", ({ bParams }) => bParams.findIndex((p) => AST__namespace.isNodeEqual(p, b))),
264
+ tools.O.filter(({ aPos, bPos }) => aPos !== -1 && bPos !== -1),
265
+ tools.O.exists(({ aPos, bPos }) => aPos === bPos)
266
266
  );
267
267
  }
268
- case (tools.O.exists(dapp, AST__namespace.is(types.AST_NODE_TYPES.ForOfStatement)) && tools.O.exists(dbpp, AST__namespace.is(types.AST_NODE_TYPES.ForOfStatement))): {
268
+ case (tools.O.exists(aDefParentParent, AST__namespace.is(types.AST_NODE_TYPES.ForOfStatement)) && tools.O.exists(bDefParentParent, AST__namespace.is(types.AST_NODE_TYPES.ForOfStatement))): {
269
269
  return tools.F.pipe(
270
270
  tools.O.Do,
271
- tools.O.bind("rightA", () => tools.O.map(dapp, (d) => d.right)),
272
- tools.O.bind("rightB", () => tools.O.map(dbpp, (d) => d.right)),
273
- tools.O.exists(({ rightA, rightB }) => AST__namespace.isNodeEqual(rightA, rightB))
271
+ tools.O.bind("aRight", () => tools.O.map(aDefParentParent, (d) => d.right)),
272
+ tools.O.bind("bRight", () => tools.O.map(bDefParentParent, (d) => d.right)),
273
+ tools.O.exists(({ aRight, bRight }) => AST__namespace.isNodeEqual(aRight, bRight))
274
274
  );
275
275
  }
276
276
  default: {
277
- if (tools.O.isNone(na) || tools.O.isNone(nb)) return false;
278
- return na.value === nb.value;
277
+ return tools.O.isSome(aVar) && tools.O.isSome(bVar) && aVar.value === bVar.value;
279
278
  }
280
279
  }
281
280
  }
package/dist/index.mjs CHANGED
@@ -214,46 +214,45 @@ function isNodeValueEqual(a, b, initialScopes) {
214
214
  const bStatic = getStaticValue(b, bScope);
215
215
  if (aStatic && bStatic) return aStatic.value === bStatic.value;
216
216
  if (a.type === AST_NODE_TYPES.Identifier && b.type === AST_NODE_TYPES.Identifier) {
217
- const va = findVariable(a, aScope);
218
- const vb = findVariable(b, bScope);
219
- const da = O.flatMap(va, getVariableDef(0));
220
- const db = O.flatMap(vb, getVariableDef(0));
221
- const dapp = O.flatMapNullable(da, (d) => d.parent?.parent);
222
- const dbpp = O.flatMapNullable(db, (d) => d.parent?.parent);
223
- const na = O.flatMap(va, getVariableNode(0));
224
- const nb = O.flatMap(vb, getVariableNode(0));
225
- const nap = O.flatMapNullable(na, (n) => n.parent);
226
- const nbp = O.flatMapNullable(nb, (n) => n.parent);
217
+ const aVar = findVariable(a, aScope);
218
+ const bVar = findVariable(b, bScope);
219
+ const aVarNode = O.flatMap(aVar, getVariableNode(0));
220
+ const bVarNode = O.flatMap(bVar, getVariableNode(0));
221
+ const aVarNodeParent = O.flatMapNullable(aVarNode, (n) => n.parent);
222
+ const bVarNodeParent = O.flatMapNullable(bVarNode, (n) => n.parent);
223
+ const aDef = O.flatMap(aVar, getVariableDef(0));
224
+ const bDef = O.flatMap(bVar, getVariableDef(0));
225
+ const aDefParentParent = O.flatMapNullable(aDef, (d) => d.parent?.parent);
226
+ const bDefParentParent = O.flatMapNullable(bDef, (d) => d.parent?.parent);
227
227
  switch (true) {
228
- case (O.exists(nap, AST.is(AST_NODE_TYPES.CallExpression)) && O.exists(nbp, AST.is(AST_NODE_TYPES.CallExpression)) && O.exists(na, AST.isFunction) && O.exists(nb, AST.isFunction)): {
228
+ case (O.exists(aVarNodeParent, AST.is(AST_NODE_TYPES.CallExpression)) && O.exists(bVarNodeParent, AST.is(AST_NODE_TYPES.CallExpression)) && O.exists(aVarNode, AST.isFunction) && O.exists(bVarNode, AST.isFunction)): {
229
229
  const hasSameCallee = F.pipe(
230
230
  O.Do,
231
- O.bind("ca", () => O.map(nap, (n) => n.callee)),
232
- O.bind("cb", () => O.map(nbp, (n) => n.callee)),
233
- O.exists(({ ca, cb }) => AST.isNodeEqual(ca, cb))
231
+ O.bind("aCallee", () => O.map(aVarNodeParent, (n) => n.callee)),
232
+ O.bind("bCallee", () => O.map(bVarNodeParent, (n) => n.callee)),
233
+ O.exists(({ aCallee, bCallee }) => AST.isNodeEqual(aCallee, bCallee))
234
234
  );
235
235
  if (!hasSameCallee) return false;
236
236
  return F.pipe(
237
237
  O.Do,
238
- O.bind("paramsA", () => O.map(na, (n) => n.params)),
239
- O.bind("paramsB", () => O.map(nb, (n) => n.params)),
240
- O.let("posA", ({ paramsA }) => paramsA.findIndex((p) => AST.isNodeEqual(p, a))),
241
- O.let("posB", ({ paramsB }) => paramsB.findIndex((p) => AST.isNodeEqual(p, b))),
242
- O.filter(({ posA, posB }) => posA !== -1 && posB !== -1),
243
- O.exists(({ posA, posB }) => posA === posB)
238
+ O.bind("aParams", () => O.map(aVarNode, (n) => n.params)),
239
+ O.bind("bParams", () => O.map(bVarNode, (n) => n.params)),
240
+ O.let("aPos", ({ aParams }) => aParams.findIndex((p) => AST.isNodeEqual(p, a))),
241
+ O.let("bPos", ({ bParams }) => bParams.findIndex((p) => AST.isNodeEqual(p, b))),
242
+ O.filter(({ aPos, bPos }) => aPos !== -1 && bPos !== -1),
243
+ O.exists(({ aPos, bPos }) => aPos === bPos)
244
244
  );
245
245
  }
246
- case (O.exists(dapp, AST.is(AST_NODE_TYPES.ForOfStatement)) && O.exists(dbpp, AST.is(AST_NODE_TYPES.ForOfStatement))): {
246
+ case (O.exists(aDefParentParent, AST.is(AST_NODE_TYPES.ForOfStatement)) && O.exists(bDefParentParent, AST.is(AST_NODE_TYPES.ForOfStatement))): {
247
247
  return F.pipe(
248
248
  O.Do,
249
- O.bind("rightA", () => O.map(dapp, (d) => d.right)),
250
- O.bind("rightB", () => O.map(dbpp, (d) => d.right)),
251
- O.exists(({ rightA, rightB }) => AST.isNodeEqual(rightA, rightB))
249
+ O.bind("aRight", () => O.map(aDefParentParent, (d) => d.right)),
250
+ O.bind("bRight", () => O.map(bDefParentParent, (d) => d.right)),
251
+ O.exists(({ aRight, bRight }) => AST.isNodeEqual(aRight, bRight))
252
252
  );
253
253
  }
254
254
  default: {
255
- if (O.isNone(na) || O.isNone(nb)) return false;
256
- return na.value === nb.value;
255
+ return O.isSome(aVar) && O.isSome(bVar) && aVar.value === bVar.value;
257
256
  }
258
257
  }
259
258
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/var",
3
- "version": "1.17.3",
3
+ "version": "1.17.4-beta.0",
4
4
  "description": "TSESTree AST utility module for static analysis of variables",
5
5
  "homepage": "https://github.com/rel1cx/eslint-react",
6
6
  "bugs": {
@@ -39,9 +39,9 @@
39
39
  "@typescript-eslint/types": "^8.17.0",
40
40
  "@typescript-eslint/utils": "^8.17.0",
41
41
  "ts-pattern": "^5.5.0",
42
- "@eslint-react/ast": "1.17.3",
43
- "@eslint-react/tools": "1.17.3",
44
- "@eslint-react/types": "1.17.3"
42
+ "@eslint-react/tools": "1.17.4-beta.0",
43
+ "@eslint-react/types": "1.17.4-beta.0",
44
+ "@eslint-react/ast": "1.17.4-beta.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "string-ts": "^2.2.0",