@eslint-react/var 1.52.9 → 1.52.10-beta.1
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.d.mts +60 -55
- package/dist/index.d.ts +60 -55
- package/dist/index.js +264 -253
- package/dist/index.mjs +242 -231
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1,287 +1,298 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
n.default = e;
|
|
24
|
-
return Object.freeze(n);
|
|
25
|
-
}
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
//#endregion
|
|
24
|
+
const __eslint_react_eff = __toESM(require("@eslint-react/eff"));
|
|
25
|
+
const __typescript_eslint_scope_manager = __toESM(require("@typescript-eslint/scope-manager"));
|
|
26
|
+
const __typescript_eslint_types = __toESM(require("@typescript-eslint/types"));
|
|
27
|
+
const __typescript_eslint_utils_ast_utils = __toESM(require("@typescript-eslint/utils/ast-utils"));
|
|
28
|
+
const __eslint_react_ast = __toESM(require("@eslint-react/ast"));
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
//#region src/var-init-node.ts
|
|
31
31
|
function getVariableInitNode(variable, at) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return def.node.init;
|
|
42
|
-
default:
|
|
43
|
-
return eff.unit;
|
|
44
|
-
}
|
|
32
|
+
if (variable == null) return __eslint_react_eff.unit;
|
|
33
|
+
const def = variable.defs.at(at);
|
|
34
|
+
if (def == null) return __eslint_react_eff.unit;
|
|
35
|
+
switch (true) {
|
|
36
|
+
case def.type === __typescript_eslint_scope_manager.DefinitionType.FunctionName && def.node.type === __typescript_eslint_types.AST_NODE_TYPES.FunctionDeclaration: return def.node;
|
|
37
|
+
case def.type === __typescript_eslint_scope_manager.DefinitionType.ClassName && def.node.type === __typescript_eslint_types.AST_NODE_TYPES.ClassDeclaration: return def.node;
|
|
38
|
+
case "init" in def.node && def.node.init != null && !("declarations" in def.node.init): return def.node.init;
|
|
39
|
+
default: return __eslint_react_eff.unit;
|
|
40
|
+
}
|
|
45
41
|
}
|
|
46
42
|
|
|
47
|
-
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/var-collect.ts
|
|
45
|
+
/**
|
|
46
|
+
* Get all variables from the given scope up to the global scope
|
|
47
|
+
* @param initialScope The scope to start from
|
|
48
|
+
* @returns All variables from the given scope up to the global scope
|
|
49
|
+
*/
|
|
48
50
|
function getVariables(initialScope) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
let scope = initialScope;
|
|
52
|
+
const variables = [...scope.variables];
|
|
53
|
+
while (scope.type !== __typescript_eslint_scope_manager.ScopeType.global) {
|
|
54
|
+
scope = scope.upper;
|
|
55
|
+
variables.push(...scope.variables);
|
|
56
|
+
}
|
|
57
|
+
return variables.reverse();
|
|
56
58
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
const findVariable = (0, __eslint_react_eff.dual)(2, (nameOrNode, initialScope) => {
|
|
60
|
+
if (nameOrNode == null) return __eslint_react_eff.unit;
|
|
61
|
+
return __typescript_eslint_utils_ast_utils.findVariable(initialScope, nameOrNode) ?? __eslint_react_eff.unit;
|
|
60
62
|
});
|
|
61
63
|
function findPropertyInProperties(name, properties, initialScope, seen = /* @__PURE__ */ new Set()) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
case types.AST_NODE_TYPES.ObjectExpression: {
|
|
84
|
-
return findPropertyInProperties(
|
|
85
|
-
name,
|
|
86
|
-
prop.argument.properties,
|
|
87
|
-
initialScope,
|
|
88
|
-
seen
|
|
89
|
-
) != null;
|
|
90
|
-
}
|
|
91
|
-
default:
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return false;
|
|
96
|
-
});
|
|
64
|
+
return properties.findLast((prop) => {
|
|
65
|
+
if (prop.type === __typescript_eslint_types.AST_NODE_TYPES.Property) return "name" in prop.key && prop.key.name === name;
|
|
66
|
+
if (prop.type === __typescript_eslint_types.AST_NODE_TYPES.SpreadElement) switch (prop.argument.type) {
|
|
67
|
+
case __typescript_eslint_types.AST_NODE_TYPES.Identifier: {
|
|
68
|
+
if (seen.has(prop.argument.name)) return false;
|
|
69
|
+
const variable = findVariable(prop.argument.name, initialScope);
|
|
70
|
+
const variableNode = getVariableInitNode(variable, 0);
|
|
71
|
+
if (variableNode?.type === __typescript_eslint_types.AST_NODE_TYPES.ObjectExpression) {
|
|
72
|
+
seen.add(prop.argument.name);
|
|
73
|
+
return findPropertyInProperties(name, variableNode.properties, initialScope, seen) != null;
|
|
74
|
+
}
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
case __typescript_eslint_types.AST_NODE_TYPES.ObjectExpression: return findPropertyInProperties(name, prop.argument.properties, initialScope, seen) != null;
|
|
78
|
+
default: return false;
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
});
|
|
97
82
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
//#region src/var-construction.ts
|
|
86
|
+
const ConstructionDetectionHint = {
|
|
87
|
+
None: 0n,
|
|
88
|
+
StrictCallExpression: 1n << 0n
|
|
101
89
|
};
|
|
90
|
+
/**
|
|
91
|
+
* Detects the construction type of a given node.
|
|
92
|
+
* @param node The node to check.
|
|
93
|
+
* @param initialScope The initial scope to check for variable declarations.
|
|
94
|
+
* @param hint Optional hint to control the detection behavior.
|
|
95
|
+
* @returns The construction type of the node, or `_` if not found.
|
|
96
|
+
*/
|
|
102
97
|
function getConstruction(node, initialScope, hint = ConstructionDetectionHint.None) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
98
|
+
if (node == null) return __eslint_react_eff.unit;
|
|
99
|
+
switch (node.type) {
|
|
100
|
+
case __typescript_eslint_types.AST_NODE_TYPES.JSXElement:
|
|
101
|
+
case __typescript_eslint_types.AST_NODE_TYPES.JSXFragment: return {
|
|
102
|
+
kind: "JSXElement",
|
|
103
|
+
node
|
|
104
|
+
};
|
|
105
|
+
case __typescript_eslint_types.AST_NODE_TYPES.ArrayExpression: return {
|
|
106
|
+
kind: "ArrayExpression",
|
|
107
|
+
node
|
|
108
|
+
};
|
|
109
|
+
case __typescript_eslint_types.AST_NODE_TYPES.ObjectExpression: return {
|
|
110
|
+
kind: "ObjectExpression",
|
|
111
|
+
node
|
|
112
|
+
};
|
|
113
|
+
case __typescript_eslint_types.AST_NODE_TYPES.ClassExpression: return {
|
|
114
|
+
kind: "ClassExpression",
|
|
115
|
+
node
|
|
116
|
+
};
|
|
117
|
+
case __typescript_eslint_types.AST_NODE_TYPES.NewExpression: return {
|
|
118
|
+
kind: "NewExpression",
|
|
119
|
+
node
|
|
120
|
+
};
|
|
121
|
+
case __typescript_eslint_types.AST_NODE_TYPES.FunctionExpression:
|
|
122
|
+
case __typescript_eslint_types.AST_NODE_TYPES.ArrowFunctionExpression: return {
|
|
123
|
+
kind: "FunctionExpression",
|
|
124
|
+
node
|
|
125
|
+
};
|
|
126
|
+
case __typescript_eslint_types.AST_NODE_TYPES.CallExpression:
|
|
127
|
+
if (hint & ConstructionDetectionHint.StrictCallExpression) return {
|
|
128
|
+
kind: "CallExpression",
|
|
129
|
+
node
|
|
130
|
+
};
|
|
131
|
+
return __eslint_react_eff.unit;
|
|
132
|
+
case __typescript_eslint_types.AST_NODE_TYPES.MemberExpression:
|
|
133
|
+
if (!("object" in node)) return __eslint_react_eff.unit;
|
|
134
|
+
return getConstruction(node.object, initialScope, hint);
|
|
135
|
+
case __typescript_eslint_types.AST_NODE_TYPES.AssignmentExpression:
|
|
136
|
+
case __typescript_eslint_types.AST_NODE_TYPES.AssignmentPattern:
|
|
137
|
+
if (!("right" in node)) return __eslint_react_eff.unit;
|
|
138
|
+
return getConstruction(node.right, initialScope, hint);
|
|
139
|
+
case __typescript_eslint_types.AST_NODE_TYPES.LogicalExpression: {
|
|
140
|
+
const lvc = getConstruction(node.left, initialScope, hint);
|
|
141
|
+
if (lvc == null) return __eslint_react_eff.unit;
|
|
142
|
+
return getConstruction(node.right, initialScope, hint);
|
|
143
|
+
}
|
|
144
|
+
case __typescript_eslint_types.AST_NODE_TYPES.ConditionalExpression: {
|
|
145
|
+
const cvc = getConstruction(node.consequent, initialScope, hint);
|
|
146
|
+
if (cvc == null) return __eslint_react_eff.unit;
|
|
147
|
+
return getConstruction(node.alternate, initialScope, hint);
|
|
148
|
+
}
|
|
149
|
+
case __typescript_eslint_types.AST_NODE_TYPES.Identifier: {
|
|
150
|
+
if (!("name" in node) || typeof node.name !== "string") return __eslint_react_eff.unit;
|
|
151
|
+
const variable = initialScope.set.get(node.name);
|
|
152
|
+
const variableNode = getVariableInitNode(variable, -1);
|
|
153
|
+
return getConstruction(variableNode, initialScope, hint);
|
|
154
|
+
}
|
|
155
|
+
case __typescript_eslint_types.AST_NODE_TYPES.Literal:
|
|
156
|
+
if ("regex" in node) return {
|
|
157
|
+
kind: "RegExpLiteral",
|
|
158
|
+
node
|
|
159
|
+
};
|
|
160
|
+
return __eslint_react_eff.unit;
|
|
161
|
+
default:
|
|
162
|
+
if (!("expression" in node) || typeof node.expression !== "object") return __eslint_react_eff.unit;
|
|
163
|
+
return getConstruction(node.expression, initialScope, hint);
|
|
164
|
+
}
|
|
165
165
|
}
|
|
166
|
+
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/var-declarator-id.ts
|
|
166
169
|
function getVariableDeclaratorId(node, prev) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
return eff.unit;
|
|
175
|
-
default:
|
|
176
|
-
return getVariableDeclaratorId(node.parent, node);
|
|
177
|
-
}
|
|
170
|
+
if (node == null) return __eslint_react_eff.unit;
|
|
171
|
+
switch (true) {
|
|
172
|
+
case node.type === __typescript_eslint_types.AST_NODE_TYPES.VariableDeclarator && node.init === prev: return node.id;
|
|
173
|
+
case node.type === __typescript_eslint_types.AST_NODE_TYPES.AssignmentExpression && node.right === prev: return node.left;
|
|
174
|
+
case node.type === __typescript_eslint_types.AST_NODE_TYPES.BlockStatement || node.type === __typescript_eslint_types.AST_NODE_TYPES.Program || node.parent === node: return __eslint_react_eff.unit;
|
|
175
|
+
default: return getVariableDeclaratorId(node.parent, node);
|
|
176
|
+
}
|
|
178
177
|
}
|
|
179
178
|
|
|
180
|
-
|
|
179
|
+
//#endregion
|
|
180
|
+
//#region src/var-scope.ts
|
|
181
181
|
function getChidScopes(scope) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
186
|
-
return scopes;
|
|
182
|
+
const scopes = [scope];
|
|
183
|
+
for (const childScope of scope.childScopes) scopes.push(...getChidScopes(childScope));
|
|
184
|
+
return scopes;
|
|
187
185
|
}
|
|
186
|
+
|
|
187
|
+
//#endregion
|
|
188
|
+
//#region src/var-value.ts
|
|
188
189
|
function toStaticValue(lazyValue) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
190
|
+
const { kind, node, initialScope } = lazyValue;
|
|
191
|
+
if (kind !== "lazy") return lazyValue;
|
|
192
|
+
const staticValue = initialScope == null ? (0, __typescript_eslint_utils_ast_utils.getStaticValue)(node) : (0, __typescript_eslint_utils_ast_utils.getStaticValue)(node, initialScope);
|
|
193
|
+
return staticValue == null ? {
|
|
194
|
+
kind: "none",
|
|
195
|
+
node,
|
|
196
|
+
initialScope
|
|
197
|
+
} : {
|
|
198
|
+
kind: "some",
|
|
199
|
+
node,
|
|
200
|
+
initialScope,
|
|
201
|
+
value: staticValue.value
|
|
202
|
+
};
|
|
195
203
|
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
204
|
+
|
|
205
|
+
//#endregion
|
|
206
|
+
//#region src/var-value-equal.ts
|
|
207
|
+
const thisBlockTypes = [
|
|
208
|
+
__typescript_eslint_types.AST_NODE_TYPES.FunctionDeclaration,
|
|
209
|
+
__typescript_eslint_types.AST_NODE_TYPES.FunctionExpression,
|
|
210
|
+
__typescript_eslint_types.AST_NODE_TYPES.ClassBody,
|
|
211
|
+
__typescript_eslint_types.AST_NODE_TYPES.Program
|
|
201
212
|
];
|
|
213
|
+
/**
|
|
214
|
+
* Determines whether node value equals to another node value
|
|
215
|
+
* @param a node to compare
|
|
216
|
+
* @param b node to compare
|
|
217
|
+
* @param initialScopes initial scopes of the two nodes
|
|
218
|
+
* @returns `true` if node value equal
|
|
219
|
+
*/
|
|
202
220
|
function isNodeValueEqual(a, b, initialScopes) {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
return aFunction === bFunction;
|
|
261
|
-
}
|
|
262
|
-
default: {
|
|
263
|
-
const aStatic = toStaticValue({ kind: "lazy", node: a, initialScope: aScope });
|
|
264
|
-
const bStatic = toStaticValue({ kind: "lazy", node: b, initialScope: bScope });
|
|
265
|
-
return aStatic.kind !== "none" && bStatic.kind !== "none" && aStatic.value === bStatic.value;
|
|
266
|
-
}
|
|
267
|
-
}
|
|
221
|
+
const [aScope, bScope] = initialScopes;
|
|
222
|
+
switch (true) {
|
|
223
|
+
case a === b: return true;
|
|
224
|
+
case a.type === __typescript_eslint_types.AST_NODE_TYPES.Literal && b.type === __typescript_eslint_types.AST_NODE_TYPES.Literal: return a.value === b.value;
|
|
225
|
+
case a.type === __typescript_eslint_types.AST_NODE_TYPES.TemplateElement && b.type === __typescript_eslint_types.AST_NODE_TYPES.TemplateElement: return a.value.cooked === b.value.cooked;
|
|
226
|
+
case a.type === __typescript_eslint_types.AST_NODE_TYPES.Identifier && b.type === __typescript_eslint_types.AST_NODE_TYPES.Identifier: {
|
|
227
|
+
const aVar = findVariable(a, aScope);
|
|
228
|
+
const bVar = findVariable(b, bScope);
|
|
229
|
+
const aVarNode = getVariableInitNodeLoose(aVar, 0);
|
|
230
|
+
const bVarNode = getVariableInitNodeLoose(bVar, 0);
|
|
231
|
+
const aVarNodeParent = aVarNode?.parent;
|
|
232
|
+
const bVarNodeParent = bVarNode?.parent;
|
|
233
|
+
const aDef = aVar?.defs.at(0);
|
|
234
|
+
const bDef = bVar?.defs.at(0);
|
|
235
|
+
const aDefParentParent = aDef?.parent?.parent;
|
|
236
|
+
const bDefParentParent = bDef?.parent?.parent;
|
|
237
|
+
switch (true) {
|
|
238
|
+
case aVarNodeParent?.type === __typescript_eslint_types.AST_NODE_TYPES.CallExpression && bVarNodeParent?.type === __typescript_eslint_types.AST_NODE_TYPES.CallExpression && __eslint_react_ast.isFunction(aVarNode) && __eslint_react_ast.isFunction(bVarNode): {
|
|
239
|
+
if (!__eslint_react_ast.isNodeEqual(aVarNodeParent.callee, bVarNodeParent.callee)) return false;
|
|
240
|
+
const aParams = aVarNode.params;
|
|
241
|
+
const bParams = bVarNode.params;
|
|
242
|
+
const aPos = aParams.findIndex((x) => __eslint_react_ast.isNodeEqual(x, a));
|
|
243
|
+
const bPos = bParams.findIndex((x) => __eslint_react_ast.isNodeEqual(x, b));
|
|
244
|
+
return aPos !== -1 && bPos !== -1 && aPos === bPos;
|
|
245
|
+
}
|
|
246
|
+
case aDefParentParent?.type === __typescript_eslint_types.AST_NODE_TYPES.ForOfStatement && bDefParentParent?.type === __typescript_eslint_types.AST_NODE_TYPES.ForOfStatement: {
|
|
247
|
+
const aLeft = aDefParentParent.left;
|
|
248
|
+
const bLeft = bDefParentParent.left;
|
|
249
|
+
if (aLeft.type !== bLeft.type) return false;
|
|
250
|
+
const aRight = aDefParentParent.right;
|
|
251
|
+
const bRight = bDefParentParent.right;
|
|
252
|
+
return __eslint_react_ast.isNodeEqual(aRight, bRight);
|
|
253
|
+
}
|
|
254
|
+
default: return aVar != null && bVar != null && aVar === bVar;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
case a.type === __typescript_eslint_types.AST_NODE_TYPES.MemberExpression && b.type === __typescript_eslint_types.AST_NODE_TYPES.MemberExpression: return __eslint_react_ast.isNodeEqual(a.property, b.property) && isNodeValueEqual(a.object, b.object, initialScopes);
|
|
258
|
+
case a.type === __typescript_eslint_types.AST_NODE_TYPES.ThisExpression && b.type === __typescript_eslint_types.AST_NODE_TYPES.ThisExpression: {
|
|
259
|
+
if (aScope.block === bScope.block) return true;
|
|
260
|
+
const aFunction = __eslint_react_ast.findParentNode(a, __eslint_react_ast.isOneOf(thisBlockTypes));
|
|
261
|
+
const bFunction = __eslint_react_ast.findParentNode(b, __eslint_react_ast.isOneOf(thisBlockTypes));
|
|
262
|
+
return aFunction === bFunction;
|
|
263
|
+
}
|
|
264
|
+
default: {
|
|
265
|
+
const aStatic = toStaticValue({
|
|
266
|
+
kind: "lazy",
|
|
267
|
+
node: a,
|
|
268
|
+
initialScope: aScope
|
|
269
|
+
});
|
|
270
|
+
const bStatic = toStaticValue({
|
|
271
|
+
kind: "lazy",
|
|
272
|
+
node: b,
|
|
273
|
+
initialScope: bScope
|
|
274
|
+
});
|
|
275
|
+
return aStatic.kind !== "none" && bStatic.kind !== "none" && aStatic.value === bStatic.value;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
268
278
|
}
|
|
269
279
|
function getVariableInitNodeLoose(variable, at) {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
280
|
+
if (variable == null) return __eslint_react_eff.unit;
|
|
281
|
+
const node = getVariableInitNode(variable, at);
|
|
282
|
+
if (node != null) return node;
|
|
283
|
+
const def = variable.defs.at(at);
|
|
284
|
+
if (def?.type === __typescript_eslint_scope_manager.DefinitionType.Parameter && __eslint_react_ast.isFunction(def.node)) return def.node;
|
|
285
|
+
return __eslint_react_eff.unit;
|
|
276
286
|
}
|
|
277
287
|
|
|
288
|
+
//#endregion
|
|
278
289
|
exports.ConstructionDetectionHint = ConstructionDetectionHint;
|
|
279
290
|
exports.findPropertyInProperties = findPropertyInProperties;
|
|
280
|
-
exports.findVariable =
|
|
291
|
+
exports.findVariable = findVariable;
|
|
281
292
|
exports.getChidScopes = getChidScopes;
|
|
282
293
|
exports.getConstruction = getConstruction;
|
|
283
294
|
exports.getVariableDeclaratorId = getVariableDeclaratorId;
|
|
284
295
|
exports.getVariableInitNode = getVariableInitNode;
|
|
285
296
|
exports.getVariables = getVariables;
|
|
286
297
|
exports.isNodeValueEqual = isNodeValueEqual;
|
|
287
|
-
exports.toStaticValue = toStaticValue;
|
|
298
|
+
exports.toStaticValue = toStaticValue;
|