@eslint-react/var 1.17.4-next.4 → 1.17.4-next.8
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 +6 -6
- package/dist/index.mjs +6 -7
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -123,8 +123,8 @@ function inspectConstruction(node, initialScope, hint = ConstructionHint.None) {
|
|
|
123
123
|
};
|
|
124
124
|
return detect(node);
|
|
125
125
|
}
|
|
126
|
-
var
|
|
127
|
-
return tools.O.fromNullable(
|
|
126
|
+
var findVariable2 = tools.F.dual(2, (nameOrNode, initialScope) => {
|
|
127
|
+
return tools.O.fromNullable(ASTUtils__namespace.findVariable(initialScope, nameOrNode));
|
|
128
128
|
});
|
|
129
129
|
|
|
130
130
|
// src/get-child-scopes.ts
|
|
@@ -194,7 +194,7 @@ function getVariables(initialScope) {
|
|
|
194
194
|
return variables.reverse();
|
|
195
195
|
}
|
|
196
196
|
function isInitializedFromSource(name, source, initialScope) {
|
|
197
|
-
const maybeLatestDef = tools.O.flatMapNullable(
|
|
197
|
+
const maybeLatestDef = tools.O.flatMapNullable(findVariable2(name, initialScope), (v) => v.defs.at(-1));
|
|
198
198
|
if (tools.O.isNone(maybeLatestDef)) return false;
|
|
199
199
|
const latestDef = maybeLatestDef.value;
|
|
200
200
|
const { node, parent } = latestDef;
|
|
@@ -243,8 +243,8 @@ function isNodeValueEqual(a, b, initialScopes) {
|
|
|
243
243
|
return a.value.cooked === b.value.cooked;
|
|
244
244
|
}
|
|
245
245
|
case (a.type === types.AST_NODE_TYPES.Identifier && b.type === types.AST_NODE_TYPES.Identifier): {
|
|
246
|
-
const aVar =
|
|
247
|
-
const bVar =
|
|
246
|
+
const aVar = findVariable2(a, aScope);
|
|
247
|
+
const bVar = findVariable2(b, bScope);
|
|
248
248
|
const aVarNode = tools.O.flatMap(aVar, getVariableNode(0));
|
|
249
249
|
const bVarNode = tools.O.flatMap(bVar, getVariableNode(0));
|
|
250
250
|
const aVarNodeParent = tools.O.flatMapNullable(aVarNode, (n) => n.parent);
|
|
@@ -313,7 +313,7 @@ function isNodeValueEqual(a, b, initialScopes) {
|
|
|
313
313
|
|
|
314
314
|
exports.Construction = Construction;
|
|
315
315
|
exports.ConstructionHint = ConstructionHint;
|
|
316
|
-
exports.findVariable =
|
|
316
|
+
exports.findVariable = findVariable2;
|
|
317
317
|
exports.getChidScopes = getChidScopes;
|
|
318
318
|
exports.getScope = getScope;
|
|
319
319
|
exports.getStaticValue = getStaticValue2;
|
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,6 @@ import { DefinitionType, ScopeType } from '@typescript-eslint/scope-manager';
|
|
|
4
4
|
import { AST_NODE_TYPES } from '@typescript-eslint/types';
|
|
5
5
|
import { match, isMatching } from 'ts-pattern';
|
|
6
6
|
import * as ASTUtils from '@typescript-eslint/utils/ast-utils';
|
|
7
|
-
import { findVariable as findVariable$1 } from '@typescript-eslint/utils/ast-utils';
|
|
8
7
|
|
|
9
8
|
// src/construction.ts
|
|
10
9
|
var Construction = Data.taggedEnum();
|
|
@@ -101,8 +100,8 @@ function inspectConstruction(node, initialScope, hint = ConstructionHint.None) {
|
|
|
101
100
|
};
|
|
102
101
|
return detect(node);
|
|
103
102
|
}
|
|
104
|
-
var
|
|
105
|
-
return O.fromNullable(findVariable
|
|
103
|
+
var findVariable2 = F.dual(2, (nameOrNode, initialScope) => {
|
|
104
|
+
return O.fromNullable(ASTUtils.findVariable(initialScope, nameOrNode));
|
|
106
105
|
});
|
|
107
106
|
|
|
108
107
|
// src/get-child-scopes.ts
|
|
@@ -172,7 +171,7 @@ function getVariables(initialScope) {
|
|
|
172
171
|
return variables.reverse();
|
|
173
172
|
}
|
|
174
173
|
function isInitializedFromSource(name, source, initialScope) {
|
|
175
|
-
const maybeLatestDef = O.flatMapNullable(
|
|
174
|
+
const maybeLatestDef = O.flatMapNullable(findVariable2(name, initialScope), (v) => v.defs.at(-1));
|
|
176
175
|
if (O.isNone(maybeLatestDef)) return false;
|
|
177
176
|
const latestDef = maybeLatestDef.value;
|
|
178
177
|
const { node, parent } = latestDef;
|
|
@@ -221,8 +220,8 @@ function isNodeValueEqual(a, b, initialScopes) {
|
|
|
221
220
|
return a.value.cooked === b.value.cooked;
|
|
222
221
|
}
|
|
223
222
|
case (a.type === AST_NODE_TYPES.Identifier && b.type === AST_NODE_TYPES.Identifier): {
|
|
224
|
-
const aVar =
|
|
225
|
-
const bVar =
|
|
223
|
+
const aVar = findVariable2(a, aScope);
|
|
224
|
+
const bVar = findVariable2(b, bScope);
|
|
226
225
|
const aVarNode = O.flatMap(aVar, getVariableNode(0));
|
|
227
226
|
const bVarNode = O.flatMap(bVar, getVariableNode(0));
|
|
228
227
|
const aVarNodeParent = O.flatMapNullable(aVarNode, (n) => n.parent);
|
|
@@ -289,4 +288,4 @@ function isNodeValueEqual(a, b, initialScopes) {
|
|
|
289
288
|
}
|
|
290
289
|
}
|
|
291
290
|
|
|
292
|
-
export { Construction, ConstructionHint, findVariable, getChidScopes, getScope, getStaticValue2 as getStaticValue, getVariableDeclaratorID, getVariableDef, getVariableNode, getVariables, inspectConstruction, isInitializedFromSource, isNodeValueEqual };
|
|
291
|
+
export { Construction, ConstructionHint, findVariable2 as findVariable, getChidScopes, getScope, getStaticValue2 as getStaticValue, getVariableDeclaratorID, getVariableDef, getVariableNode, getVariables, inspectConstruction, isInitializedFromSource, isNodeValueEqual };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/var",
|
|
3
|
-
"version": "1.17.4-next.
|
|
3
|
+
"version": "1.17.4-next.8",
|
|
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/types": "1.17.4-next.
|
|
42
|
+
"@eslint-react/ast": "1.17.4-next.8",
|
|
43
|
+
"@eslint-react/tools": "1.17.4-next.8",
|
|
44
|
+
"@eslint-react/types": "1.17.4-next.8"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"string-ts": "^2.2.0",
|