@eslint-react/var 2.0.7-beta.2 → 2.0.7-beta.3
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 +5 -12
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -87,12 +87,9 @@ function getConstruction(node, initialScope, hint = ConstructionDetectionHint.No
|
|
|
87
87
|
case AST_NODE_TYPES.ConditionalExpression:
|
|
88
88
|
if (getConstruction(node.consequent, initialScope, hint) == null) return unit;
|
|
89
89
|
return getConstruction(node.alternate, initialScope, hint);
|
|
90
|
-
case AST_NODE_TYPES.Identifier:
|
|
90
|
+
case AST_NODE_TYPES.Identifier:
|
|
91
91
|
if (!("name" in node) || typeof node.name !== "string") return unit;
|
|
92
|
-
|
|
93
|
-
const variableNode = getVariableDefinitionNode(variable, -1);
|
|
94
|
-
return getConstruction(variableNode, initialScope, hint);
|
|
95
|
-
}
|
|
92
|
+
return getConstruction(getVariableDefinitionNode(initialScope.set.get(node.name), -1), initialScope, hint);
|
|
96
93
|
case AST_NODE_TYPES.Literal:
|
|
97
94
|
if ("regex" in node) return {
|
|
98
95
|
kind: "RegExpLiteral",
|
|
@@ -146,8 +143,7 @@ function findProperty(name, properties, initialScope, seen = /* @__PURE__ */ new
|
|
|
146
143
|
if (prop.type === AST_NODE_TYPES.SpreadElement) switch (prop.argument.type) {
|
|
147
144
|
case AST_NODE_TYPES.Identifier: {
|
|
148
145
|
if (seen.has(prop.argument.name)) return false;
|
|
149
|
-
const
|
|
150
|
-
const variableNode = getVariableDefinitionNode(variable, 0);
|
|
146
|
+
const variableNode = getVariableDefinitionNode(findVariable(prop.argument.name, initialScope), 0);
|
|
151
147
|
if (variableNode?.type === AST_NODE_TYPES.ObjectExpression) {
|
|
152
148
|
seen.add(prop.argument.name);
|
|
153
149
|
return findProperty(name, variableNode.properties, initialScope, seen) != null;
|
|
@@ -222,12 +218,9 @@ function isNodeValueEqual(a, b, initialScopes) {
|
|
|
222
218
|
}
|
|
223
219
|
}
|
|
224
220
|
case a.type === AST_NODE_TYPES.MemberExpression && b.type === AST_NODE_TYPES.MemberExpression: return AST.isNodeEqual(a.property, b.property) && isNodeValueEqual(a.object, b.object, initialScopes);
|
|
225
|
-
case a.type === AST_NODE_TYPES.ThisExpression && b.type === AST_NODE_TYPES.ThisExpression:
|
|
221
|
+
case a.type === AST_NODE_TYPES.ThisExpression && b.type === AST_NODE_TYPES.ThisExpression:
|
|
226
222
|
if (aScope.block === bScope.block) return true;
|
|
227
|
-
|
|
228
|
-
const bFunction = AST.findParentNode(b, AST.isOneOf(thisBlockTypes));
|
|
229
|
-
return aFunction === bFunction;
|
|
230
|
-
}
|
|
223
|
+
return AST.findParentNode(a, AST.isOneOf(thisBlockTypes)) === AST.findParentNode(b, AST.isOneOf(thisBlockTypes));
|
|
231
224
|
default: {
|
|
232
225
|
const aStatic = getStaticValue(a, aScope);
|
|
233
226
|
const bStatic = getStaticValue(b, bScope);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/var",
|
|
3
|
-
"version": "2.0.7-beta.
|
|
3
|
+
"version": "2.0.7-beta.3",
|
|
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": {
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"@typescript-eslint/types": "^8.46.0",
|
|
32
32
|
"@typescript-eslint/utils": "^8.46.0",
|
|
33
33
|
"ts-pattern": "^5.8.0",
|
|
34
|
-
"@eslint-react/ast": "2.0.7-beta.
|
|
35
|
-
"@eslint-react/eff": "2.0.7-beta.
|
|
34
|
+
"@eslint-react/ast": "2.0.7-beta.3",
|
|
35
|
+
"@eslint-react/eff": "2.0.7-beta.3"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"tsdown": "^0.15.6",
|