@eslint-react/core 2.0.0-next.0 → 2.0.0-next.10

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,57 +1,31 @@
1
- 'use strict';
2
-
3
- var types = require('@typescript-eslint/types');
4
- var AST14 = require('@eslint-react/ast');
5
- var eff = require('@eslint-react/eff');
6
- var kit = require('@eslint-react/kit');
7
- var shared = require('@eslint-react/shared');
8
- var VAR3 = require('@eslint-react/var');
9
- var tsPattern = require('ts-pattern');
10
- var birecord = require('birecord');
11
-
12
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
-
14
- function _interopNamespace(e) {
15
- if (e && e.__esModule) return e;
16
- var n = Object.create(null);
17
- if (e) {
18
- Object.keys(e).forEach(function (k) {
19
- if (k !== 'default') {
20
- var d = Object.getOwnPropertyDescriptor(e, k);
21
- Object.defineProperty(n, k, d.get ? d : {
22
- enumerable: true,
23
- get: function () { return e[k]; }
24
- });
25
- }
26
- });
27
- }
28
- n.default = e;
29
- return Object.freeze(n);
30
- }
31
-
32
- var AST14__namespace = /*#__PURE__*/_interopNamespace(AST14);
33
- var VAR3__namespace = /*#__PURE__*/_interopNamespace(VAR3);
34
- var birecord__default = /*#__PURE__*/_interopDefault(birecord);
1
+ import { AST_NODE_TYPES } from '@typescript-eslint/types';
2
+ import * as AST14 from '@eslint-react/ast';
3
+ import { flip, dual, constFalse, identity, constTrue, _ } from '@eslint-react/eff';
4
+ import { RegExp, Selector } from '@eslint-react/kit';
5
+ import { coerceSettings, DEFAULT_ESLINT_REACT_SETTINGS, getId } from '@eslint-react/shared';
6
+ import * as VAR3 from '@eslint-react/var';
7
+ import { isMatching, P, match } from 'ts-pattern';
8
+ import birecord from 'birecord';
35
9
 
36
10
  // src/component/component-children.ts
37
11
  function isReactAPI(api) {
38
12
  const func = (context, node) => {
39
13
  if (node == null) return false;
40
14
  const getText = (n) => context.sourceCode.getText(n);
41
- const name = AST14__namespace.toString(node, getText);
15
+ const name = AST14.toString(node, getText);
42
16
  if (name === api) return true;
43
17
  if (name.substring(name.indexOf(".") + 1) === api) return true;
44
18
  return false;
45
19
  };
46
- return eff.dual(2, func);
20
+ return dual(2, func);
47
21
  }
48
22
  function isReactAPICall(api) {
49
23
  const func = (context, node) => {
50
24
  if (node == null) return false;
51
- if (node.type !== types.AST_NODE_TYPES.CallExpression) return false;
25
+ if (node.type !== AST_NODE_TYPES.CallExpression) return false;
52
26
  return isReactAPI(api)(context, node.callee);
53
27
  };
54
- return eff.dual(2, func);
28
+ return dual(2, func);
55
29
  }
56
30
  var isCaptureOwnerStack = isReactAPI("captureOwnerStack");
57
31
  var isChildrenCount = isReactAPI("Children.count");
@@ -83,51 +57,51 @@ var isLazyCall = isReactAPICall("lazy");
83
57
  // src/component/component-children.ts
84
58
  function isChildrenOfCreateElement(context, node) {
85
59
  const parent = node.parent;
86
- if (parent == null || parent.type !== types.AST_NODE_TYPES.CallExpression) return false;
60
+ if (parent == null || parent.type !== AST_NODE_TYPES.CallExpression) return false;
87
61
  if (!isCreateElementCall(context, parent)) return false;
88
62
  return parent.arguments.slice(2).some((arg) => arg === node);
89
63
  }
90
64
  function getInstanceId(node, prev) {
91
65
  switch (true) {
92
- case (node.type === types.AST_NODE_TYPES.VariableDeclarator && node.init === prev):
66
+ case (node.type === AST_NODE_TYPES.VariableDeclarator && node.init === prev):
93
67
  return node.id;
94
- case (node.type === types.AST_NODE_TYPES.AssignmentExpression && node.right === prev):
68
+ case (node.type === AST_NODE_TYPES.AssignmentExpression && node.right === prev):
95
69
  return node.left;
96
- case (node.type === types.AST_NODE_TYPES.PropertyDefinition && node.value === prev):
70
+ case (node.type === AST_NODE_TYPES.PropertyDefinition && node.value === prev):
97
71
  return node.key;
98
- case (node.type === types.AST_NODE_TYPES.BlockStatement || node.type === types.AST_NODE_TYPES.Program || node.parent === node):
99
- return eff._;
72
+ case (node.type === AST_NODE_TYPES.BlockStatement || node.type === AST_NODE_TYPES.Program || node.parent === node):
73
+ return _;
100
74
  default:
101
75
  return getInstanceId(node.parent, node);
102
76
  }
103
77
  }
104
78
  function getRequireExpressionArguments(node) {
105
- return tsPattern.match(node).with({ type: types.AST_NODE_TYPES.CallExpression, arguments: tsPattern.P.select(), callee: { type: types.AST_NODE_TYPES.Identifier, name: "require" } }, eff.identity).with({ type: types.AST_NODE_TYPES.MemberExpression, object: tsPattern.P.select() }, getRequireExpressionArguments).otherwise(() => null);
79
+ return match(node).with({ type: AST_NODE_TYPES.CallExpression, arguments: P.select(), callee: { type: AST_NODE_TYPES.Identifier, name: "require" } }, identity).with({ type: AST_NODE_TYPES.MemberExpression, object: P.select() }, getRequireExpressionArguments).otherwise(() => null);
106
80
  }
