@eslint-react/core 1.26.3-next.8 → 1.27.0-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 CHANGED
@@ -24,11 +24,29 @@ type ERComponentHint = bigint;
24
24
  * hints for component collector
25
25
  */
26
26
  declare const ERComponentHint: {
27
+ /**
28
+ * Skip function component created by React.memo
29
+ */
27
30
  readonly SkipMemo: bigint;
31
+ /**
32
+ * Skip function component created by React.forwardRef
33
+ */
28
34
  readonly SkipForwardRef: bigint;
35
+ /**
36
+ * Skip function component defined in map function callback
37
+ */
29
38
  readonly SkipMapCallback: bigint;
39
+ /**
40
+ * Skip function component defined on object method
41
+ */
30
42
  readonly SkipObjectMethod: bigint;
43
+ /**
44
+ * Skip function component defined on class method
45
+ */
31
46
  readonly SkipClassMethod: bigint;
47
+ /**
48
+ * Skip function component defined on class property
49
+ */
32
50
  readonly SkipClassProperty: bigint;
33
51
  readonly None: 0n;
34
52
  readonly SkipUndefined: bigint;
@@ -51,8 +69,8 @@ declare const ERComponentFlag: {
51
69
  PureComponent: bigint;
52
70
  CreateElement: bigint;
53
71
  Memo: bigint;
54
- Async: bigint;
55
72
  ForwardRef: bigint;
73
+ Async: bigint;
56
74
  };
57
75
 
58
76
  interface ERFunctionComponent extends ERSemanticNode {
@@ -119,17 +137,6 @@ declare namespace useComponentCollectorLegacy {
119
137
  };
120
138
  }
121
139
 
122
- /**
123
- * The ESQuery selector for a component display name assignment expression
124
- */
125
- declare const COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR: string;
126
- /**
127
- * Check if the node is a component display name assignment expression
128
- * @param node The AST node
129
- * @returns `true` if the node is a component display name assignment
130
- */
131
- declare function isComponentDisplayNameAssignment(node: TSESTree.Node | _): node is TSESTree.AssignmentExpression;
132
-
133
140
  declare function getFunctionComponentIdentifier(node: AST.TSESTreeFunction, context: RuleContext): TSESTree.Identifier | TSESTree.Identifier[] | _;
134
141
 
135
142
  type ERComponentKind = "classComponent" | "functionComponent";
@@ -319,6 +326,17 @@ interface ERSemanticEntry {
319
326
  phase: ERPhaseKind;
320
327
  }
321
328
 
329
+ /**
330
+ * The ESQuery selector for a component display name assignment expression
331
+ */
332
+ declare const DISPLAY_NAME_ASSIGNMENT_SELECTOR: string;
333
+ /**
334
+ * Check if the node is a component display name assignment expression
335
+ * @param node The AST node
336
+ * @returns `true` if the node is a component display name assignment
337
+ */
338
+ declare function isDisplayNameAssignment(node: TSESTree.Node | _): node is TSESTree.AssignmentExpression;
339
+
322
340
  /**
323
341
  * Checks if the given node is a call expression to the given function or method of the pragma
324
342
  * @param name The name of the function or method to check
@@ -2368,7 +2386,7 @@ declare interface WithStatement extends BaseNode {
2368
2386
  }
2369
2387
  declare interface YieldExpression extends BaseNode {
2370
2388
  type: AST_NODE_TYPES.YieldExpression;
2371
- argument: Expression | undefined;
2389
+ argument: Expression | null;
2372
2390
  delegate: boolean;
2373
2391
  }
2374
2392
 
@@ -2399,4 +2417,4 @@ declare const isCreateRefCall: isCallFromReact.ReturnType;
2399
2417
  declare const isForwardRefCall: isCallFromReact.ReturnType;
2400
2418
  declare const isMemoCall: isCallFromReact.ReturnType;
2401
2419
 
2402
- export { COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR, DEFAULT_COMPONENT_HINT, type ERClassComponent, type ERComponent, ERComponentFlag, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectPhaseKind, type ERFunctionComponent, type ERHook, type ERHookKind, type ERLifecyclePhaseKind, type ERPhaseKind, ERPhaseRelevance, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDisplayNameAssignment, isComponentName, isComponentWillUnmount, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactMember, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
2420
+ export { DEFAULT_COMPONENT_HINT, DISPLAY_NAME_ASSIGNMENT_SELECTOR, type ERClassComponent, type ERComponent, ERComponentFlag, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectPhaseKind, type ERFunctionComponent, type ERHook, type ERHookKind, type ERLifecyclePhaseKind, type ERPhaseKind, ERPhaseRelevance, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentName, isComponentWillUnmount, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isDisplayNameAssignment, isForwardRef, isForwardRefCall, isFromReact, isFromReactMember, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
package/dist/index.d.ts CHANGED
@@ -24,11 +24,29 @@ type ERComponentHint = bigint;
24
24
  * hints for component collector
25
25
  */
26
26
  declare const ERComponentHint: {
27
+ /**
28
+ * Skip function component created by React.memo
29
+ */
27
30
  readonly SkipMemo: bigint;
31
+ /**
32
+ * Skip function component created by React.forwardRef
33
+ */
28
34
  readonly SkipForwardRef: bigint;
35
+ /**
36
+ * Skip function component defined in map function callback
37
+ */
29
38
  readonly SkipMapCallback: bigint;
39
+ /**
40
+ * Skip function component defined on object method
41
+ */
30
42
  readonly SkipObjectMethod: bigint;
43
+ /**
44
+ * Skip function component defined on class method
45
+ */
31
46
  readonly SkipClassMethod: bigint;
47
+ /**
48
+ * Skip function component defined on class property
49
+ */
32
50
  readonly SkipClassProperty: bigint;
33
51
  readonly None: 0n;
34
52
  readonly SkipUndefined: bigint;
@@ -51,8 +69,8 @@ declare const ERComponentFlag: {
51
69
  PureComponent: bigint;
52
70
  CreateElement: bigint;
53
71
  Memo: bigint;
54
- Async: bigint;
55
72
  ForwardRef: bigint;
73
+ Async: bigint;
56
74
  };
57
75
 
58
76
  interface ERFunctionComponent extends ERSemanticNode {
@@ -119,17 +137,6 @@ declare namespace useComponentCollectorLegacy {
119
137
  };
120
138
  }
121
139
 
122
- /**
123
- * The ESQuery selector for a component display name assignment expression
124
- */
125
- declare const COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR: string;
126
- /**
127
- * Check if the node is a component display name assignment expression
128
- * @param node The AST node
129
- * @returns `true` if the node is a component display name assignment
130
- */
131
- declare function isComponentDisplayNameAssignment(node: TSESTree.Node | _): node is TSESTree.AssignmentExpression;
132
-
133
140
  declare function getFunctionComponentIdentifier(node: AST.TSESTreeFunction, context: RuleContext): TSESTree.Identifier | TSESTree.Identifier[] | _;
134
141
 
135
142
  type ERComponentKind = "classComponent" | "functionComponent";
@@ -319,6 +326,17 @@ interface ERSemanticEntry {
319
326
  phase: ERPhaseKind;
320
327
  }
321
328
 
329
+ /**
330
+ * The ESQuery selector for a component display name assignment expression
331
+ */
332
+ declare const DISPLAY_NAME_ASSIGNMENT_SELECTOR: string;
333
+ /**
334
+ * Check if the node is a component display name assignment expression
335
+ * @param node The AST node
336
+ * @returns `true` if the node is a component display name assignment
337
+ */
338
+ declare function isDisplayNameAssignment(node: TSESTree.Node | _): node is TSESTree.AssignmentExpression;
339
+
322
340
  /**
323
341
  * Checks if the given node is a call expression to the given function or method of the pragma
324
342
  * @param name The name of the function or method to check
@@ -2368,7 +2386,7 @@ declare interface WithStatement extends BaseNode {
2368
2386
  }
2369
2387
  declare interface YieldExpression extends BaseNode {
2370
2388
  type: AST_NODE_TYPES.YieldExpression;
2371
- argument: Expression | undefined;
2389
+ argument: Expression | null;
2372
2390
  delegate: boolean;
2373
2391
  }
2374
2392
 
@@ -2399,4 +2417,4 @@ declare const isCreateRefCall: isCallFromReact.ReturnType;
2399
2417
  declare const isForwardRefCall: isCallFromReact.ReturnType;
2400
2418
  declare const isMemoCall: isCallFromReact.ReturnType;
2401
2419
 
2402
- export { COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR, DEFAULT_COMPONENT_HINT, type ERClassComponent, type ERComponent, ERComponentFlag, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectPhaseKind, type ERFunctionComponent, type ERHook, type ERHookKind, type ERLifecyclePhaseKind, type ERPhaseKind, ERPhaseRelevance, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDisplayNameAssignment, isComponentName, isComponentWillUnmount, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactMember, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
2420
+ export { DEFAULT_COMPONENT_HINT, DISPLAY_NAME_ASSIGNMENT_SELECTOR, type ERClassComponent, type ERComponent, ERComponentFlag, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectPhaseKind, type ERFunctionComponent, type ERHook, type ERHookKind, type ERLifecyclePhaseKind, type ERPhaseKind, ERPhaseRelevance, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentName, isComponentWillUnmount, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isDisplayNameAssignment, isForwardRef, isForwardRefCall, isFromReact, isFromReactMember, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
package/dist/index.js CHANGED
@@ -34,6 +34,17 @@ var VAR__namespace = /*#__PURE__*/_interopNamespace(VAR);
34
34
  var birecord__default = /*#__PURE__*/_interopDefault(birecord);
35
35
 
36
36
  // src/component/component-collector.ts
37
+ var DISPLAY_NAME_ASSIGNMENT_SELECTOR = [
38
+ "AssignmentExpression",
39
+ "[type]",
40
+ "[operator='=']",
41
+ "[left.type='MemberExpression']",
42
+ "[left.property.name='displayName']"
43
+ ].join("");
44
+ function isDisplayNameAssignment(node) {
45
+ if (node == null) return false;
46
+ return node.type === types.AST_NODE_TYPES.AssignmentExpression && node.operator === "=" && node.left.type === types.AST_NODE_TYPES.MemberExpression && node.left.property.type === types.AST_NODE_TYPES.Identifier && node.left.property.name === "displayName";
47
+ }
37
48
  function isInitializedFromReact(name, importSource, initialScope) {
38
49
  return name.toLowerCase() === "react" || VAR__namespace.isInitializedFromSource(
39
50
  name,
@@ -316,33 +327,36 @@ function useHookCollector() {
316
327
  return { ctx, listeners };
317
328
  }
318
329
  var ERComponentHint = {
330
+ /**
331
+ * 1n << 0n - 1n << 63n are reserved for JSXValueHint
332
+ */
319
333
  ...JSX3__namespace.JSXValueHint,
320
- // 1n << 0n - 1n << 63n are reserved for JSXValueHint
321
- // Skip function component created by React.memo
334
+ /**
335
+ * Skip function component created by React.memo
336
+ */
322
337
  SkipMemo: 1n << 64n,
323
- // Skip function component created by React.forwardRef
338
+ /**
339
+ * Skip function component created by React.forwardRef
340
+ */
324
341
  SkipForwardRef: 1n << 65n,
325
- // Skip function component defined in map function callback
342
+ /**
343
+ * Skip function component defined in map function callback
344
+ */
326
345
  SkipMapCallback: 1n << 66n,
327
- // Skip function component defined on object method
346
+ /**
347
+ * Skip function component defined on object method
348
+ */
328
349
  SkipObjectMethod: 1n << 67n,
329
- // Skip function component defined on class method
350
+ /**
351
+ * Skip function component defined on class method
352
+ */
330
353
  SkipClassMethod: 1n << 68n,
331
- // Skip function component defined on class property
354
+ /**
355
+ * Skip function component defined on class property
356
+ */
332
357
  SkipClassProperty: 1n << 69n
333
358
  };
334
- var DEFAULT_COMPONENT_HINT = 0n | ERComponentHint.SkipBooleanLiteral | ERComponentHint.SkipMapCallback | ERComponentHint.SkipNumberLiteral | ERComponentHint.SkipStringLiteral | ERComponentHint.SkipUndefined | ERComponentHint.SkipEmptyArray | ERComponentHint.StrictArray | ERComponentHint.StrictConditional | ERComponentHint.StrictLogical;
335
- var COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR = [
336
- "AssignmentExpression",
337
- "[type]",
338
- "[operator='=']",
339
- "[left.type='MemberExpression']",
340
- "[left.property.name='displayName']"
341
- ].join("");
342
- function isComponentDisplayNameAssignment(node) {
343
- if (node == null) return false;
344
- return node.type === types.AST_NODE_TYPES.AssignmentExpression && node.operator === "=" && node.left.type === types.AST_NODE_TYPES.MemberExpression && node.left.property.type === types.AST_NODE_TYPES.Identifier && node.left.property.name === "displayName";
345
- }
359
+ var DEFAULT_COMPONENT_HINT = 0n | ERComponentHint.SkipBooleanLiteral | ERComponentHint.SkipEmptyArray | ERComponentHint.SkipMapCallback | ERComponentHint.SkipNumberLiteral | ERComponentHint.SkipStringLiteral | ERComponentHint.SkipUndefined | ERComponentHint.StrictArray | ERComponentHint.StrictConditional | ERComponentHint.StrictLogical;
346
360
 
347
361
  // src/component/component-flag.ts
348
362
  var ERComponentFlag = {
@@ -350,8 +364,8 @@ var ERComponentFlag = {
350
364
  PureComponent: 1n << 0n,
351
365
  CreateElement: 1n << 1n,
352
366
  Memo: 1n << 2n,
353
- Async: 1n << 3n,
354
- ForwardRef: 1n << 4n
367
+ ForwardRef: 1n << 3n,
368
+ Async: 1n << 4n
355
369
  };
356
370
  function isComponentWrapperCall(node, context) {
357
371
  if (node.type !== types.AST_NODE_TYPES.CallExpression) {
@@ -507,7 +521,7 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
507
521
  });
508
522
  },
509
523
  ...collectDisplayName ? {
510
- [COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR](node) {
524
+ [DISPLAY_NAME_ASSIGNMENT_SELECTOR](node) {
511
525
  const { left, right } = node;
512
526
  if (left.type !== types.AST_NODE_TYPES.MemberExpression) return;
513
527
  const componentName = left.object.type === types.AST_NODE_TYPES.Identifier ? left.object.name : eff._;
@@ -680,8 +694,8 @@ function isFunctionOfUseEffectCleanup(node) {
680
694
  return nearFunction === nearFunctionOfReturn && isFunctionOfUseEffectSetup(nearFunction);
681
695
  }
682
696
 
683
- exports.COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR = COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR;
684
697
  exports.DEFAULT_COMPONENT_HINT = DEFAULT_COMPONENT_HINT;
698
+ exports.DISPLAY_NAME_ASSIGNMENT_SELECTOR = DISPLAY_NAME_ASSIGNMENT_SELECTOR;
685
699
  exports.ERComponentFlag = ERComponentFlag;
686
700
  exports.ERComponentHint = ERComponentHint;
687
701
  exports.ERPhaseRelevance = ERPhaseRelevance;
@@ -708,7 +722,6 @@ exports.isCloneElement = isCloneElement;
708
722
  exports.isCloneElementCall = isCloneElementCall;
709
723
  exports.isComponentDidCatch = isComponentDidCatch;
710
724
  exports.isComponentDidMount = isComponentDidMount;
711
- exports.isComponentDisplayNameAssignment = isComponentDisplayNameAssignment;
712
725
  exports.isComponentName = isComponentName;
713
726
  exports.isComponentWillUnmount = isComponentWillUnmount;
714
727
  exports.isCreateContext = isCreateContext;
@@ -719,6 +732,7 @@ exports.isCreateRef = isCreateRef;
719
732
  exports.isCreateRefCall = isCreateRefCall;
720
733
  exports.isDeclaredInRenderPropLoose = isDeclaredInRenderPropLoose;
721
734
  exports.isDirectValueOfRenderPropertyLoose = isDirectValueOfRenderPropertyLoose;
735
+ exports.isDisplayNameAssignment = isDisplayNameAssignment;
722
736
  exports.isForwardRef = isForwardRef;
723
737
  exports.isForwardRefCall = isForwardRefCall;
724
738
  exports.isFromReact = isFromReact;
package/dist/index.mjs CHANGED
@@ -7,6 +7,17 @@ import * as VAR from '@eslint-react/var';
7
7
  import birecord from 'birecord';
8
8
 
9
9
  // src/component/component-collector.ts
10
+ var DISPLAY_NAME_ASSIGNMENT_SELECTOR = [
11
+ "AssignmentExpression",
12
+ "[type]",
13
+ "[operator='=']",
14
+ "[left.type='MemberExpression']",
15
+ "[left.property.name='displayName']"
16
+ ].join("");
17
+ function isDisplayNameAssignment(node) {
18
+ if (node == null) return false;
19
+ return node.type === AST_NODE_TYPES.AssignmentExpression && node.operator === "=" && node.left.type === AST_NODE_TYPES.MemberExpression && node.left.property.type === AST_NODE_TYPES.Identifier && node.left.property.name === "displayName";
20
+ }
10
21
  function isInitializedFromReact(name, importSource, initialScope) {
11
22
  return name.toLowerCase() === "react" || VAR.isInitializedFromSource(
12
23
  name,
@@ -289,33 +300,36 @@ function useHookCollector() {
289
300
  return { ctx, listeners };
290
301
  }
291
302
  var ERComponentHint = {
303
+ /**
304
+ * 1n << 0n - 1n << 63n are reserved for JSXValueHint
305
+ */
292
306
  ...JSX3.JSXValueHint,
293
- // 1n << 0n - 1n << 63n are reserved for JSXValueHint
294
- // Skip function component created by React.memo
307
+ /**
308
+ * Skip function component created by React.memo
309
+ */
295
310
  SkipMemo: 1n << 64n,
296
- // Skip function component created by React.forwardRef
311
+ /**
312
+ * Skip function component created by React.forwardRef
313
+ */
297
314
  SkipForwardRef: 1n << 65n,
298
- // Skip function component defined in map function callback
315
+ /**
316
+ * Skip function component defined in map function callback
317
+ */
299
318
  SkipMapCallback: 1n << 66n,
300
- // Skip function component defined on object method
319
+ /**
320
+ * Skip function component defined on object method
321
+ */
301
322
  SkipObjectMethod: 1n << 67n,
302
- // Skip function component defined on class method
323
+ /**
324
+ * Skip function component defined on class method
325
+ */
303
326
  SkipClassMethod: 1n << 68n,
304
- // Skip function component defined on class property
327
+ /**
328
+ * Skip function component defined on class property
329
+ */
305
330
  SkipClassProperty: 1n << 69n
306
331
  };
307
- var DEFAULT_COMPONENT_HINT = 0n | ERComponentHint.SkipBooleanLiteral | ERComponentHint.SkipMapCallback | ERComponentHint.SkipNumberLiteral | ERComponentHint.SkipStringLiteral | ERComponentHint.SkipUndefined | ERComponentHint.SkipEmptyArray | ERComponentHint.StrictArray | ERComponentHint.StrictConditional | ERComponentHint.StrictLogical;
308
- var COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR = [
309
- "AssignmentExpression",
310
- "[type]",
311
- "[operator='=']",
312
- "[left.type='MemberExpression']",
313
- "[left.property.name='displayName']"
314
- ].join("");
315
- function isComponentDisplayNameAssignment(node) {
316
- if (node == null) return false;
317
- return node.type === AST_NODE_TYPES.AssignmentExpression && node.operator === "=" && node.left.type === AST_NODE_TYPES.MemberExpression && node.left.property.type === AST_NODE_TYPES.Identifier && node.left.property.name === "displayName";
318
- }
332
+ var DEFAULT_COMPONENT_HINT = 0n | ERComponentHint.SkipBooleanLiteral | ERComponentHint.SkipEmptyArray | ERComponentHint.SkipMapCallback | ERComponentHint.SkipNumberLiteral | ERComponentHint.SkipStringLiteral | ERComponentHint.SkipUndefined | ERComponentHint.StrictArray | ERComponentHint.StrictConditional | ERComponentHint.StrictLogical;
319
333
 
320
334
  // src/component/component-flag.ts
321
335
  var ERComponentFlag = {
@@ -323,8 +337,8 @@ var ERComponentFlag = {
323
337
  PureComponent: 1n << 0n,
324
338
  CreateElement: 1n << 1n,
325
339
  Memo: 1n << 2n,
326
- Async: 1n << 3n,
327
- ForwardRef: 1n << 4n
340
+ ForwardRef: 1n << 3n,
341
+ Async: 1n << 4n
328
342
  };
329
343
  function isComponentWrapperCall(node, context) {
330
344
  if (node.type !== AST_NODE_TYPES.CallExpression) {
@@ -480,7 +494,7 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
480
494
  });
481
495
  },
482
496
  ...collectDisplayName ? {
483
- [COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR](node) {
497
+ [DISPLAY_NAME_ASSIGNMENT_SELECTOR](node) {
484
498
  const { left, right } = node;
485
499
  if (left.type !== AST_NODE_TYPES.MemberExpression) return;
486
500
  const componentName = left.object.type === AST_NODE_TYPES.Identifier ? left.object.name : _;
@@ -653,4 +667,4 @@ function isFunctionOfUseEffectCleanup(node) {
653
667
  return nearFunction === nearFunctionOfReturn && isFunctionOfUseEffectSetup(nearFunction);
654
668
  }
655
669
 
656
- export { COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR, DEFAULT_COMPONENT_HINT, ERComponentFlag, ERComponentHint, ERPhaseRelevance, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDisplayNameAssignment, isComponentName, isComponentWillUnmount, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactMember, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
670
+ export { DEFAULT_COMPONENT_HINT, DISPLAY_NAME_ASSIGNMENT_SELECTOR, ERComponentFlag, ERComponentHint, ERPhaseRelevance, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentName, isComponentWillUnmount, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isDisplayNameAssignment, isForwardRef, isForwardRefCall, isFromReact, isFromReactMember, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "1.26.3-next.8",
3
+ "version": "1.27.0-beta.1",
4
4
  "description": "ESLint React's ESLint utility module for static analysis of React core APIs and Patterns.",
5
5
  "homepage": "https://github.com/Rel1cx/eslint-react",
6
6
  "bugs": {
@@ -35,17 +35,17 @@
35
35
  "./package.json"
36
36
  ],
37
37
  "dependencies": {
38
- "@typescript-eslint/scope-manager": "^8.23.0",
39
- "@typescript-eslint/type-utils": "^8.23.0",
40
- "@typescript-eslint/types": "^8.23.0",
41
- "@typescript-eslint/utils": "^8.23.0",
38
+ "@typescript-eslint/scope-manager": "^8.24.1",
39
+ "@typescript-eslint/type-utils": "^8.24.1",
40
+ "@typescript-eslint/types": "^8.24.1",
41
+ "@typescript-eslint/utils": "^8.24.1",
42
42
  "birecord": "^0.1.1",
43
43
  "ts-pattern": "^5.6.2",
44
- "@eslint-react/ast": "1.26.3-next.8",
45
- "@eslint-react/eff": "1.26.3-next.8",
46
- "@eslint-react/jsx": "1.26.3-next.8",
47
- "@eslint-react/shared": "1.26.3-next.8",
48
- "@eslint-react/var": "1.26.3-next.8"
44
+ "@eslint-react/ast": "1.27.0-beta.1",
45
+ "@eslint-react/eff": "1.27.0-beta.1",
46
+ "@eslint-react/jsx": "1.27.0-beta.1",
47
+ "@eslint-react/shared": "1.27.0-beta.1",
48
+ "@eslint-react/var": "1.27.0-beta.1"
49
49
  },
50
50
  "devDependencies": {
51
51
  "tsup": "^8.3.6",
@@ -59,6 +59,6 @@
59
59
  "build": "tsup",
60
60
  "build:docs": "typedoc",
61
61
  "lint:publish": "publint",
62
- "lint:type": "tsc --noEmit"
62
+ "lint:ts": "tsc --noEmit"
63
63
  }
64
64
  }