@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 +25 -26
- package/dist/index.mjs +25 -26
- package/package.json +4 -4
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
|
|
240
|
-
const
|
|
241
|
-
const
|
|
242
|
-
const
|
|
243
|
-
const
|
|
244
|
-
const
|
|
245
|
-
const
|
|
246
|
-
const
|
|
247
|
-
const
|
|
248
|
-
const
|
|
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(
|
|
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("
|
|
254
|
-
tools.O.bind("
|
|
255
|
-
tools.O.exists(({
|
|
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("
|
|
261
|
-
tools.O.bind("
|
|
262
|
-
tools.O.let("
|
|
263
|
-
tools.O.let("
|
|
264
|
-
tools.O.filter(({
|
|
265
|
-
tools.O.exists(({
|
|
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(
|
|
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("
|
|
272
|
-
tools.O.bind("
|
|
273
|
-
tools.O.exists(({
|
|
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
|
-
|
|
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
|
|
218
|
-
const
|
|
219
|
-
const
|
|
220
|
-
const
|
|
221
|
-
const
|
|
222
|
-
const
|
|
223
|
-
const
|
|
224
|
-
const
|
|
225
|
-
const
|
|
226
|
-
const
|
|
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(
|
|
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("
|
|
232
|
-
O.bind("
|
|
233
|
-
O.exists(({
|
|
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("
|
|
239
|
-
O.bind("
|
|
240
|
-
O.let("
|
|
241
|
-
O.let("
|
|
242
|
-
O.filter(({
|
|
243
|
-
O.exists(({
|
|
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(
|
|
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("
|
|
250
|
-
O.bind("
|
|
251
|
-
O.exists(({
|
|
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
|
-
|
|
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
|
+
"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/
|
|
43
|
-
"@eslint-react/
|
|
44
|
-
"@eslint-react/
|
|
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",
|