107
81
  function isInitializedFromReact(name, importSource, initialScope) {
108
82
  if (name.toLowerCase() === "react") return true;
109
- const latestDef = VAR3__namespace.findVariable(name, initialScope)?.defs.at(-1);
83
+ const latestDef = VAR3.findVariable(name, initialScope)?.defs.at(-1);
110
84
  if (latestDef == null) return false;
111
85
  const { node, parent } = latestDef;
112
- if (node.type === types.AST_NODE_TYPES.VariableDeclarator && node.init != null) {
86
+ if (node.type === AST_NODE_TYPES.VariableDeclarator && node.init != null) {
113
87
  const { init } = node;
114
- if (init.type === types.AST_NODE_TYPES.MemberExpression && init.object.type === types.AST_NODE_TYPES.Identifier) {
88
+ if (init.type === AST_NODE_TYPES.MemberExpression && init.object.type === AST_NODE_TYPES.Identifier) {
115
89
  return isInitializedFromReact(init.object.name, importSource, initialScope);
116
90
  }
117
- if (init.type === types.AST_NODE_TYPES.Identifier) {
91
+ if (init.type === AST_NODE_TYPES.Identifier) {
118
92
  return isInitializedFromReact(init.name, importSource, initialScope);
119
93
  }
120
94
  const args = getRequireExpressionArguments(init);
121
95
  const arg0 = args?.[0];
122
- if (arg0 == null || !AST14__namespace.isLiteral(arg0, "string")) {
96
+ if (arg0 == null || !AST14.isLiteral(arg0, "string")) {
123
97
  return false;
124
98
  }
125
99
  return arg0.value === importSource || arg0.value.startsWith(`${importSource}/`);
126
100
  }
127
- return parent?.type === types.AST_NODE_TYPES.ImportDeclaration && parent.source.value === importSource;
101
+ return parent?.type === AST_NODE_TYPES.ImportDeclaration && parent.source.value === importSource;
128
102
  }
129
103
  function isInstanceIdEqual(context, a, b) {
130
- return AST14__namespace.isNodeEqual(a, b) || VAR3__namespace.isNodeValueEqual(a, b, [
104
+ return AST14.isNodeEqual(a, b) || VAR3.isNodeValueEqual(a, b, [
131
105
  context.sourceCode.getScope(a),
132
106
  context.sourceCode.getScope(b)
133
107
  ]);
@@ -141,34 +115,34 @@ function isReactHookName(name) {
141
115
  // src/hook/hook-is.ts
142
116
  function isReactHook(node) {
143
117
  if (node == null) return false;
144
- const id = AST14__namespace.getFunctionId(node);
118
+ const id = AST14.getFunctionId(node);
145
119
  return id?.name != null && isReactHookName(id.name);
146
120
  }
147
121
  function isReactHookCall(node) {
148
122
  if (node == null) return false;
149
- if (node.type !== types.AST_NODE_TYPES.CallExpression) {
123
+ if (node.type !== AST_NODE_TYPES.CallExpression) {
150
124
  return false;
151
125
  }
152
- if (node.callee.type === types.AST_NODE_TYPES.Identifier) {
126
+ if (node.callee.type === AST_NODE_TYPES.Identifier) {
153
127
  return isReactHookName(node.callee.name);
154
128
  }
155
- if (node.callee.type === types.AST_NODE_TYPES.MemberExpression) {
156
- return node.callee.property.type === types.AST_NODE_TYPES.Identifier && isReactHookName(node.callee.property.name);
129
+ if (node.callee.type === AST_NODE_TYPES.MemberExpression) {
130
+ return node.callee.property.type === AST_NODE_TYPES.Identifier && isReactHookName(node.callee.property.name);
157
131
  }
158
132
  return false;
159
133
  }
160
134
  function isReactHookCallWithName(context, node) {
161
- if (node == null || node.type !== types.AST_NODE_TYPES.CallExpression) return eff.constFalse;
135
+ if (node == null || node.type !== AST_NODE_TYPES.CallExpression) return constFalse;
162
136
  const {
163
- importSource = shared.DEFAULT_ESLINT_REACT_SETTINGS.importSource,
137
+ importSource = DEFAULT_ESLINT_REACT_SETTINGS.importSource,
164
138
  skipImportCheck = true
165
- } = shared.coerceSettings(context.settings);
139
+ } = coerceSettings(context.settings);
166
140
  const initialScope = context.sourceCode.getScope(node);
167
141
  return (name) => {
168
142
  switch (true) {
169
- case (node.callee.type === types.AST_NODE_TYPES.Identifier && node.callee.name === name):
143
+ case (node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === name):
170
144
  return skipImportCheck || isInitializedFromReact(name, importSource, initialScope);
171
- case (node.callee.type === types.AST_NODE_TYPES.MemberExpression && node.callee.property.type === types.AST_NODE_TYPES.Identifier && node.callee.property.name === name && "name" in node.callee.object):
145
+ case (node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === name && "name" in node.callee.object):
172
146
  return skipImportCheck || isInitializedFromReact(node.callee.object.name, importSource, initialScope);
173
147
  default:
174
148
  return false;
@@ -176,13 +150,13 @@ function isReactHookCallWithName(context, node) {
176
150
  };
177
151
  }
178
152
  function isReactHookCallWithNameLoose(node) {
179
- if (node == null || node.type !== types.AST_NODE_TYPES.CallExpression) return eff.constFalse;
153
+ if (node == null || node.type !== AST_NODE_TYPES.CallExpression) return constFalse;
180
154
  return (name) => {
181
155
  switch (node.callee.type) {
182
- case types.AST_NODE_TYPES.Identifier:
156
+ case AST_NODE_TYPES.Identifier:
183
157
  return node.callee.name === name;
184
- case types.AST_NODE_TYPES.MemberExpression:
185
- return node.callee.property.type === types.AST_NODE_TYPES.Identifier && node.callee.property.name === name;
158
+ case AST_NODE_TYPES.MemberExpression:
159
+ return node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === name;
186
160
  default:
187
161
  return false;
188
162
  }
@@ -190,15 +164,15 @@ function isReactHookCallWithNameLoose(node) {
190
164
  }
191
165
  function isReactHookCallWithNameAlias(context, name, alias = []) {
192
166
  const {
193
- importSource = shared.DEFAULT_ESLINT_REACT_SETTINGS.importSource,
167
+ importSource = DEFAULT_ESLINT_REACT_SETTINGS.importSource,
194
168
  skipImportCheck = true
195
- } = shared.coerceSettings(context.settings);
169
+ } = coerceSettings(context.settings);
196
170
  return (node) => {
197
171
  const initialScope = context.sourceCode.getScope(node);
198
172
  switch (true) {
199
- case (node.callee.type === types.AST_NODE_TYPES.Identifier && node.callee.name === name):
173
+ case (node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === name):
200
174
  return skipImportCheck || isInitializedFromReact(name, importSource, initialScope);
201
- case (node.callee.type === types.AST_NODE_TYPES.MemberExpression && node.callee.property.type === types.AST_NODE_TYPES.Identifier && node.callee.property.name === name && "name" in node.callee.object):
175
+ case (node.callee.type === AST_NODE_TYPES.MemberExpression && node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === name && "name" in node.callee.object):
202
176
  return skipImportCheck || isInitializedFromReact(node.callee.object.name, importSource, initialScope);
203
177
  default:
204
178
  return alias.some(isReactHookCallWithNameLoose(node));
@@ -207,45 +181,45 @@ function isReactHookCallWithNameAlias(context, name, alias = []) {
207
181
  }
208
182
  function isUseEffectCallLoose(node) {
209
183
  if (node == null) return false;
210
- if (node.type !== types.AST_NODE_TYPES.CallExpression) {
184
+ if (node.type !== AST_NODE_TYPES.CallExpression) {
211
185
  return false;
212
186
  }
213
187
  switch (node.callee.type) {
214
- case types.AST_NODE_TYPES.Identifier:
188
+ case AST_NODE_TYPES.Identifier:
215
189
  return /^use\w*Effect$/u.test(node.callee.name);
216
- case types.AST_NODE_TYPES.MemberExpression:
217
- return node.callee.property.type === types.AST_NODE_TYPES.Identifier && /^use\w*Effect$/u.test(node.callee.property.name);
190
+ case AST_NODE_TYPES.MemberExpression:
191
+ return node.callee.property.type === AST_NODE_TYPES.Identifier && /^use\w*Effect$/u.test(node.callee.property.name);
218
192
  default:
219
193
  return false;
220
194
  }
221
195
  }
222
- var isUseCall = eff.flip(isReactHookCallWithName)("use");
223
- var isUseActionStateCall = eff.flip(isReactHookCallWithName)("useActionState");
224
- var isUseCallbackCall = eff.flip(isReactHookCallWithName)("useCallback");
225
- var isUseContextCall = eff.flip(isReactHookCallWithName)("useContext");
226
- var isUseDebugValueCall = eff.flip(isReactHookCallWithName)("useDebugValue");
227
- var isUseDeferredValueCall = eff.flip(isReactHookCallWithName)("useDeferredValue");
228
- var isUseEffectCall = eff.flip(isReactHookCallWithName)("useEffect");
229
- var isUseFormStatusCall = eff.flip(isReactHookCallWithName)("useFormStatus");
230
- var isUseIdCall = eff.flip(isReactHookCallWithName)("useId");
231
- var isUseImperativeHandleCall = eff.flip(isReactHookCallWithName)("useImperativeHandle");
232
- var isUseInsertionEffectCall = eff.flip(isReactHookCallWithName)("useInsertionEffect");
233
- var isUseLayoutEffectCall = eff.flip(isReactHookCallWithName)("useLayoutEffect");
234
- var isUseMemoCall = eff.flip(isReactHookCallWithName)("useMemo");
235
- var isUseOptimisticCall = eff.flip(isReactHookCallWithName)("useOptimistic");
236
- var isUseReducerCall = eff.flip(isReactHookCallWithName)("useReducer");
237
- var isUseRefCall = eff.flip(isReactHookCallWithName)("useRef");
238
- var isUseStateCall = eff.flip(isReactHookCallWithName)("useState");
239
- var isUseSyncExternalStoreCall = eff.flip(isReactHookCallWithName)("useSyncExternalStore");
240
- var isUseTransitionCall = eff.flip(isReactHookCallWithName)("useTransition");
196
+ var isUseCall = flip(isReactHookCallWithName)("use");
197
+ var isUseActionStateCall = flip(isReactHookCallWithName)("useActionState");
198
+ var isUseCallbackCall = flip(isReactHookCallWithName)("useCallback");
199
+ var isUseContextCall = flip(isReactHookCallWithName)("useContext");
200
+ var isUseDebugValueCall = flip(isReactHookCallWithName)("useDebugValue");
201
+ var isUseDeferredValueCall = flip(isReactHookCallWithName)("useDeferredValue");
202
+ var isUseEffectCall = flip(isReactHookCallWithName)("useEffect");
203
+ var isUseFormStatusCall = flip(isReactHookCallWithName)("useFormStatus");
204
+ var isUseIdCall = flip(isReactHookCallWithName)("useId");
205
+ var isUseImperativeHandleCall = flip(isReactHookCallWithName)("useImperativeHandle");
206
+ var isUseInsertionEffectCall = flip(isReactHookCallWithName)("useInsertionEffect");
207
+ var isUseLayoutEffectCall = flip(isReactHookCallWithName)("useLayoutEffect");
208
+ var isUseMemoCall = flip(isReactHookCallWithName)("useMemo");
209
+ var isUseOptimisticCall = flip(isReactHookCallWithName)("useOptimistic");
210
+ var isUseReducerCall = flip(isReactHookCallWithName)("useReducer");
211
+ var isUseRefCall = flip(isReactHookCallWithName)("useRef");
212
+ var isUseStateCall = flip(isReactHookCallWithName)("useState");
213
+ var isUseSyncExternalStoreCall = flip(isReactHookCallWithName)("useSyncExternalStore");
214
+ var isUseTransitionCall = flip(isReactHookCallWithName)("useTransition");
241
215
 
242
216
  // src/hook/hook-collector.ts
243
217
  function useHookCollector() {
244
218
  const hooks = /* @__PURE__ */ new Map();
245
219
  const functionEntries = [];
246
220
  const onFunctionEnter = (node) => {
247
- const id = AST14__namespace.getFunctionId(node);
248
- const key = shared.getId();
221
+ const id = AST14.getFunctionId(node);
222
+ const key = getId();
249
223
  const name = id?.name;
250
224
  if (name != null && isReactHookName(name)) {
251
225
  functionEntries.push({ key, node, isHook: true });
@@ -292,23 +266,33 @@ function useHookCollector() {
292
266
  };
293
267
  return { ctx, listeners };
294
268
  }
269
+ function isReactHookId(id) {
270
+ switch (id.type) {
271
+ case AST_NODE_TYPES.Identifier:
272
+ return isReactHookName(id.name);
273
+ case AST_NODE_TYPES.MemberExpression:
274
+ return "name" in id.property && isReactHookName(id.property.name);
275
+ default:
276
+ return false;
277
+ }
278
+ }
295
279
  function stringifyJsx(node) {
296
280
  switch (node.type) {
297
- case types.AST_NODE_TYPES.JSXIdentifier:
281
+ case AST_NODE_TYPES.JSXIdentifier:
298
282
  return node.name;
299
- case types.AST_NODE_TYPES.JSXNamespacedName:
283
+ case AST_NODE_TYPES.JSXNamespacedName:
300
284
  return `${node.namespace.name}:${node.name.name}`;
301
- case types.AST_NODE_TYPES.JSXMemberExpression:
285
+ case AST_NODE_TYPES.JSXMemberExpression:
302
286
  return `${stringifyJsx(node.object)}.${stringifyJsx(node.property)}`;
303
- case types.AST_NODE_TYPES.JSXText:
287
+ case AST_NODE_TYPES.JSXText:
304
288
  return node.value;
305
- case types.AST_NODE_TYPES.JSXOpeningElement:
289
+ case AST_NODE_TYPES.JSXOpeningElement:
306
290
  return `<${stringifyJsx(node.name)}>`;
307
- case types.AST_NODE_TYPES.JSXClosingElement:
291
+ case AST_NODE_TYPES.JSXClosingElement:
308
292
  return `</${stringifyJsx(node.name)}>`;
309
- case types.AST_NODE_TYPES.JSXOpeningFragment:
293
+ case AST_NODE_TYPES.JSXOpeningFragment:
310
294
  return "<>";
311
- case types.AST_NODE_TYPES.JSXClosingFragment:
295
+ case AST_NODE_TYPES.JSXClosingFragment:
312
296
  return "</>";
313
297
  }
314
298
  }
@@ -321,21 +305,21 @@ function getAttributeName(context, node) {
321
305
  // src/jsx/jsx-attribute.ts
322
306
  function getAttribute(context, name, attributes, initialScope) {
323
307
  return attributes.findLast((attr) => {
324
- if (attr.type === types.AST_NODE_TYPES.JSXAttribute) {
308
+ if (attr.type === AST_NODE_TYPES.JSXAttribute) {
325
309
  return getAttributeName(context, attr) === name;
326
310
  }
327
311
  if (initialScope == null) return false;
328
312
  switch (attr.argument.type) {
329
- case types.AST_NODE_TYPES.Identifier: {
330
- const variable = VAR3__namespace.findVariable(attr.argument.name, initialScope);
331
- const variableNode = VAR3__namespace.getVariableInitNode(variable, 0);
332
- if (variableNode?.type === types.AST_NODE_TYPES.ObjectExpression) {
333
- return VAR3__namespace.findPropertyInProperties(name, variableNode.properties, initialScope) != null;
313
+ case AST_NODE_TYPES.Identifier: {
314
+ const variable = VAR3.findVariable(attr.argument.name, initialScope);
315
+ const variableNode = VAR3.getVariableInitNode(variable, 0);
316
+ if (variableNode?.type === AST_NODE_TYPES.ObjectExpression) {
317
+ return VAR3.findPropertyInProperties(name, variableNode.properties, initialScope) != null;
334
318
  }
335
319
  return false;
336
320
  }
337
- case types.AST_NODE_TYPES.ObjectExpression:
338
- return VAR3__namespace.findPropertyInProperties(name, attr.argument.properties, initialScope) != null;
321
+ case AST_NODE_TYPES.ObjectExpression:
322
+ return VAR3.findPropertyInProperties(name, attr.argument.properties, initialScope) != null;
339
323
  }
340
324
  return false;
341
325
  });
@@ -343,8 +327,8 @@ function getAttribute(context, name, attributes, initialScope) {
343
327
  function getAttributeValue(context, node, name) {
344
328
  const initialScope = context.sourceCode.getScope(node);
345
329
  switch (node.type) {
346
- case types.AST_NODE_TYPES.JSXAttribute:
347
- if (node.value?.type === types.AST_NODE_TYPES.Literal) {
330
+ case AST_NODE_TYPES.JSXAttribute:
331
+ if (node.value?.type === AST_NODE_TYPES.Literal) {
348
332
  return {
349
333
  kind: "some",
350
334
  node: node.value,
@@ -352,16 +336,16 @@ function getAttributeValue(context, node, name) {
352
336
  value: node.value.value
353
337
  };
354
338
  }
355
- if (node.value?.type === types.AST_NODE_TYPES.JSXExpressionContainer) {
356
- return VAR3__namespace.toStaticValue({
339
+ if (node.value?.type === AST_NODE_TYPES.JSXExpressionContainer) {
340
+ return VAR3.toStaticValue({
357
341
  kind: "lazy",
358
342
  node: node.value.expression,
359
343
  initialScope
360
344
  });
361
345
  }
362
346
  return { kind: "none", node, initialScope };
363
- case types.AST_NODE_TYPES.JSXSpreadAttribute: {
364
- const staticValue = VAR3__namespace.toStaticValue({
347
+ case AST_NODE_TYPES.JSXSpreadAttribute: {
348
+ const staticValue = VAR3.toStaticValue({
365
349
  kind: "lazy",
366
350
  node: node.argument,
367
351
  initialScope
@@ -369,7 +353,7 @@ function getAttributeValue(context, node, name) {
369
353
  if (staticValue.kind === "none") {
370
354
  return staticValue;
371
355
  }
372
- return tsPattern.match(staticValue.value).with({ [name]: tsPattern.P.select(tsPattern.P.any) }, (value) => ({
356
+ return match(staticValue.value).with({ [name]: P.select(P.any) }, (value) => ({
373
357
  kind: "some",
374
358
  node: node.argument,
375
359
  initialScope,
@@ -401,13 +385,13 @@ var DEFAULT_JSX_DETECTION_HINT = 0n | JSXDetectionHint.SkipUndefined | JSXDetect
401
385
  // src/jsx/jsx-detection.ts
402
386
  function isJsxText(node) {
403
387
  if (node == null) return false;
404
- return node.type === types.AST_NODE_TYPES.JSXText || node.type === types.AST_NODE_TYPES.Literal;
388
+ return node.type === AST_NODE_TYPES.JSXText || node.type === AST_NODE_TYPES.Literal;
405
389
  }
406
390
  function isJsxLike(code, node, hint = DEFAULT_JSX_DETECTION_HINT) {
407
391
  if (node == null) return false;
408
- if (AST14__namespace.isJSX(node)) return true;
392
+ if (AST14.isJSX(node)) return true;
409
393
  switch (node.type) {
410
- case types.AST_NODE_TYPES.Literal: {
394
+ case AST_NODE_TYPES.Literal: {
411
395
  switch (typeof node.value) {
412
396
  case "boolean":
413
397
  return !(hint & JSXDetectionHint.SkipBooleanLiteral);
@@ -423,22 +407,22 @@ function isJsxLike(code, node, hint = DEFAULT_JSX_DETECTION_HINT) {
423
407
  }
424
408
  return false;
425
409
  }
426
- case types.AST_NODE_TYPES.TemplateLiteral: {
410
+ case AST_NODE_TYPES.TemplateLiteral: {
427
411
  return !(hint & JSXDetectionHint.SkipStringLiteral);
428
412
  }
429
- case types.AST_NODE_TYPES.ArrayExpression: {
413
+ case AST_NODE_TYPES.ArrayExpression: {
430
414
  if (hint & JSXDetectionHint.StrictArray) {
431
415
  return node.elements.every((n) => isJsxLike(code, n, hint));
432
416
  }
433
417
  return node.elements.some((n) => isJsxLike(code, n, hint));
434
418
  }
435
- case types.AST_NODE_TYPES.LogicalExpression: {
419
+ case AST_NODE_TYPES.LogicalExpression: {
436
420
  if (hint & JSXDetectionHint.StrictLogical) {
437
421
  return isJsxLike(code, node.left, hint) && isJsxLike(code, node.right, hint);
438
422
  }
439
423
  return isJsxLike(code, node.left, hint) || isJsxLike(code, node.right, hint);
440
424
  }
441
- case types.AST_NODE_TYPES.ConditionalExpression: {
425
+ case AST_NODE_TYPES.ConditionalExpression: {
442
426
  let leftHasJSX2 = function(node2) {
443
427
  if (Array.isArray(node2.consequent)) {
444
428
  if (node2.consequent.length === 0) {
@@ -458,39 +442,39 @@ function isJsxLike(code, node, hint = DEFAULT_JSX_DETECTION_HINT) {
458
442
  }
459
443
  return leftHasJSX2(node) || rightHasJSX2(node);
460
444
  }
461
- case types.AST_NODE_TYPES.SequenceExpression: {
445
+ case AST_NODE_TYPES.SequenceExpression: {
462
446
  const exp = node.expressions.at(-1);
463
447
  return isJsxLike(code, exp, hint);
464
448
  }
465
- case types.AST_NODE_TYPES.CallExpression: {
449
+ case AST_NODE_TYPES.CallExpression: {
466
450
  if (hint & JSXDetectionHint.SkipCreateElement) {
467
451
  return false;
468
452
  }
469
453
  switch (node.callee.type) {
470
- case types.AST_NODE_TYPES.Identifier:
454
+ case AST_NODE_TYPES.Identifier:
471
455
  return node.callee.name === "createElement";
472
- case types.AST_NODE_TYPES.MemberExpression:
473
- return node.callee.property.type === types.AST_NODE_TYPES.Identifier && node.callee.property.name === "createElement";
456
+ case AST_NODE_TYPES.MemberExpression:
457
+ return node.callee.property.type === AST_NODE_TYPES.Identifier && node.callee.property.name === "createElement";
474
458
  }
475
459
  return false;
476
460
  }
477
- case types.AST_NODE_TYPES.Identifier: {
461
+ case AST_NODE_TYPES.Identifier: {
478
462
  const { name } = node;
479
463
  if (name === "undefined") {
480
464
  return !(hint & JSXDetectionHint.SkipUndefined);
481
465
  }
482
- if (AST14__namespace.isJSXTagNameExpression(node)) {
466
+ if (AST14.isJSXTagNameExpression(node)) {
483
467
  return true;
484
468
  }
485
- const variable = VAR3__namespace.findVariable(name, code.getScope(node));
486
- const variableNode = variable && VAR3__namespace.getVariableInitNode(variable, 0);
469
+ const variable = VAR3.findVariable(name, code.getScope(node));
470
+ const variableNode = variable && VAR3.getVariableInitNode(variable, 0);
487
471
  return !!variableNode && isJsxLike(code, variableNode, hint);
488
472
  }
489
473
  }
490
474
  return false;
491
475
  }
492
476
  function getElementType(context, node) {
493
- if (node.type === types.AST_NODE_TYPES.JSXFragment) {
477
+ if (node.type === AST_NODE_TYPES.JSXFragment) {
494
478
  return "";
495
479
  }
496
480
  return stringifyJsx(node.openingElement.name);
@@ -506,22 +490,22 @@ function hasAnyAttribute(context, names, attributes, initialScope) {
506
490
  function hasEveryAttribute(context, names, attributes, initialScope) {
507
491
  return names.every((n) => hasAttribute(context, n, attributes, initialScope));
508
492
  }
509
- function findParentAttribute(node, test = eff.constTrue) {
493
+ function findParentAttribute(node, test = constTrue) {
510
494
  const guard = (node2) => {
511
- return node2.type === types.AST_NODE_TYPES.JSXAttribute && test(node2);
495
+ return node2.type === AST_NODE_TYPES.JSXAttribute && test(node2);
512
496
  };
513
- return AST14__namespace.findParentNode(node, guard);
497
+ return AST14.findParentNode(node, guard);
514
498
  }
515
499
  function isHostElement(context, node) {
516
- return node.type === types.AST_NODE_TYPES.JSXElement && node.openingElement.name.type === types.AST_NODE_TYPES.JSXIdentifier && /^[a-z]/u.test(node.openingElement.name.name);
500
+ return node.type === AST_NODE_TYPES.JSXElement && node.openingElement.name.type === AST_NODE_TYPES.JSXIdentifier && /^[a-z]/u.test(node.openingElement.name.name);
517
501
  }
518
502
  function isKeyedElement(context, node, initialScope) {
519
- return node.type === types.AST_NODE_TYPES.JSXElement && hasAttribute(context, "key", node.openingElement.attributes, initialScope);
503
+ return node.type === AST_NODE_TYPES.JSXElement && hasAttribute(context, "key", node.openingElement.attributes, initialScope);
520
504
  }
521
505
  function isFragmentElement(context, node, allowJSXFragment = false) {
522
506
  if (node == null) return false;
523
- if (node.type !== types.AST_NODE_TYPES.JSXElement && node.type !== types.AST_NODE_TYPES.JSXFragment) return false;
524
- if (node.type === types.AST_NODE_TYPES.JSXFragment) return allowJSXFragment;
507
+ if (node.type !== AST_NODE_TYPES.JSXElement && node.type !== AST_NODE_TYPES.JSXFragment) return false;
508
+ if (node.type === AST_NODE_TYPES.JSXFragment) return allowJSXFragment;
525
509
  return getElementType(context, node).split(".").at(-1) === "Fragment";
526
510
  }
527
511
 
@@ -561,9 +545,9 @@ function isClassComponent(node) {
561
545
  if ("superClass" in node && node.superClass != null) {
562
546
  const re = /^(?:Pure)?Component$/u;
563
547
  switch (true) {
564
- case node.superClass.type === types.AST_NODE_TYPES.Identifier:
548
+ case node.superClass.type === AST_NODE_TYPES.Identifier:
565
549
  return re.test(node.superClass.name);
566
- case (node.superClass.type === types.AST_NODE_TYPES.MemberExpression && node.superClass.property.type === types.AST_NODE_TYPES.Identifier):
550
+ case (node.superClass.type === AST_NODE_TYPES.MemberExpression && node.superClass.property.type === AST_NODE_TYPES.Identifier):
567
551
  return re.test(node.superClass.property.name);
568
552
  }
569
553
  }
@@ -573,33 +557,33 @@ function isPureComponent(node) {
573
557
  if ("superClass" in node && node.superClass != null) {
574
558
  const re = /^PureComponent$/u;
575
559
  switch (true) {
576
- case node.superClass.type === types.AST_NODE_TYPES.Identifier:
560
+ case node.superClass.type === AST_NODE_TYPES.Identifier:
577
561
  return re.test(node.superClass.name);
578
- case (node.superClass.type === types.AST_NODE_TYPES.MemberExpression && node.superClass.property.type === types.AST_NODE_TYPES.Identifier):
562
+ case (node.superClass.type === AST_NODE_TYPES.MemberExpression && node.superClass.property.type === AST_NODE_TYPES.Identifier):
579
563
  return re.test(node.superClass.property.name);
580
564
  }
581
565
  }
582
566
  return false;
583
567
  }
584
568
  function isRenderMethodLike(node) {
585
- return AST14__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name.startsWith("render") && node.parent.parent.type === types.AST_NODE_TYPES.ClassDeclaration;
569
+ return AST14.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name.startsWith("render") && node.parent.parent.type === AST_NODE_TYPES.ClassDeclaration;
586
570
  }
587
571
 
588
572
  // src/component/component-definition.ts
589
- var isFunctionOfClassMethod = tsPattern.isMatching({
590
- type: tsPattern.P.union(types.AST_NODE_TYPES.ArrowFunctionExpression, types.AST_NODE_TYPES.FunctionExpression),
591
- parent: types.AST_NODE_TYPES.MethodDefinition
573
+ var isFunctionOfClassMethod = isMatching({
574
+ type: P.union(AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression),
575
+ parent: AST_NODE_TYPES.MethodDefinition
592
576
  });
593
- var isFunctionOfClassProperty = tsPattern.isMatching({
594
- type: tsPattern.P.union(types.AST_NODE_TYPES.ArrowFunctionExpression, types.AST_NODE_TYPES.FunctionExpression),
595
- parent: types.AST_NODE_TYPES.Property
577
+ var isFunctionOfClassProperty = isMatching({
578
+ type: P.union(AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression),
579
+ parent: AST_NODE_TYPES.Property
596
580
  });
597
- var isFunctionOfObjectMethod = tsPattern.isMatching({
598
- type: tsPattern.P.union(types.AST_NODE_TYPES.ArrowFunctionExpression, types.AST_NODE_TYPES.FunctionExpression),
581
+ var isFunctionOfObjectMethod = isMatching({
582
+ type: P.union(AST_NODE_TYPES.ArrowFunctionExpression, AST_NODE_TYPES.FunctionExpression),
599
583
  parent: {
600
- type: types.AST_NODE_TYPES.Property,
584
+ type: AST_NODE_TYPES.Property,
601
585
  parent: {
602
- type: types.AST_NODE_TYPES.ObjectExpression
586
+ type: AST_NODE_TYPES.ObjectExpression
603
587
  }
604
588
  }
605
589
  });
@@ -622,44 +606,44 @@ function isValidComponentDefinition(context, node, hint) {
622
606
  if (hint & ComponentDetectionHint.SkipClassProperty && isFunctionOfClassProperty(node.parent)) {
623
607
  return false;
624
608
  }
625
- if (hint & ComponentDetectionHint.SkipArrayMapArgument && AST14__namespace.isArrayMapCall(node.parent)) {
609
+ if (hint & ComponentDetectionHint.SkipArrayMapArgument && AST14.isArrayMapCall(node.parent)) {
626
610
  return false;
627
611
  }
628
- const significantParent = AST14__namespace.findParentNode(
612
+ const significantParent = AST14.findParentNode(
629
613
  node,
630
- AST14__namespace.isOneOf([
631
- types.AST_NODE_TYPES.JSXExpressionContainer,
632
- types.AST_NODE_TYPES.ArrowFunctionExpression,
633
- types.AST_NODE_TYPES.FunctionExpression,
634
- types.AST_NODE_TYPES.Property,
635
- types.AST_NODE_TYPES.ClassBody
614
+ AST14.isOneOf([
615
+ AST_NODE_TYPES.JSXExpressionContainer,
616
+ AST_NODE_TYPES.ArrowFunctionExpression,
617
+ AST_NODE_TYPES.FunctionExpression,
618
+ AST_NODE_TYPES.Property,
619
+ AST_NODE_TYPES.ClassBody
636
620
  ])
637
621
  );
638
- return significantParent == null || significantParent.type !== types.AST_NODE_TYPES.JSXExpressionContainer;
622
+ return significantParent == null || significantParent.type !== AST_NODE_TYPES.JSXExpressionContainer;
639
623
  }
640
624
  function isComponentWrapperCall(context, node) {
641
- if (node.type !== types.AST_NODE_TYPES.CallExpression) return false;
625
+ if (node.type !== AST_NODE_TYPES.CallExpression) return false;
642
626
  return isMemoCall(context, node) || isForwardRefCall(context, node);
643
627
  }
644
628
  function isComponentWrapperCallLoose(context, node) {
645
- if (node.type !== types.AST_NODE_TYPES.CallExpression) return false;
629
+ if (node.type !== AST_NODE_TYPES.CallExpression) return false;
646
630
  return isComponentWrapperCall(context, node) || isUseCallbackCall(context, node);
647
631
  }
648
632
 
649
633
  // src/component/component-id.ts
650
634
  function getFunctionComponentId(context, node) {
651
- const functionId = AST14__namespace.getFunctionId(node);
635
+ const functionId = AST14.getFunctionId(node);
652
636
  if (functionId != null) {
653
637
  return functionId;
654
638
  }
655
639
  const { parent } = node;
656
- if (parent.type === types.AST_NODE_TYPES.CallExpression && isComponentWrapperCallLoose(context, parent) && parent.parent.type === types.AST_NODE_TYPES.VariableDeclarator && parent.parent.id.type === types.AST_NODE_TYPES.Identifier) {
640
+ if (parent.type === AST_NODE_TYPES.CallExpression && isComponentWrapperCallLoose(context, parent) && parent.parent.type === AST_NODE_TYPES.VariableDeclarator && parent.parent.id.type === AST_NODE_TYPES.Identifier) {
657
641
  return parent.parent.id;
658
642
  }
659
- if (parent.type === types.AST_NODE_TYPES.CallExpression && isComponentWrapperCallLoose(context, parent) && parent.parent.type === types.AST_NODE_TYPES.CallExpression && isComponentWrapperCallLoose(context, parent.parent) && parent.parent.parent.type === types.AST_NODE_TYPES.VariableDeclarator && parent.parent.parent.id.type === types.AST_NODE_TYPES.Identifier) {
643
+ if (parent.type === AST_NODE_TYPES.CallExpression && isComponentWrapperCallLoose(context, parent) && parent.parent.type === AST_NODE_TYPES.CallExpression && isComponentWrapperCallLoose(context, parent.parent) && parent.parent.parent.type === AST_NODE_TYPES.VariableDeclarator && parent.parent.parent.id.type === AST_NODE_TYPES.Identifier) {
660
644
  return parent.parent.parent.id;
661
645
  }
662
- return eff._;
646
+ return _;
663
647
  }
664
648
 
665
649
  // src/component/component-flag.ts
@@ -675,22 +659,22 @@ var ComponentFlag = {
675
659
  // src/component/component-init-path.ts
676
660
  function getComponentFlagFromInitPath(initPath) {
677
661
  let flag = ComponentFlag.None;
678
- if (initPath != null && AST14__namespace.hasCallInFunctionInitPath("memo", initPath)) {
662
+ if (initPath != null && AST14.hasCallInFunctionInitPath("memo", initPath)) {
679
663
  flag |= ComponentFlag.Memo;
680
664
  }
681
- if (initPath != null && AST14__namespace.hasCallInFunctionInitPath("forwardRef", initPath)) {
665
+ if (initPath != null && AST14.hasCallInFunctionInitPath("forwardRef", initPath)) {
682
666
  flag |= ComponentFlag.ForwardRef;
683
667
  }
684
668
  return flag;
685
669
  }
686
670
  function isComponentName(name) {
687
- return kit.RegExp.COMPONENT_NAME.test(name);
671
+ return RegExp.COMPONENT_NAME.test(name);
688
672
  }
689
673
  function isComponentNameLoose(name) {
690
- return kit.RegExp.COMPONENT_NAME_LOOSE.test(name);
674
+ return RegExp.COMPONENT_NAME_LOOSE.test(name);
691
675
  }
692
676
  function getComponentNameFromId(id) {
693
- if (id == null) return eff._;
677
+ if (id == null) return _;
694
678
  return Array.isArray(id) ? id.map((n) => n.name).join(".") : id.name;
695
679
  }
696
680
  function hasNoneOrLooseComponentName(context, fn) {
@@ -711,14 +695,14 @@ function useComponentCollector(context, options = {}) {
711
695
  const functionEntries = [];
712
696
  const getCurrentEntry = () => functionEntries.at(-1);
713
697
  const onFunctionEnter = (node) => {
714
- const key = shared.getId();
698
+ const key = getId();
715
699
  functionEntries.push({ key, node, hookCalls: [], isComponent: false });
716
700
  };
717
701
  const onFunctionExit = () => {
718
702
  const entry = functionEntries.at(-1);
719
703
  if (entry == null) return;
720
704
  if (!entry.isComponent) return functionEntries.pop();
721
- const shouldDrop = AST14__namespace.getNestedReturnStatements(entry.node.body).slice().reverse().some((r) => {
705
+ const shouldDrop = AST14.getNestedReturnStatements(entry.node.body).slice().reverse().some((r) => {
722
706
  return context.sourceCode.getScope(r).block === entry.node && r.argument != null && !isJsxLike(context.sourceCode, r.argument, hint);
723
707
  });
724
708
  if (shouldDrop) {
@@ -745,17 +729,17 @@ function useComponentCollector(context, options = {}) {
745
729
  const { body } = entry.node;
746
730
  const isComponent = hasNoneOrLooseComponentName(context, entry.node) && isJsxLike(context.sourceCode, body, hint) && isValidComponentDefinition(context, entry.node, hint);
747
731
  if (!isComponent) return;
748
- const initPath = AST14__namespace.getFunctionInitPath(entry.node);
732
+ const initPath = AST14.getFunctionInitPath(entry.node);
749
733
  const id = getFunctionComponentId(context, entry.node);
750
734
  const name = getComponentNameFromId(id);
751
- const key = shared.getId();
735
+ const key = getId();
752
736
  components.set(key, {
753
737
  id,
754
738
  key,
755
739
  kind: "function",
756
740
  name,
757
741
  node: entry.node,
758
- displayName: eff._,
742
+ displayName: _,
759
743
  flag: getComponentFlagFromInitPath(initPath),
760
744
  hint,
761
745
  hookCalls: entry.hookCalls,
@@ -763,10 +747,10 @@ function useComponentCollector(context, options = {}) {
763
747
  });
764
748
  },
765
749
  ...collectDisplayName ? {
766
- [kit.Selector.DISPLAY_NAME_ASSIGNMENT_EXPRESSION](node) {
750
+ [Selector.DISPLAY_NAME_ASSIGNMENT_EXPRESSION](node) {
767
751
  const { left, right } = node;
768
- if (left.type !== types.AST_NODE_TYPES.MemberExpression) return;
769
- const componentName = left.object.type === types.AST_NODE_TYPES.Identifier ? left.object.name : eff._;
752
+ if (left.type !== AST_NODE_TYPES.MemberExpression) return;
753
+ const componentName = left.object.type === AST_NODE_TYPES.Identifier ? left.object.name : _;
770
754
  const component = [...components.values()].findLast(({ name }) => name != null && name === componentName);
771
755
  if (component == null) return;
772
756
  component.displayName = right;
@@ -786,7 +770,7 @@ function useComponentCollector(context, options = {}) {
786
770
  const isComponent = hasNoneOrLooseComponentName(context, entry.node) && isJsxLike(context.sourceCode, node.argument, hint) && isValidComponentDefinition(context, entry.node, hint);
787
771
  if (!isComponent) return;
788
772
  entry.isComponent = true;
789
- const initPath = AST14__namespace.getFunctionInitPath(entry.node);
773
+ const initPath = AST14.getFunctionInitPath(entry.node);
790
774
  const id = getFunctionComponentId(context, entry.node);
791
775
  const name = getComponentNameFromId(id);
792
776
  components.set(entry.key, {
@@ -795,7 +779,7 @@ function useComponentCollector(context, options = {}) {
795
779
  kind: "function",
796
780
  name,
797
781
  node: entry.node,
798
- displayName: eff._,
782
+ displayName: _,
799
783
  flag: getComponentFlagFromInitPath(initPath),
800
784
  hint,
801
785
  hookCalls: entry.hookCalls,
@@ -817,8 +801,8 @@ function useComponentCollectorLegacy() {
817
801
  if (!isClassComponent(node)) {
818
802
  return;
819
803
  }
820
- const id = AST14__namespace.getClassId(node);
821
- const key = shared.getId();
804
+ const id = AST14.getClassId(node);
805
+ const key = getId();
822
806
  const flag = isPureComponent(node) ? ComponentFlag.PureComponent : ComponentFlag.None;
823
807
  components.set(
824
808
  key,
@@ -829,7 +813,7 @@ function useComponentCollectorLegacy() {
829
813
  name: id?.name,
830
814
  node,
831
815
  // TODO: Get displayName of class component
832
- displayName: eff._,
816
+ displayName: _,
833
817
  flag,
834
818
  hint: 0n,
835
819
  // TODO: Get methods of class component
@@ -844,63 +828,63 @@ function useComponentCollectorLegacy() {
844
828
  return { ctx, listeners };
845
829
  }
846
830
  function isComponentDidCatch(node) {
847
- return AST14__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidCatch";
831
+ return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidCatch";
848
832
  }
849
833
  function isComponentDidMount(node) {
850
- return AST14__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
834
+ return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
851
835
  }
852
836
  function isComponentDidUpdate(node) {
853
- return AST14__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidUpdate";
837
+ return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidUpdate";
854
838
  }
855
839
  function isComponentWillMount(node) {
856
- return AST14__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillMount";
840
+ return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillMount";
857
841
  }
858
842
  function isComponentWillReceiveProps(node) {
859
- return AST14__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillReceiveProps";
843
+ return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillReceiveProps";
860
844
  }
861
845
  function isComponentWillUnmount(node) {
862
- return AST14__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillUnmount";
846
+ return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillUnmount";
863
847
  }
864
848
  function isComponentWillUpdate(node) {
865
- return AST14__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillUpdate";
849
+ return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillUpdate";
866
850
  }
867
851
  function isGetChildContext(node) {
868
- return AST14__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getChildContext";
852
+ return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getChildContext";
869
853
  }
870
854
  function isGetDefaultProps(node) {
871
- return AST14__namespace.isMethodOrProperty(node) && node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getDefaultProps";
855
+ return AST14.isMethodOrProperty(node) && node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getDefaultProps";
872
856
  }
873
857
  function isGetInitialState(node) {
874
- return AST14__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getInitialState";
858
+ return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getInitialState";
875
859
  }
876
860
  function isGetSnapshotBeforeUpdate(node) {
877
- return AST14__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getSnapshotBeforeUpdate";
861
+ return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getSnapshotBeforeUpdate";
878
862
  }
879
863
  function isShouldComponentUpdate(node) {
880
- return AST14__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
864
+ return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "shouldComponentUpdate";
881
865
  }
882
866
  function isUnsafeComponentWillMount(node) {
883
- return AST14__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillMount";
867
+ return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillMount";
884
868
  }
885
869
  function isUnsafeComponentWillReceiveProps(node) {
886
- return AST14__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillReceiveProps";
870
+ return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillReceiveProps";
887
871
  }
888
872
  function isUnsafeComponentWillUpdate(node) {
889
- return AST14__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillUpdate";
873
+ return AST14.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "UNSAFE_componentWillUpdate";
890
874
  }
891
875
  function isGetDerivedStateFromProps(node) {
892
- return AST14__namespace.isMethodOrProperty(node) && node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromProps";
876
+ return AST14.isMethodOrProperty(node) && node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromProps";
893
877
  }
894
878
  function isGetDerivedStateFromError(node) {
895
- return AST14__namespace.isMethodOrProperty(node) && node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromError";
879
+ return AST14.isMethodOrProperty(node) && node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromError";
896
880
  }
897
- var ComponentPhaseRelevance = birecord__default.default({
881
+ var ComponentPhaseRelevance = birecord({
898
882
  mount: "unmount",
899
883
  setup: "cleanup"
900
884
  });
901
- var isInversePhase = eff.dual(2, (a, b) => ComponentPhaseRelevance.get(a) === b);
885
+ var isInversePhase = dual(2, (a, b) => ComponentPhaseRelevance.get(a) === b);
902
886
  function isRenderLike(node) {
903
- return AST14__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "render" && node.parent.parent.type === types.AST_NODE_TYPES.ClassDeclaration;
887
+ return AST14.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "render" && node.parent.parent.type === AST_NODE_TYPES.ClassDeclaration;
904
888
  }
905
889
  function isFunctionOfRender(node) {
906
890
  if (!isRenderLike(node.parent)) {
@@ -910,8 +894,8 @@ function isFunctionOfRender(node) {
910
894
  }
911
895
  function isRenderFunctionLoose(context, node) {
912
896
  const { body, parent } = node;
913
- if (AST14__namespace.getFunctionId(node)?.name.startsWith("render")) {
914
- return parent.type === types.AST_NODE_TYPES.JSXExpressionContainer && parent.parent.type === types.AST_NODE_TYPES.JSXAttribute && parent.parent.name.type === types.AST_NODE_TYPES.JSXIdentifier && parent.parent.name.name.startsWith("render");
897
+ if (AST14.getFunctionId(node)?.name.startsWith("render")) {
898
+ return parent.type === AST_NODE_TYPES.JSXExpressionContainer && parent.parent.type === AST_NODE_TYPES.JSXAttribute && parent.parent.name.type === AST_NODE_TYPES.JSXIdentifier && parent.parent.name.name.startsWith("render");
915
899
  }
916
900
  return isJsxLike(
917
901
  context.sourceCode,
@@ -920,14 +904,14 @@ function isRenderFunctionLoose(context, node) {
920
904
  );
921
905
  }
922
906
  function isRenderPropLoose(context, node) {
923
- if (node.name.type !== types.AST_NODE_TYPES.JSXIdentifier) {
907
+ if (node.name.type !== AST_NODE_TYPES.JSXIdentifier) {
924
908
  return false;
925
909
  }
926
- return node.name.name.startsWith("render") && node.value?.type === types.AST_NODE_TYPES.JSXExpressionContainer && AST14__namespace.isFunction(node.value.expression) && isRenderFunctionLoose(context, node.value.expression);
910
+ return node.name.name.startsWith("render") && node.value?.type === AST_NODE_TYPES.JSXExpressionContainer && AST14.isFunction(node.value.expression) && isRenderFunctionLoose(context, node.value.expression);
927
911
  }
928
912
  function isDirectValueOfRenderPropertyLoose(node) {
929
913
  const matching = (node2) => {
930
- return node2.type === types.AST_NODE_TYPES.Property && node2.key.type === types.AST_NODE_TYPES.Identifier && node2.key.name.startsWith("render");
914
+ return node2.type === AST_NODE_TYPES.Property && node2.key.type === AST_NODE_TYPES.Identifier && node2.key.name.startsWith("render");
931
915
  };
932
916
  return matching(node) || node.parent != null && matching(node.parent);
933
917
  }
@@ -935,138 +919,19 @@ function isDeclaredInRenderPropLoose(node) {
935
919
  if (isDirectValueOfRenderPropertyLoose(node)) {
936
920
  return true;
937
921
  }
938
- const parent = AST14__namespace.findParentNode(node, AST14__namespace.is(types.AST_NODE_TYPES.JSXExpressionContainer))?.parent;
939
- if (parent?.type !== types.AST_NODE_TYPES.JSXAttribute) {
922
+ const parent = AST14.findParentNode(node, AST14.is(AST_NODE_TYPES.JSXExpressionContainer))?.parent;
923
+ if (parent?.type !== AST_NODE_TYPES.JSXAttribute) {
940
924
  return false;
941
925
  }
942
- return parent.name.type === types.AST_NODE_TYPES.JSXIdentifier && parent.name.name.startsWith("render");
926
+ return parent.name.type === AST_NODE_TYPES.JSXIdentifier && parent.name.name.startsWith("render");
943
927
  }
944
928
  function isThisSetState(node) {
945
929
  const { callee } = node;
946
- return callee.type === types.AST_NODE_TYPES.MemberExpression && AST14__namespace.isThisExpression(callee.object) && callee.property.type === types.AST_NODE_TYPES.Identifier && callee.property.name === "setState";
930
+ return callee.type === AST_NODE_TYPES.MemberExpression && AST14.isThisExpression(callee.object) && callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "setState";
947
931
  }
948
932
  function isAssignmentToThisState(node) {
949
933
  const { left } = node;
950
- return left.type === types.AST_NODE_TYPES.MemberExpression && AST14__namespace.isThisExpression(left.object) && AST14__namespace.getPropertyName(left.property) === "state";
934
+ return left.type === AST_NODE_TYPES.MemberExpression && AST14.isThisExpression(left.object) && AST14.getPropertyName(left.property) === "state";
951
935
  }
952
936
 
953
- exports.ComponentDetectionHint = ComponentDetectionHint;
954
- exports.ComponentFlag = ComponentFlag;
955
- exports.ComponentPhaseRelevance = ComponentPhaseRelevance;
956
- exports.DEFAULT_COMPONENT_DETECTION_HINT = DEFAULT_COMPONENT_DETECTION_HINT;
957
- exports.DEFAULT_JSX_DETECTION_HINT = DEFAULT_JSX_DETECTION_HINT;
958
- exports.JSXDetectionHint = JSXDetectionHint;
959
- exports.findParentAttribute = findParentAttribute;
960
- exports.getAttribute = getAttribute;
961
- exports.getAttributeName = getAttributeName;
962
- exports.getAttributeValue = getAttributeValue;
963
- exports.getComponentFlagFromInitPath = getComponentFlagFromInitPath;
964
- exports.getComponentNameFromId = getComponentNameFromId;
965
- exports.getElementType = getElementType;
966
- exports.getFunctionComponentId = getFunctionComponentId;
967
- exports.getInstanceId = getInstanceId;
968
- exports.hasAnyAttribute = hasAnyAttribute;
969
- exports.hasAttribute = hasAttribute;
970
- exports.hasEveryAttribute = hasEveryAttribute;
971
- exports.hasNoneOrLooseComponentName = hasNoneOrLooseComponentName;
972
- exports.isAssignmentToThisState = isAssignmentToThisState;
973
- exports.isCaptureOwnerStack = isCaptureOwnerStack;
974
- exports.isCaptureOwnerStackCall = isCaptureOwnerStackCall;
975
- exports.isChildrenCount = isChildrenCount;
976
- exports.isChildrenCountCall = isChildrenCountCall;
977
- exports.isChildrenForEach = isChildrenForEach;
978
- exports.isChildrenForEachCall = isChildrenForEachCall;
979
- exports.isChildrenMap = isChildrenMap;
980
- exports.isChildrenMapCall = isChildrenMapCall;
981
- exports.isChildrenOfCreateElement = isChildrenOfCreateElement;
982
- exports.isChildrenOnly = isChildrenOnly;
983
- exports.isChildrenOnlyCall = isChildrenOnlyCall;
984
- exports.isChildrenToArray = isChildrenToArray;
985
- exports.isChildrenToArrayCall = isChildrenToArrayCall;
986
- exports.isClassComponent = isClassComponent;
987
- exports.isCloneElement = isCloneElement;
988
- exports.isCloneElementCall = isCloneElementCall;
989
- exports.isComponentDidCatch = isComponentDidCatch;
990
- exports.isComponentDidMount = isComponentDidMount;
991
- exports.isComponentDidUpdate = isComponentDidUpdate;
992
- exports.isComponentName = isComponentName;
993
- exports.isComponentNameLoose = isComponentNameLoose;
994
- exports.isComponentWillMount = isComponentWillMount;
995
- exports.isComponentWillReceiveProps = isComponentWillReceiveProps;
996
- exports.isComponentWillUnmount = isComponentWillUnmount;
997
- exports.isComponentWillUpdate = isComponentWillUpdate;
998
- exports.isComponentWrapperCall = isComponentWrapperCall;
999
- exports.isComponentWrapperCallLoose = isComponentWrapperCallLoose;
1000
- exports.isCreateContext = isCreateContext;
1001
- exports.isCreateContextCall = isCreateContextCall;
1002
- exports.isCreateElement = isCreateElement;
1003
- exports.isCreateElementCall = isCreateElementCall;
1004
- exports.isCreateRef = isCreateRef;
1005
- exports.isCreateRefCall = isCreateRefCall;
1006
- exports.isDeclaredInRenderPropLoose = isDeclaredInRenderPropLoose;
1007
- exports.isDirectValueOfRenderPropertyLoose = isDirectValueOfRenderPropertyLoose;
1008
- exports.isForwardRef = isForwardRef;
1009
- exports.isForwardRefCall = isForwardRefCall;
1010
- exports.isFragmentElement = isFragmentElement;
1011
- exports.isFunctionOfRender = isFunctionOfRender;
1012
- exports.isFunctionOfRenderMethod = isFunctionOfRenderMethod;
1013
- exports.isGetChildContext = isGetChildContext;
1014
- exports.isGetDefaultProps = isGetDefaultProps;
1015
- exports.isGetDerivedStateFromError = isGetDerivedStateFromError;
1016
- exports.isGetDerivedStateFromProps = isGetDerivedStateFromProps;
1017
- exports.isGetInitialState = isGetInitialState;
1018
- exports.isGetSnapshotBeforeUpdate = isGetSnapshotBeforeUpdate;
1019
- exports.isHostElement = isHostElement;
1020
- exports.isInitializedFromReact = isInitializedFromReact;
1021
- exports.isInstanceIdEqual = isInstanceIdEqual;
1022
- exports.isInversePhase = isInversePhase;
1023
- exports.isJsxLike = isJsxLike;
1024
- exports.isJsxText = isJsxText;
1025
- exports.isKeyedElement = isKeyedElement;
1026
- exports.isLazy = isLazy;
1027
- exports.isLazyCall = isLazyCall;
1028
- exports.isMemo = isMemo;
1029
- exports.isMemoCall = isMemoCall;
1030
- exports.isPureComponent = isPureComponent;
1031
- exports.isReactAPI = isReactAPI;
1032
- exports.isReactAPICall = isReactAPICall;
1033
- exports.isReactHook = isReactHook;
1034
- exports.isReactHookCall = isReactHookCall;
1035
- exports.isReactHookCallWithName = isReactHookCallWithName;
1036
- exports.isReactHookCallWithNameAlias = isReactHookCallWithNameAlias;
1037
- exports.isReactHookCallWithNameLoose = isReactHookCallWithNameLoose;
1038
- exports.isReactHookName = isReactHookName;
1039
- exports.isRenderFunctionLoose = isRenderFunctionLoose;
1040
- exports.isRenderLike = isRenderLike;
1041
- exports.isRenderMethodLike = isRenderMethodLike;
1042
- exports.isRenderPropLoose = isRenderPropLoose;
1043
- exports.isShouldComponentUpdate = isShouldComponentUpdate;
1044
- exports.isThisSetState = isThisSetState;
1045
- exports.isUnsafeComponentWillMount = isUnsafeComponentWillMount;
1046
- exports.isUnsafeComponentWillReceiveProps = isUnsafeComponentWillReceiveProps;
1047
- exports.isUnsafeComponentWillUpdate = isUnsafeComponentWillUpdate;
1048
- exports.isUseActionStateCall = isUseActionStateCall;
1049
- exports.isUseCall = isUseCall;
1050
- exports.isUseCallbackCall = isUseCallbackCall;
1051
- exports.isUseContextCall = isUseContextCall;
1052
- exports.isUseDebugValueCall = isUseDebugValueCall;
1053
- exports.isUseDeferredValueCall = isUseDeferredValueCall;
1054
- exports.isUseEffectCall = isUseEffectCall;
1055
- exports.isUseEffectCallLoose = isUseEffectCallLoose;
1056
- exports.isUseFormStatusCall = isUseFormStatusCall;
1057
- exports.isUseIdCall = isUseIdCall;
1058
- exports.isUseImperativeHandleCall = isUseImperativeHandleCall;
1059
- exports.isUseInsertionEffectCall = isUseInsertionEffectCall;
1060
- exports.isUseLayoutEffectCall = isUseLayoutEffectCall;
1061
- exports.isUseMemoCall = isUseMemoCall;
1062
- exports.isUseOptimisticCall = isUseOptimisticCall;
1063
- exports.isUseReducerCall = isUseReducerCall;
1064
- exports.isUseRefCall = isUseRefCall;
1065
- exports.isUseStateCall = isUseStateCall;
1066
- exports.isUseSyncExternalStoreCall = isUseSyncExternalStoreCall;
1067
- exports.isUseTransitionCall = isUseTransitionCall;
1068
- exports.isValidComponentDefinition = isValidComponentDefinition;
1069
- exports.stringifyJsx = stringifyJsx;
1070
- exports.useComponentCollector = useComponentCollector;
1071
- exports.useComponentCollectorLegacy = useComponentCollectorLegacy;
1072
- exports.useHookCollector = useHookCollector;
937
+ export { ComponentDetectionHint, ComponentFlag, ComponentPhaseRelevance, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, JSXDetectionHint, findParentAttribute, getAttribute, getAttributeName, getAttributeValue, getComponentFlagFromInitPath, getComponentNameFromId, getElementType, getFunctionComponentId, getInstanceId, hasAnyAttribute, hasAttribute, hasEveryAttribute, hasNoneOrLooseComponentName, isAssignmentToThisState, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFragmentElement, isFunctionOfRender, isFunctionOfRenderMethod, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isHostElement, isInitializedFromReact, isInstanceIdEqual, isInversePhase, isJsxLike, isJsxText, isKeyedElement, isLazy, isLazyCall, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookId, isReactHookName, isRenderFunctionLoose, isRenderLike, isRenderMethodLike, isRenderPropLoose, isShouldComponentUpdate, isThisSetState, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, isValidComponentDefinition, stringifyJsx, useComponentCollector, useComponentCollectorLegacy, useHookCollector };