@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.js CHANGED
@@ -1,287 +1,298 @@
1
- 'use strict';
2
-
3
- var eff = require('@eslint-react/eff');
4
- var scopeManager = require('@typescript-eslint/scope-manager');
5
- var types = require('@typescript-eslint/types');
6
- var ASTUtils = require('@typescript-eslint/utils/ast-utils');
7
- var AST = require('@eslint-react/ast');
8
-
9
- function _interopNamespace(e) {
10
- if (e && e.__esModule) return e;
11
- var n = Object.create(null);
12
- if (e) {
13
- Object.keys(e).forEach(function (k) {
14
- if (k !== 'default') {
15
- var d = Object.getOwnPropertyDescriptor(e, k);
16
- Object.defineProperty(n, k, d.get ? d : {
17
- enumerable: true,
18
- get: function () { return e[k]; }
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
- var ASTUtils__namespace = /*#__PURE__*/_interopNamespace(ASTUtils);
28
- var AST__namespace = /*#__PURE__*/_interopNamespace(AST);
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
- // src/var-collect.ts
30
+ //#region src/var-init-node.ts
31
31
  function getVariableInitNode(variable, at) {
32
- if (variable == null) return eff.unit;
33
- const def = variable.defs.at(at);
34
- if (def == null) return eff.unit;
35
- switch (true) {
36
- case (def.type === scopeManager.DefinitionType.FunctionName && def.node.type === types.AST_NODE_TYPES.FunctionDeclaration):
37
- return def.node;
38
- case (def.type === scopeManager.DefinitionType.ClassName && def.node.type === types.AST_NODE_TYPES.ClassDeclaration):
39
- return def.node;
40
- case ("init" in def.node && def.node.init != null && !("declarations" in def.node.init)):
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
- // src/var-collect.ts
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
- let scope = initialScope;
50
- const variables = [...scope.variables];
51
- while (scope.type !== scopeManager.ScopeType.global) {
52
- scope = scope.upper;
53
- variables.push(...scope.variables);
54
- }
55
- return variables.reverse();
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
- var findVariable2 = eff.dual(2, (nameOrNode, initialScope) => {
58
- if (nameOrNode == null) return eff.unit;
59
- return ASTUtils__namespace.findVariable(initialScope, nameOrNode) ?? eff.unit;
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
- return properties.findLast((prop) => {
63
- if (prop.type === types.AST_NODE_TYPES.Property) {
64
- return "name" in prop.key && prop.key.name === name;
65
- }
66
- if (prop.type === types.AST_NODE_TYPES.SpreadElement) {
67
- switch (prop.argument.type) {
68
- case types.AST_NODE_TYPES.Identifier: {
69
- if (seen.has(prop.argument.name)) return false;
70
- const variable = findVariable2(prop.argument.name, initialScope);
71
- const variableNode = getVariableInitNode(variable, 0);
72
- if (variableNode?.type === types.AST_NODE_TYPES.ObjectExpression) {
73
- seen.add(prop.argument.name);
74
- return findPropertyInProperties(
75
- name,
76
- variableNode.properties,
77
- initialScope,
78
- seen
79
- ) != null;
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
- var ConstructionDetectionHint = {
99
- None: 0n,
100
- StrictCallExpression: 1n << 0n
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
- if (node == null) return eff.unit;
104
- switch (node.type) {
105
- case types.AST_NODE_TYPES.JSXElement:
106
- case types.AST_NODE_TYPES.JSXFragment:
107
- return { kind: "JSXElement", node };
108
- case types.AST_NODE_TYPES.ArrayExpression:
109
- return { kind: "ArrayExpression", node };
110
- case types.AST_NODE_TYPES.ObjectExpression:
111
- return { kind: "ObjectExpression", node };
112
- case types.AST_NODE_TYPES.ClassExpression:
113
- return { kind: "ClassExpression", node };
114
- case types.AST_NODE_TYPES.NewExpression:
115
- return { kind: "NewExpression", node };
116
- case types.AST_NODE_TYPES.FunctionExpression:
117
- case types.AST_NODE_TYPES.ArrowFunctionExpression:
118
- return { kind: "FunctionExpression", node };
119
- case types.AST_NODE_TYPES.CallExpression: {
120
- if (hint & ConstructionDetectionHint.StrictCallExpression) {
121
- return { kind: "CallExpression", node };
122
- }
123
- return eff.unit;
124
- }
125
- case types.AST_NODE_TYPES.MemberExpression: {
126
- if (!("object" in node)) return eff.unit;
127
- return getConstruction(node.object, initialScope, hint);
128
- }
129
- case types.AST_NODE_TYPES.AssignmentExpression:
130
- case types.AST_NODE_TYPES.AssignmentPattern: {
131
- if (!("right" in node)) return eff.unit;
132
- return getConstruction(node.right, initialScope, hint);
133
- }
134
- case types.AST_NODE_TYPES.LogicalExpression: {
135
- const lvc = getConstruction(node.left, initialScope, hint);
136
- if (lvc == null) return eff.unit;
137
- return getConstruction(node.right, initialScope, hint);
138
- }
139
- case types.AST_NODE_TYPES.ConditionalExpression: {
140
- const cvc = getConstruction(node.consequent, initialScope, hint);
141
- if (cvc == null) return eff.unit;
142
- return getConstruction(node.alternate, initialScope, hint);
143
- }
144
- case types.AST_NODE_TYPES.Identifier: {
145
- if (!("name" in node) || typeof node.name !== "string") {
146
- return eff.unit;
147
- }
148
- const variable = initialScope.set.get(node.name);
149
- const variableNode = getVariableInitNode(variable, -1);
150
- return getConstruction(variableNode, initialScope, hint);
151
- }
152
- case types.AST_NODE_TYPES.Literal: {
153
- if ("regex" in node) {
154
- return { kind: "RegExpLiteral", node };
155
- }
156
- return eff.unit;
157
- }
158
- default: {
159
- if (!("expression" in node) || typeof node.expression !== "object") {
160
- return eff.unit;
161
- }
162
- return getConstruction(node.expression, initialScope, hint);
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
- if (node == null) return eff.unit;
168
- switch (true) {
169
- case (node.type === types.AST_NODE_TYPES.VariableDeclarator && node.init === prev):
170
- return node.id;
171
- case (node.type === types.AST_NODE_TYPES.AssignmentExpression && node.right === prev):
172
- return node.left;
173
- case (node.type === types.AST_NODE_TYPES.BlockStatement || node.type === types.AST_NODE_TYPES.Program || node.parent === node):
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
- // src/var-scope.ts
179
+ //#endregion
180
+ //#region src/var-scope.ts
181
181
  function getChidScopes(scope) {
182
- const scopes = [scope];
183
- for (const childScope of scope.childScopes) {
184
- scopes.push(...getChidScopes(childScope));
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
- const { kind, node, initialScope } = lazyValue;
190
- if (kind !== "lazy") {
191
- return lazyValue;
192
- }
193
- const staticValue = initialScope == null ? ASTUtils.getStaticValue(node) : ASTUtils.getStaticValue(node, initialScope);
194
- return staticValue == null ? { kind: "none", node, initialScope } : { kind: "some", node, initialScope, value: staticValue.value };
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
- var thisBlockTypes = [
197
- types.AST_NODE_TYPES.FunctionDeclaration,
198
- types.AST_NODE_TYPES.FunctionExpression,
199
- types.AST_NODE_TYPES.ClassBody,
200
- types.AST_NODE_TYPES.Program
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
- const [aScope, bScope] = initialScopes;
204
- switch (true) {
205
- case a === b: {
206
- return true;
207
- }
208
- case (a.type === types.AST_NODE_TYPES.Literal && b.type === types.AST_NODE_TYPES.Literal): {
209
- return a.value === b.value;
210
- }
211
- case (a.type === types.AST_NODE_TYPES.TemplateElement && b.type === types.AST_NODE_TYPES.TemplateElement): {
212
- return a.value.cooked === b.value.cooked;
213
- }
214
- case (a.type === types.AST_NODE_TYPES.Identifier && b.type === types.AST_NODE_TYPES.Identifier): {
215
- const aVar = findVariable2(a, aScope);
216
- const bVar = findVariable2(b, bScope);
217
- const aVarNode = getVariableInitNodeLoose(aVar, 0);
218
- const bVarNode = getVariableInitNodeLoose(bVar, 0);
219
- const aVarNodeParent = aVarNode?.parent;
220
- const bVarNodeParent = bVarNode?.parent;
221
- const aDef = aVar?.defs.at(0);
222
- const bDef = bVar?.defs.at(0);
223
- const aDefParentParent = aDef?.parent?.parent;
224
- const bDefParentParent = bDef?.parent?.parent;
225
- switch (true) {
226
- case (aVarNodeParent?.type === types.AST_NODE_TYPES.CallExpression && bVarNodeParent?.type === types.AST_NODE_TYPES.CallExpression && AST__namespace.isFunction(aVarNode) && AST__namespace.isFunction(bVarNode)): {
227
- if (!AST__namespace.isNodeEqual(aVarNodeParent.callee, bVarNodeParent.callee)) {
228
- return false;
229
- }
230
- const aParams = aVarNode.params;
231
- const bParams = bVarNode.params;
232
- const aPos = aParams.findIndex((x) => AST__namespace.isNodeEqual(x, a));
233
- const bPos = bParams.findIndex((x) => AST__namespace.isNodeEqual(x, b));
234
- return aPos !== -1 && bPos !== -1 && aPos === bPos;
235
- }
236
- case (aDefParentParent?.type === types.AST_NODE_TYPES.ForOfStatement && bDefParentParent?.type === types.AST_NODE_TYPES.ForOfStatement): {
237
- const aLeft = aDefParentParent.left;
238
- const bLeft = bDefParentParent.left;
239
- if (aLeft.type !== bLeft.type) {
240
- return false;
241
- }
242
- const aRight = aDefParentParent.right;
243
- const bRight = bDefParentParent.right;
244
- return AST__namespace.isNodeEqual(aRight, bRight);
245
- }
246
- default: {
247
- return aVar != null && bVar != null && aVar === bVar;
248
- }
249
- }
250
- }
251
- case (a.type === types.AST_NODE_TYPES.MemberExpression && b.type === types.AST_NODE_TYPES.MemberExpression): {
252
- return AST__namespace.isNodeEqual(a.property, b.property) && isNodeValueEqual(a.object, b.object, initialScopes);
253
- }
254
- case (a.type === types.AST_NODE_TYPES.ThisExpression && b.type === types.AST_NODE_TYPES.ThisExpression): {
255
- if (aScope.block === bScope.block) {
256
- return true;
257
- }
258
- const aFunction = AST__namespace.findParentNode(a, AST__namespace.isOneOf(thisBlockTypes));
259
- const bFunction = AST__namespace.findParentNode(b, AST__namespace.isOneOf(thisBlockTypes));
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
- if (variable == null) return eff.unit;
271
- const node = getVariableInitNode(variable, at);
272
- if (node != null) return node;
273
- const def = variable.defs.at(at);
274
- if (def?.type === scopeManager.DefinitionType.Parameter && AST__namespace.isFunction(def.node)) return def.node;
275
- return eff.unit;
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 = findVariable2;
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;