@eslint-react/core 1.24.0-next.8 → 1.24.0

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
@@ -1,6 +1,6 @@
1
1
  import * as AST from '@eslint-react/ast';
2
2
  import * as _eslint_react_shared from '@eslint-react/shared';
3
- import { RuleContext, CustomComponentNormalized } from '@eslint-react/shared';
3
+ import { RuleContext } from '@eslint-react/shared';
4
4
  import { TSESTree } from '@typescript-eslint/types';
5
5
  import { _ } from '@eslint-react/eff';
6
6
  import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
@@ -73,7 +73,7 @@ interface ERClassComponent extends ERSemanticNode {
73
73
  node: AST.TSESTreeClass;
74
74
  flag: ERClassComponentFlag;
75
75
  hint: ERComponentHint;
76
- methods: Array<TSESTree.MethodDefinition | TSESTree.PropertyDefinition>;
76
+ methods: AST.TSESTreeMethodOrProperty[];
77
77
  displayName: _ | TSESTree.Expression;
78
78
  }
79
79
  type ERComponent = ERClassComponent | ERFunctionComponent;
@@ -82,6 +82,13 @@ interface ComponentCollectorOptions {
82
82
  collectDisplayName?: boolean;
83
83
  collectHookCalls?: boolean;
84
84
  }
85
+ /**
86
+ * Get a ctx and listeners for the rule to collect function components
87
+ * @param context The ESLint rule context
88
+ * @param hint The hint to use
89
+ * @param options The options to use
90
+ * @returns The component collector
91
+ */
85
92
  declare function useComponentCollector(context: RuleContext, hint?: bigint, options?: ComponentCollectorOptions): {
86
93
  readonly ctx: {
87
94
  readonly getAllComponents: (node: TSESTree.Program) => Map<string, ERFunctionComponent>;
@@ -101,9 +108,6 @@ declare function useComponentCollector(context: RuleContext, hint?: bigint, opti
101
108
  readonly listeners: {
102
109
  readonly "ReturnStatement[type]": (node: TSESTree.ReturnStatement) => void;
103
110
  readonly "CallExpression[type]:exit"?: (node: TSESTree.CallExpression) => void;
104
- readonly "AssignmentExpression[type][operator='='][left.type='MemberExpression'][left.property.name='displayName']"?: (node: TSESTree.AssignmentExpression & {
105
- left: TSESTree.MemberExpression;
106
- }) => void;
107
111
  readonly ":function[type]": (node: AST.TSESTreeFunction) => void;
108
112
  readonly ":function[type]:exit": () => {
109
113
  key: string;
@@ -115,6 +119,10 @@ declare function useComponentCollector(context: RuleContext, hint?: bigint, opti
115
119
  };
116
120
  };
117
121
 
122
+ /**
123
+ * Get a ctx and listeners for the rule to collect class components
124
+ * @returns The context and listeners for the rule
125
+ */
118
126
  declare function useComponentCollectorLegacy(): {
119
127
  readonly ctx: {
120
128
  readonly getAllComponents: (node: TSESTree$1.Program) => Map<string, ERClassComponent>;
@@ -125,15 +133,29 @@ declare function useComponentCollectorLegacy(): {
125
133
  };
126
134
  };
127
135
 
136
+ /**
137
+ * The ESQuery selector for a component display name assignment expression
138
+ */
139
+ declare const COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR: string;
140
+ /**
141
+ * Check if the node is a component display name assignment expression
142
+ * @param node The AST node
143
+ * @returns `true` if the node is a component display name assignment
144
+ */
145
+ declare function isComponentDisplayNameAssignment(node: TSESTree.Node | _): node is TSESTree.AssignmentExpression;
146
+
128
147
  declare function getFunctionComponentIdentifier(node: AST.TSESTreeFunction, context: RuleContext): TSESTree.Identifier | TSESTree.Identifier[] | _;
129
148
 
130
149
  type ERComponentKind = "classComponent" | "functionComponent";
131
150
 
132
- declare function isComponentDidMount(node: TSESTree.Node): node is TSESTree.MethodDefinition | TSESTree.PropertyDefinition;
133
- declare function isComponentWillUnmount(node: TSESTree.Node): node is TSESTree.MethodDefinition | TSESTree.PropertyDefinition;
151
+ declare function isComponentDidMount(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
152
+ declare function isComponentWillUnmount(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
153
+ declare function isComponentDidCatch(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
154
+ declare function isGetDerivedStateFromError(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
155
+ declare function isGetDerivedStateFromProps(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
134
156
  declare function isFunctionOfComponentDidMount(node: TSESTree.Node): boolean;
135
157
  declare function isFunctionOfComponentWillUnmount(node: TSESTree.Node): boolean;
136
- declare function isRenderMethodLike(node: TSESTree.Node): node is TSESTree.MethodDefinition | TSESTree.PropertyDefinition;
158
+ declare function isRenderMethodLike(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
137
159
  declare function isFunctionOfRenderMethod(node: AST.TSESTreeFunction): boolean;
138
160
  /**
139
161
  * Check whether given node is declared inside class component's render block
@@ -152,9 +174,6 @@ declare function isFunctionOfRenderMethod(node: AST.TSESTreeFunction): boolean;
152
174
  */
153
175
  declare function isInsideRenderMethod(node: TSESTree.Node): boolean;
154
176
 
155
- type EREffectMethodKind = "useEffect" | "useInsertionEffect" | "useLayoutEffect";
156
- type ERLifecycleMethodKind = "componentDidMount" | "componentWillUnmount";
157
-
158
177
  declare const RE_COMPONENT_NAME: RegExp;
159
178
  declare function getComponentNameFromIdentifier(node: TSESTree.Identifier | TSESTree.Identifier[] | _): string | undefined;
160
179
  declare function isComponentName(name: string): boolean;
@@ -238,13 +257,11 @@ declare function isClassComponent(node: TSESTree.Node): node is AST.TSESTreeClas
238
257
  */
239
258
  declare function isPureComponent(node: TSESTree.Node): boolean;
240
259
 
241
- type EREffectKind = "effect" | "insertionEffect" | "layoutEffect";
260
+ type EREffectKind = "useEffect" | "useLayoutEffect" | "useInsertionEffect";
242
261
 
243
262
  declare function isFunctionOfUseEffectSetup(node: TSESTree.Node | _): boolean | undefined;
244
263
  declare function isFunctionOfUseEffectCleanup(node: TSESTree.Node): boolean | undefined;
245
264
 
246
- declare function getElementNameOnJsxAndHtml(node: TSESTree.JSXOpeningElement, context: RuleContext, polymorphicPropName?: string, additionalComponents?: CustomComponentNormalized[]): [string, string];
247
-
248
265
  /**
249
266
  * Determines whether inside `createElement`'s props.
250
267
  * @param node The AST node to check
@@ -318,8 +335,6 @@ interface ERSemanticEntry {
318
335
  phase: ERPhaseKind;
319
336
  }
320
337
 
321
- declare const getId: () => string;
322
-
323
338
  /**
324
339
  * Checks if the given node is a call expression to the given function or method of the pragma
325
340
  * @param name The name of the function or method to check
@@ -348,7 +363,7 @@ type IsCallFromReactMember = {
348
363
  };
349
364
  declare function isCallFromReactMember(pragmaMemberName: string, name: string): IsCallFromReactMember;
350
365
 
351
- declare function isInitializedFromReact(name: string, initialScope: Scope, importSource?: string): boolean;
366
+ declare function isInitializedFromReact(name: string, importSource: string, initialScope: Scope): boolean;
352
367
 
353
368
  /**********************************************
354
369
  * DO NOT MODIFY THIS FILE MANUALLY *
@@ -2572,4 +2587,4 @@ declare const isMemoCall: {
2572
2587
  (node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
2573
2588
  };
2574
2589
 
2575
- export { type ComponentCollectorOptions, DEFAULT_COMPONENT_HINT, type ERClassComponent, ERClassComponentFlag, type ERComponent, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectMethodKind, type EREffectPhaseKind, type ERFunctionComponent, ERFunctionComponentFlag, type ERHook, type ERHookKind, type ERLifecycleMethodKind, type ERLifecyclePhaseKind, type ERPhaseKind, ERPhaseRelevance, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getElementNameOnJsxAndHtml, getFunctionComponentIdentifier, getId, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidMount, isComponentName, isComponentWillUnmount, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactMember, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, 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 };
2590
+ export { COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR, type ComponentCollectorOptions, DEFAULT_COMPONENT_HINT, type ERClassComponent, ERClassComponentFlag, type ERComponent, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectPhaseKind, type ERFunctionComponent, ERFunctionComponentFlag, 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 };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as AST from '@eslint-react/ast';
2
2
  import * as _eslint_react_shared from '@eslint-react/shared';
3
- import { RuleContext, CustomComponentNormalized } from '@eslint-react/shared';
3
+ import { RuleContext } from '@eslint-react/shared';
4
4
  import { TSESTree } from '@typescript-eslint/types';
5
5
  import { _ } from '@eslint-react/eff';
6
6
  import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
@@ -73,7 +73,7 @@ interface ERClassComponent extends ERSemanticNode {
73
73
  node: AST.TSESTreeClass;
74
74
  flag: ERClassComponentFlag;
75
75
  hint: ERComponentHint;
76
- methods: Array<TSESTree.MethodDefinition | TSESTree.PropertyDefinition>;
76
+ methods: AST.TSESTreeMethodOrProperty[];
77
77
  displayName: _ | TSESTree.Expression;
78
78
  }
79
79
  type ERComponent = ERClassComponent | ERFunctionComponent;
@@ -82,6 +82,13 @@ interface ComponentCollectorOptions {
82
82
  collectDisplayName?: boolean;
83
83
  collectHookCalls?: boolean;
84
84
  }
85
+ /**
86
+ * Get a ctx and listeners for the rule to collect function components
87
+ * @param context The ESLint rule context
88
+ * @param hint The hint to use
89
+ * @param options The options to use
90
+ * @returns The component collector
91
+ */
85
92
  declare function useComponentCollector(context: RuleContext, hint?: bigint, options?: ComponentCollectorOptions): {
86
93
  readonly ctx: {
87
94
  readonly getAllComponents: (node: TSESTree.Program) => Map<string, ERFunctionComponent>;
@@ -101,9 +108,6 @@ declare function useComponentCollector(context: RuleContext, hint?: bigint, opti
101
108
  readonly listeners: {
102
109
  readonly "ReturnStatement[type]": (node: TSESTree.ReturnStatement) => void;
103
110
  readonly "CallExpression[type]:exit"?: (node: TSESTree.CallExpression) => void;
104
- readonly "AssignmentExpression[type][operator='='][left.type='MemberExpression'][left.property.name='displayName']"?: (node: TSESTree.AssignmentExpression & {
105
- left: TSESTree.MemberExpression;
106
- }) => void;
107
111
  readonly ":function[type]": (node: AST.TSESTreeFunction) => void;
108
112
  readonly ":function[type]:exit": () => {
109
113
  key: string;
@@ -115,6 +119,10 @@ declare function useComponentCollector(context: RuleContext, hint?: bigint, opti
115
119
  };
116
120
  };
117
121
 
122
+ /**
123
+ * Get a ctx and listeners for the rule to collect class components
124
+ * @returns The context and listeners for the rule
125
+ */
118
126
  declare function useComponentCollectorLegacy(): {
119
127
  readonly ctx: {
120
128
  readonly getAllComponents: (node: TSESTree$1.Program) => Map<string, ERClassComponent>;
@@ -125,15 +133,29 @@ declare function useComponentCollectorLegacy(): {
125
133
  };
126
134
  };
127
135
 
136
+ /**
137
+ * The ESQuery selector for a component display name assignment expression
138
+ */
139
+ declare const COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR: string;
140
+ /**
141
+ * Check if the node is a component display name assignment expression
142
+ * @param node The AST node
143
+ * @returns `true` if the node is a component display name assignment
144
+ */
145
+ declare function isComponentDisplayNameAssignment(node: TSESTree.Node | _): node is TSESTree.AssignmentExpression;
146
+
128
147
  declare function getFunctionComponentIdentifier(node: AST.TSESTreeFunction, context: RuleContext): TSESTree.Identifier | TSESTree.Identifier[] | _;
129
148
 
130
149
  type ERComponentKind = "classComponent" | "functionComponent";
131
150
 
132
- declare function isComponentDidMount(node: TSESTree.Node): node is TSESTree.MethodDefinition | TSESTree.PropertyDefinition;
133
- declare function isComponentWillUnmount(node: TSESTree.Node): node is TSESTree.MethodDefinition | TSESTree.PropertyDefinition;
151
+ declare function isComponentDidMount(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
152
+ declare function isComponentWillUnmount(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
153
+ declare function isComponentDidCatch(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
154
+ declare function isGetDerivedStateFromError(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
155
+ declare function isGetDerivedStateFromProps(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
134
156
  declare function isFunctionOfComponentDidMount(node: TSESTree.Node): boolean;
135
157
  declare function isFunctionOfComponentWillUnmount(node: TSESTree.Node): boolean;
136
- declare function isRenderMethodLike(node: TSESTree.Node): node is TSESTree.MethodDefinition | TSESTree.PropertyDefinition;
158
+ declare function isRenderMethodLike(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
137
159
  declare function isFunctionOfRenderMethod(node: AST.TSESTreeFunction): boolean;
138
160
  /**
139
161
  * Check whether given node is declared inside class component's render block
@@ -152,9 +174,6 @@ declare function isFunctionOfRenderMethod(node: AST.TSESTreeFunction): boolean;
152
174
  */
153
175
  declare function isInsideRenderMethod(node: TSESTree.Node): boolean;
154
176
 
155
- type EREffectMethodKind = "useEffect" | "useInsertionEffect" | "useLayoutEffect";
156
- type ERLifecycleMethodKind = "componentDidMount" | "componentWillUnmount";
157
-
158
177
  declare const RE_COMPONENT_NAME: RegExp;
159
178
  declare function getComponentNameFromIdentifier(node: TSESTree.Identifier | TSESTree.Identifier[] | _): string | undefined;
160
179
  declare function isComponentName(name: string): boolean;
@@ -238,13 +257,11 @@ declare function isClassComponent(node: TSESTree.Node): node is AST.TSESTreeClas
238
257
  */
239
258
  declare function isPureComponent(node: TSESTree.Node): boolean;
240
259
 
241
- type EREffectKind = "effect" | "insertionEffect" | "layoutEffect";
260
+ type EREffectKind = "useEffect" | "useLayoutEffect" | "useInsertionEffect";
242
261
 
243
262
  declare function isFunctionOfUseEffectSetup(node: TSESTree.Node | _): boolean | undefined;
244
263
  declare function isFunctionOfUseEffectCleanup(node: TSESTree.Node): boolean | undefined;
245
264
 
246
- declare function getElementNameOnJsxAndHtml(node: TSESTree.JSXOpeningElement, context: RuleContext, polymorphicPropName?: string, additionalComponents?: CustomComponentNormalized[]): [string, string];
247
-
248
265
  /**
249
266
  * Determines whether inside `createElement`'s props.
250
267
  * @param node The AST node to check
@@ -318,8 +335,6 @@ interface ERSemanticEntry {
318
335
  phase: ERPhaseKind;
319
336
  }
320
337
 
321
- declare const getId: () => string;
322
-
323
338
  /**
324
339
  * Checks if the given node is a call expression to the given function or method of the pragma
325
340
  * @param name The name of the function or method to check
@@ -348,7 +363,7 @@ type IsCallFromReactMember = {
348
363
  };
349
364
  declare function isCallFromReactMember(pragmaMemberName: string, name: string): IsCallFromReactMember;
350
365
 
351
- declare function isInitializedFromReact(name: string, initialScope: Scope, importSource?: string): boolean;
366
+ declare function isInitializedFromReact(name: string, importSource: string, initialScope: Scope): boolean;
352
367
 
353
368
  /**********************************************
354
369
  * DO NOT MODIFY THIS FILE MANUALLY *
@@ -2572,4 +2587,4 @@ declare const isMemoCall: {
2572
2587
  (node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
2573
2588
  };
2574
2589
 
2575
- export { type ComponentCollectorOptions, DEFAULT_COMPONENT_HINT, type ERClassComponent, ERClassComponentFlag, type ERComponent, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectMethodKind, type EREffectPhaseKind, type ERFunctionComponent, ERFunctionComponentFlag, type ERHook, type ERHookKind, type ERLifecycleMethodKind, type ERLifecyclePhaseKind, type ERPhaseKind, ERPhaseRelevance, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getElementNameOnJsxAndHtml, getFunctionComponentIdentifier, getId, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidMount, isComponentName, isComponentWillUnmount, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactMember, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, 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 };
2590
+ export { COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR, type ComponentCollectorOptions, DEFAULT_COMPONENT_HINT, type ERClassComponent, ERClassComponentFlag, type ERComponent, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectPhaseKind, type ERFunctionComponent, ERFunctionComponentFlag, 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 };
package/dist/index.js CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  var AST8 = require('@eslint-react/ast');
4
4
  var eff = require('@eslint-react/eff');
5
- var JSX4 = require('@eslint-react/jsx');
5
+ var JSX3 = require('@eslint-react/jsx');
6
+ var shared = require('@eslint-react/shared');
6
7
  var types = require('@typescript-eslint/types');
7
8
  var VAR = require('@eslint-react/var');
8
- var shared = require('@eslint-react/shared');
9
9
  var birecord = require('birecord');
10
10
 
11
11
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -29,35 +29,12 @@ function _interopNamespace(e) {
29
29
  }
30
30
 
31
31
  var AST8__namespace = /*#__PURE__*/_interopNamespace(AST8);
32
- var JSX4__namespace = /*#__PURE__*/_interopNamespace(JSX4);
32
+ var JSX3__namespace = /*#__PURE__*/_interopNamespace(JSX3);
33
33
  var VAR__namespace = /*#__PURE__*/_interopNamespace(VAR);
34
34
  var birecord__default = /*#__PURE__*/_interopDefault(birecord);
35
35
 
36
36
  // src/component/component-collector.ts
37
- function getElementNameOnJsxAndHtml(node, context, polymorphicPropName, additionalComponents = []) {
38
- const name = JSX4__namespace.getElementName(node);
39
- if (name === name.toLowerCase()) return [name, name];
40
- const component = additionalComponents.findLast((c) => c.name === name || c.re.test(name));
41
- if (component != null) return [name, component.as];
42
- if (polymorphicPropName == null) return [name, name];
43
- const initialScope = context.sourceCode.getScope(node);
44
- const attributeNode = JSX4__namespace.getAttributeNode(
45
- polymorphicPropName,
46
- initialScope,
47
- node.attributes
48
- );
49
- if (attributeNode == null) return [name, name];
50
- const polymorphicPropValue = VAR__namespace.toResolved(JSX4__namespace.getAttributeStaticValue(attributeNode, initialScope)).value;
51
- if (typeof polymorphicPropValue === "string") {
52
- return [name, polymorphicPropValue];
53
- }
54
- return [name, name];
55
- }
56
-
57
- // src/utils/get-id.ts
58
- var id = 0n;
59
- var getId = () => (id++).toString();
60
- function isInitializedFromReact(name, initialScope, importSource = "react") {
37
+ function isInitializedFromReact(name, importSource, initialScope) {
61
38
  return name.toLowerCase() === "react" || VAR__namespace.isInitializedFromSource(
62
39
  name,
63
40
  importSource,
@@ -75,12 +52,13 @@ function isFromReact(name) {
75
52
  }
76
53
  return node.name === name;
77
54
  }
55
+ const importSource = settings.importSource ?? shared.DEFAULT_ESLINT_REACT_SETTINGS.importSource;
78
56
  const initialScope = context.sourceCode.getScope(node);
79
57
  if (node.type === types.AST_NODE_TYPES.MemberExpression) {
80
- return node.object.type === types.AST_NODE_TYPES.Identifier && node.property.type === types.AST_NODE_TYPES.Identifier && node.property.name === name && isInitializedFromReact(node.object.name, initialScope, settings.importSource);
58
+ return node.object.type === types.AST_NODE_TYPES.Identifier && node.property.type === types.AST_NODE_TYPES.Identifier && node.property.name === name && isInitializedFromReact(node.object.name, importSource, initialScope);
81
59
  }
82
60
  if (node.name === name) {
83
- return isInitializedFromReact(name, initialScope, settings.importSource);
61
+ return isInitializedFromReact(name, importSource, initialScope);
84
62
  }
85
63
  return false;
86
64
  };
@@ -100,14 +78,15 @@ function isFromReactMember(memberName, name) {
100
78
  }
101
79
  return false;
102
80
  }
81
+ const importSource = settings.importSource ?? shared.DEFAULT_ESLINT_REACT_SETTINGS.importSource;
103
82
  const initialScope = context.sourceCode.getScope(node);
104
83
  if (node.property.type !== types.AST_NODE_TYPES.Identifier || node.property.name !== name) {
105
84
  return false;
106
85
  }
107
86
  if (node.object.type === types.AST_NODE_TYPES.Identifier && node.object.name === memberName) {
108
- return isInitializedFromReact(node.object.name, initialScope, settings.importSource);
87
+ return isInitializedFromReact(node.object.name, importSource, initialScope);
109
88
  }
110
- if (node.object.type === types.AST_NODE_TYPES.MemberExpression && node.object.object.type === types.AST_NODE_TYPES.Identifier && isInitializedFromReact(node.object.object.name, initialScope, settings.importSource) && node.object.property.type === types.AST_NODE_TYPES.Identifier) {
89
+ if (node.object.type === types.AST_NODE_TYPES.MemberExpression && node.object.object.type === types.AST_NODE_TYPES.Identifier && isInitializedFromReact(node.object.object.name, importSource, initialScope) && node.object.property.type === types.AST_NODE_TYPES.Identifier) {
111
90
  return node.object.property.name === memberName;
112
91
  }
113
92
  return false;
@@ -190,8 +169,8 @@ function isReactHookName(name) {
190
169
  // src/hook/is.ts
191
170
  function isReactHook(node) {
192
171
  if (node == null) return eff._;
193
- const id2 = AST8__namespace.getFunctionIdentifier(node);
194
- return id2?.name != null && isReactHookName(id2.name);
172
+ const id = AST8__namespace.getFunctionIdentifier(node);
173
+ return id?.name != null && isReactHookName(id.name);
195
174
  }
196
175
  function isReactHookCall(node) {
197
176
  if (node == null) return false;
@@ -209,13 +188,14 @@ function isReactHookCall(node) {
209
188
  function isReactHookCallWithName(node, context) {
210
189
  if (node == null) return eff.returnFalse;
211
190
  const settings = shared.unsafeDecodeSettings(context.settings);
191
+ const importSource = settings.importSource ?? "react";
192
+ const initialScope = context.sourceCode.getScope(node);
212
193
  return (name) => {
213
- const initialScope = context.sourceCode.getScope(node);
214
194
  switch (true) {
215
195
  case (node.callee.type === types.AST_NODE_TYPES.Identifier && node.callee.name === name):
216
- return !settings.strictImportCheck || isInitializedFromReact(name, initialScope, settings.importSource);
196
+ return !settings.strictImportCheck || isInitializedFromReact(name, importSource, initialScope);
217
197
  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):
218
- return !settings.strictImportCheck || isInitializedFromReact(node.callee.object.name, initialScope, settings.importSource);
198
+ return !settings.strictImportCheck || isInitializedFromReact(node.callee.object.name, importSource, initialScope);
219
199
  default:
220
200
  return false;
221
201
  }
@@ -236,13 +216,14 @@ function isReactHookCallWithNameLoose(node) {
236
216
  }
237
217
  function isReactHookCallWithNameAlias(name, context, alias) {
238
218
  const settings = shared.unsafeDecodeSettings(context);
219
+ const importSource = settings.importSource ?? "react";
239
220
  return (node) => {
240
221
  const initialScope = context.sourceCode.getScope(node);
241
222
  switch (true) {
242
223
  case (node.callee.type === types.AST_NODE_TYPES.Identifier && node.callee.name === name):
243
- return !settings.strictImportCheck || isInitializedFromReact(name, initialScope, settings.importSource);
224
+ return !settings.strictImportCheck || isInitializedFromReact(name, importSource, initialScope);
244
225
  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):
245
- return !settings.strictImportCheck || isInitializedFromReact(node.callee.object.name, initialScope, settings.importSource);
226
+ return !settings.strictImportCheck || isInitializedFromReact(node.callee.object.name, importSource, initialScope);
246
227
  default:
247
228
  return alias.some(isReactHookCallWithNameLoose(node));
248
229
  }
@@ -286,13 +267,13 @@ function useHookCollector() {
286
267
  const hooks = /* @__PURE__ */ new Map();
287
268
  const fEntries = [];
288
269
  const onFunctionEnter = (node) => {
289
- const id2 = AST8__namespace.getFunctionIdentifier(node);
290
- const name = id2?.name;
270
+ const id = AST8__namespace.getFunctionIdentifier(node);
271
+ const name = id?.name;
291
272
  if (name != null && isReactHookName(name)) {
292
- const key = getId();
273
+ const key = shared.getId();
293
274
  fEntries.push({ key, node });
294
275
  hooks.set(key, {
295
- id: id2,
276
+ id,
296
277
  key,
297
278
  kind: "function",
298
279
  name,
@@ -338,7 +319,7 @@ function useHookCollector() {
338
319
  return { ctx, listeners };
339
320
  }
340
321
  var ERComponentHint = {
341
- ...JSX4__namespace.JSXValueHint,
322
+ ...JSX3__namespace.JSXValueHint,
342
323
  // 1n << 0n - 1n << 63n are reserved for JSXValueHint
343
324
  // Skip function component created by React.memo
344
325
  SkipMemo: 1n << 64n,
@@ -354,6 +335,17 @@ var ERComponentHint = {
354
335
  SkipClassProperty: 1n << 69n
355
336
  };
356
337
  var DEFAULT_COMPONENT_HINT = 0n | ERComponentHint.SkipBooleanLiteral | ERComponentHint.SkipMapCallback | ERComponentHint.SkipNumberLiteral | ERComponentHint.SkipStringLiteral | ERComponentHint.SkipUndefined | ERComponentHint.SkipEmptyArray | ERComponentHint.StrictArray | ERComponentHint.StrictConditional | ERComponentHint.StrictLogical;
338
+ var COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR = [
339
+ "AssignmentExpression",
340
+ "[type]",
341
+ "[operator='=']",
342
+ "[left.type='MemberExpression']",
343
+ "[left.property.name='displayName']"
344
+ ].join("");
345
+ function isComponentDisplayNameAssignment(node) {
346
+ if (node == null) return false;
347
+ 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";
348
+ }
357
349
 
358
350
  // src/component/component-flag.ts
359
351
  var ERClassComponentFlag = {
@@ -420,10 +412,19 @@ function isPureComponent(node) {
420
412
 
421
413
  // src/component/component-lifecycle.ts
422
414
  function isComponentDidMount(node) {
423
- return AST8__namespace.isOneOf([types.AST_NODE_TYPES.MethodDefinition, types.AST_NODE_TYPES.PropertyDefinition])(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
415
+ return AST8__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
424
416
  }
425
417
  function isComponentWillUnmount(node) {
426
- return AST8__namespace.isOneOf([types.AST_NODE_TYPES.MethodDefinition, types.AST_NODE_TYPES.PropertyDefinition])(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillUnmount";
418
+ return AST8__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentWillUnmount";
419
+ }
420
+ function isComponentDidCatch(node) {
421
+ return AST8__namespace.isMethodOrProperty(node) && !node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "componentDidCatch";
422
+ }
423
+ function isGetDerivedStateFromError(node) {
424
+ return AST8__namespace.isMethodOrProperty(node) && node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromError";
425
+ }
426
+ function isGetDerivedStateFromProps(node) {
427
+ return AST8__namespace.isMethodOrProperty(node) && node.static && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromProps";
427
428
  }
428
429
  function isFunctionOfComponentDidMount(node) {
429
430
  return AST8__namespace.isFunction(node) && isComponentDidMount(node.parent) && node.parent.value === node;
@@ -432,7 +433,7 @@ function isFunctionOfComponentWillUnmount(node) {
432
433
  return AST8__namespace.isFunction(node) && isComponentWillUnmount(node.parent) && node.parent.value === node;
433
434
  }
434
435
  function isRenderMethodLike(node) {
435
- return (node.type === types.AST_NODE_TYPES.MethodDefinition || node.type === types.AST_NODE_TYPES.PropertyDefinition) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "render" && node.parent.parent.type === types.AST_NODE_TYPES.ClassDeclaration;
436
+ return AST8__namespace.isMethodOrProperty(node) && node.key.type === types.AST_NODE_TYPES.Identifier && node.key.name === "render" && node.parent.parent.type === types.AST_NODE_TYPES.ClassDeclaration;
436
437
  }
437
438
  function isFunctionOfRenderMethod(node) {
438
439
  if (!isRenderMethodLike(node.parent)) {
@@ -452,9 +453,9 @@ function isComponentName(name) {
452
453
  return RE_COMPONENT_NAME.test(name);
453
454
  }
454
455
  function hasNoneOrValidComponentName(node, context) {
455
- const id2 = getFunctionComponentIdentifier(node, context);
456
- if (id2 == null) return true;
457
- const name = Array.isArray(id2) ? id2.at(-1)?.name : id2.name;
456
+ const id = getFunctionComponentIdentifier(node, context);
457
+ if (id == null) return true;
458
+ const name = Array.isArray(id) ? id.at(-1)?.name : id.name;
458
459
  return name != null && isComponentName(name);
459
460
  }
460
461
 
@@ -497,7 +498,6 @@ function getComponentFlag(initPath) {
497
498
  }
498
499
  return flag;
499
500
  }
500
- var displayNameAssignmentSelector = "AssignmentExpression[type][operator='='][left.type='MemberExpression'][left.property.name='displayName']";
501
501
  function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options = {}) {
502
502
  const { collectDisplayName = false, collectHookCalls = false } = options;
503
503
  const jsxCtx = { getScope: (node) => context.sourceCode.getScope(node) };
@@ -505,7 +505,7 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
505
505
  const functionEntries = [];
506
506
  const getCurrentEntry = () => functionEntries.at(-1);
507
507
  const onFunctionEnter = (node) => {
508
- const key = getId();
508
+ const key = shared.getId();
509
509
  functionEntries.push({ key, node, hookCalls: [], isComponent: false });
510
510
  };
511
511
  const onFunctionExit = () => {
@@ -515,7 +515,7 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
515
515
  return functionEntries.pop();
516
516
  }
517
517
  const shouldDrop = AST8__namespace.getNestedReturnStatements(entry.node.body).slice().reverse().some((r) => {
518
- return context.sourceCode.getScope(r).block === entry.node && r.argument != null && !JSX4__namespace.isJSXValue(r.argument, jsxCtx, hint);
518
+ return context.sourceCode.getScope(r).block === entry.node && r.argument != null && !JSX3__namespace.isJSXValue(r.argument, jsxCtx, hint);
519
519
  });
520
520
  if (shouldDrop) {
521
521
  components.delete(entry.key);
@@ -541,16 +541,16 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
541
541
  return;
542
542
  }
543
543
  const { body } = entry.node;
544
- const isComponent = hasNoneOrValidComponentName(entry.node, context) && JSX4__namespace.isJSXValue(body, jsxCtx, hint) && hasValidHierarchy(entry.node, context, hint);
544
+ const isComponent = hasNoneOrValidComponentName(entry.node, context) && JSX3__namespace.isJSXValue(body, jsxCtx, hint) && hasValidHierarchy(entry.node, context, hint);
545
545
  if (!isComponent) {
546
546
  return;
547
547
  }
548
548
  const initPath = AST8__namespace.getFunctionInitPath(entry.node);
549
- const id2 = getFunctionComponentIdentifier(entry.node, context);
550
- const name = getComponentNameFromIdentifier(id2);
551
- const key = getId();
549
+ const id = getFunctionComponentIdentifier(entry.node, context);
550
+ const name = getComponentNameFromIdentifier(id);
551
+ const key = shared.getId();
552
552
  components.set(key, {
553
- id: id2,
553
+ id,
554
554
  key,
555
555
  kind: "function",
556
556
  name,
@@ -563,8 +563,9 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
563
563
  });
564
564
  },
565
565
  ...collectDisplayName ? {
566
- [displayNameAssignmentSelector](node) {
566
+ [COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR](node) {
567
567
  const { left, right } = node;
568
+ if (left.type !== types.AST_NODE_TYPES.MemberExpression) return;
568
569
  const componentName = left.object.type === types.AST_NODE_TYPES.Identifier ? left.object.name : eff._;
569
570
  const component = [...components.values()].findLast(({ name }) => name != null && name === componentName);
570
571
  if (component == null) {
@@ -590,17 +591,17 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
590
591
  if (entry == null) {
591
592
  return;
592
593
  }
593
- const isComponent = hasNoneOrValidComponentName(entry.node, context) && JSX4__namespace.isJSXValue(node.argument, jsxCtx, hint) && hasValidHierarchy(entry.node, context, hint);
594
+ const isComponent = hasNoneOrValidComponentName(entry.node, context) && JSX3__namespace.isJSXValue(node.argument, jsxCtx, hint) && hasValidHierarchy(entry.node, context, hint);
594
595
  if (!isComponent) {
595
596
  return;
596
597
  }
597
598
  functionEntries.pop();
598
599
  functionEntries.push({ ...entry, isComponent });
599
600
  const initPath = AST8__namespace.getFunctionInitPath(entry.node);
600
- const id2 = getFunctionComponentIdentifier(entry.node, context);
601
- const name = getComponentNameFromIdentifier(id2);
601
+ const id = getFunctionComponentIdentifier(entry.node, context);
602
+ const name = getComponentNameFromIdentifier(id);
602
603
  components.set(entry.key, {
603
- id: id2,
604
+ id,
604
605
  key: entry.key,
605
606
  kind: "function",
606
607
  name,
@@ -627,16 +628,16 @@ function useComponentCollectorLegacy() {
627
628
  if (!isClassComponent(node)) {
628
629
  return;
629
630
  }
630
- const id2 = AST8__namespace.getClassIdentifier(node);
631
- const key = getId();
631
+ const id = AST8__namespace.getClassIdentifier(node);
632
+ const key = shared.getId();
632
633
  const flag = isPureComponent(node) ? ERClassComponentFlag.PureComponent : ERClassComponentFlag.None;
633
634
  components.set(
634
635
  key,
635
636
  {
636
- id: id2,
637
+ id,
637
638
  key,
638
639
  kind: "class",
639
- name: id2?.name,
640
+ name: id?.name,
640
641
  node,
641
642
  // TODO: Get displayName of class component
642
643
  displayName: eff._,
@@ -663,12 +664,12 @@ function isRenderFunctionLoose(node, context) {
663
664
  if (AST8__namespace.getFunctionIdentifier(node)?.name.startsWith("render")) {
664
665
  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");
665
666
  }
666
- return JSX4__namespace.isJSXValue(
667
+ return JSX3__namespace.isJSXValue(
667
668
  body,
668
669
  {
669
670
  getScope: (node2) => context.sourceCode.getScope(node2)
670
671
  },
671
- JSX4__namespace.JSXValueHint.SkipNullLiteral | JSX4__namespace.JSXValueHint.SkipUndefined | JSX4__namespace.JSXValueHint.StrictLogical | JSX4__namespace.JSXValueHint.StrictConditional
672
+ JSX3__namespace.JSXValueHint.SkipNullLiteral | JSX3__namespace.JSXValueHint.SkipUndefined | JSX3__namespace.JSXValueHint.StrictLogical | JSX3__namespace.JSXValueHint.StrictConditional
672
673
  );
673
674
  }
674
675
  function isRenderPropLoose(node, context) {
@@ -708,6 +709,7 @@ function isFunctionOfUseEffectCleanup(node) {
708
709
  return nearFunction === nearFunctionOfReturn && isFunctionOfUseEffectSetup(nearFunction);
709
710
  }
710
711
 
712
+ exports.COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR = COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR;
711
713
  exports.DEFAULT_COMPONENT_HINT = DEFAULT_COMPONENT_HINT;
712
714
  exports.ERClassComponentFlag = ERClassComponentFlag;
713
715
  exports.ERComponentHint = ERComponentHint;
@@ -716,9 +718,7 @@ exports.ERPhaseRelevance = ERPhaseRelevance;
716
718
  exports.RE_COMPONENT_NAME = RE_COMPONENT_NAME;
717
719
  exports.RE_HOOK_NAME = RE_HOOK_NAME;
718
720
  exports.getComponentNameFromIdentifier = getComponentNameFromIdentifier;
719
- exports.getElementNameOnJsxAndHtml = getElementNameOnJsxAndHtml;
720
721
  exports.getFunctionComponentIdentifier = getFunctionComponentIdentifier;
721
- exports.getId = getId;
722
722
  exports.hasNoneOrValidComponentName = hasNoneOrValidComponentName;
723
723
  exports.isCallFromReact = isCallFromReact;
724
724
  exports.isCallFromReactMember = isCallFromReactMember;
@@ -736,7 +736,9 @@ exports.isChildrenToArrayCall = isChildrenToArrayCall;
736
736
  exports.isClassComponent = isClassComponent;
737
737
  exports.isCloneElement = isCloneElement;
738
738
  exports.isCloneElementCall = isCloneElementCall;
739
+ exports.isComponentDidCatch = isComponentDidCatch;
739
740
  exports.isComponentDidMount = isComponentDidMount;
741
+ exports.isComponentDisplayNameAssignment = isComponentDisplayNameAssignment;
740
742
  exports.isComponentName = isComponentName;
741
743
  exports.isComponentWillUnmount = isComponentWillUnmount;
742
744
  exports.isCreateContext = isCreateContext;
@@ -756,6 +758,8 @@ exports.isFunctionOfComponentWillUnmount = isFunctionOfComponentWillUnmount;
756
758
  exports.isFunctionOfRenderMethod = isFunctionOfRenderMethod;
757
759
  exports.isFunctionOfUseEffectCleanup = isFunctionOfUseEffectCleanup;
758
760
  exports.isFunctionOfUseEffectSetup = isFunctionOfUseEffectSetup;
761
+ exports.isGetDerivedStateFromError = isGetDerivedStateFromError;
762
+ exports.isGetDerivedStateFromProps = isGetDerivedStateFromProps;
759
763
  exports.isInitializedFromReact = isInitializedFromReact;
760
764
  exports.isInsideCreateElementProps = isInsideCreateElementProps;
761
765
  exports.isInsideReactHook = isInsideReactHook;
package/dist/index.mjs CHANGED
@@ -1,36 +1,13 @@
1
1
  import * as AST8 from '@eslint-react/ast';
2
2
  import { flip, dual, _, returnFalse } from '@eslint-react/eff';
3
- import * as JSX4 from '@eslint-react/jsx';
3
+ import * as JSX3 from '@eslint-react/jsx';
4
+ import { unsafeDecodeSettings, DEFAULT_ESLINT_REACT_SETTINGS, getId } from '@eslint-react/shared';
4
5
  import { AST_NODE_TYPES } from '@typescript-eslint/types';
5
6
  import * as VAR from '@eslint-react/var';
6
- import { unsafeDecodeSettings } from '@eslint-react/shared';
7
7
  import birecord from 'birecord';
8
8
 
9
9
  // src/component/component-collector.ts
10
- function getElementNameOnJsxAndHtml(node, context, polymorphicPropName, additionalComponents = []) {
11
- const name = JSX4.getElementName(node);
12
- if (name === name.toLowerCase()) return [name, name];
13
- const component = additionalComponents.findLast((c) => c.name === name || c.re.test(name));
14
- if (component != null) return [name, component.as];
15
- if (polymorphicPropName == null) return [name, name];
16
- const initialScope = context.sourceCode.getScope(node);
17
- const attributeNode = JSX4.getAttributeNode(
18
- polymorphicPropName,
19
- initialScope,
20
- node.attributes
21
- );
22
- if (attributeNode == null) return [name, name];
23
- const polymorphicPropValue = VAR.toResolved(JSX4.getAttributeStaticValue(attributeNode, initialScope)).value;
24
- if (typeof polymorphicPropValue === "string") {
25
- return [name, polymorphicPropValue];
26
- }
27
- return [name, name];
28
- }
29
-
30
- // src/utils/get-id.ts
31
- var id = 0n;
32
- var getId = () => (id++).toString();
33
- function isInitializedFromReact(name, initialScope, importSource = "react") {
10
+ function isInitializedFromReact(name, importSource, initialScope) {
34
11
  return name.toLowerCase() === "react" || VAR.isInitializedFromSource(
35
12
  name,
36
13
  importSource,
@@ -48,12 +25,13 @@ function isFromReact(name) {
48
25
  }
49
26
  return node.name === name;
50
27
  }
28
+ const importSource = settings.importSource ?? DEFAULT_ESLINT_REACT_SETTINGS.importSource;
51
29
  const initialScope = context.sourceCode.getScope(node);
52
30
  if (node.type === AST_NODE_TYPES.MemberExpression) {
53
- return node.object.type === AST_NODE_TYPES.Identifier && node.property.type === AST_NODE_TYPES.Identifier && node.property.name === name && isInitializedFromReact(node.object.name, initialScope, settings.importSource);
31
+ return node.object.type === AST_NODE_TYPES.Identifier && node.property.type === AST_NODE_TYPES.Identifier && node.property.name === name && isInitializedFromReact(node.object.name, importSource, initialScope);
54
32
  }
55
33
  if (node.name === name) {
56
- return isInitializedFromReact(name, initialScope, settings.importSource);
34
+ return isInitializedFromReact(name, importSource, initialScope);
57
35
  }
58
36
  return false;
59
37
  };
@@ -73,14 +51,15 @@ function isFromReactMember(memberName, name) {
73
51
  }
74
52
  return false;
75
53
  }
54
+ const importSource = settings.importSource ?? DEFAULT_ESLINT_REACT_SETTINGS.importSource;
76
55
  const initialScope = context.sourceCode.getScope(node);
77
56
  if (node.property.type !== AST_NODE_TYPES.Identifier || node.property.name !== name) {
78
57
  return false;
79
58
  }
80
59
  if (node.object.type === AST_NODE_TYPES.Identifier && node.object.name === memberName) {
81
- return isInitializedFromReact(node.object.name, initialScope, settings.importSource);
60
+ return isInitializedFromReact(node.object.name, importSource, initialScope);
82
61
  }
83
- if (node.object.type === AST_NODE_TYPES.MemberExpression && node.object.object.type === AST_NODE_TYPES.Identifier && isInitializedFromReact(node.object.object.name, initialScope, settings.importSource) && node.object.property.type === AST_NODE_TYPES.Identifier) {
62
+ if (node.object.type === AST_NODE_TYPES.MemberExpression && node.object.object.type === AST_NODE_TYPES.Identifier && isInitializedFromReact(node.object.object.name, importSource, initialScope) && node.object.property.type === AST_NODE_TYPES.Identifier) {
84
63
  return node.object.property.name === memberName;
85
64
  }
86
65
  return false;
@@ -163,8 +142,8 @@ function isReactHookName(name) {
163
142
  // src/hook/is.ts
164
143
  function isReactHook(node) {
165
144
  if (node == null) return _;
166
- const id2 = AST8.getFunctionIdentifier(node);
167
- return id2?.name != null && isReactHookName(id2.name);
145
+ const id = AST8.getFunctionIdentifier(node);
146
+ return id?.name != null && isReactHookName(id.name);
168
147
  }
169
148
  function isReactHookCall(node) {
170
149
  if (node == null) return false;
@@ -182,13 +161,14 @@ function isReactHookCall(node) {
182
161
  function isReactHookCallWithName(node, context) {
183
162
  if (node == null) return returnFalse;
184
163
  const settings = unsafeDecodeSettings(context.settings);
164
+ const importSource = settings.importSource ?? "react";
165
+ const initialScope = context.sourceCode.getScope(node);
185
166
  return (name) => {
186
- const initialScope = context.sourceCode.getScope(node);
187
167
  switch (true) {
188
168
  case (node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === name):
189
- return !settings.strictImportCheck || isInitializedFromReact(name, initialScope, settings.importSource);
169
+ return !settings.strictImportCheck || isInitializedFromReact(name, importSource, initialScope);
190
170
  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):
191
- return !settings.strictImportCheck || isInitializedFromReact(node.callee.object.name, initialScope, settings.importSource);
171
+ return !settings.strictImportCheck || isInitializedFromReact(node.callee.object.name, importSource, initialScope);
192
172
  default:
193
173
  return false;
194
174
  }
@@ -209,13 +189,14 @@ function isReactHookCallWithNameLoose(node) {
209
189
  }
210
190
  function isReactHookCallWithNameAlias(name, context, alias) {
211
191
  const settings = unsafeDecodeSettings(context);
192
+ const importSource = settings.importSource ?? "react";
212
193
  return (node) => {
213
194
  const initialScope = context.sourceCode.getScope(node);
214
195
  switch (true) {
215
196
  case (node.callee.type === AST_NODE_TYPES.Identifier && node.callee.name === name):
216
- return !settings.strictImportCheck || isInitializedFromReact(name, initialScope, settings.importSource);
197
+ return !settings.strictImportCheck || isInitializedFromReact(name, importSource, initialScope);
217
198
  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):
218
- return !settings.strictImportCheck || isInitializedFromReact(node.callee.object.name, initialScope, settings.importSource);
199
+ return !settings.strictImportCheck || isInitializedFromReact(node.callee.object.name, importSource, initialScope);
219
200
  default:
220
201
  return alias.some(isReactHookCallWithNameLoose(node));
221
202
  }
@@ -259,13 +240,13 @@ function useHookCollector() {
259
240
  const hooks = /* @__PURE__ */ new Map();
260
241
  const fEntries = [];
261
242
  const onFunctionEnter = (node) => {
262
- const id2 = AST8.getFunctionIdentifier(node);
263
- const name = id2?.name;
243
+ const id = AST8.getFunctionIdentifier(node);
244
+ const name = id?.name;
264
245
  if (name != null && isReactHookName(name)) {
265
246
  const key = getId();
266
247
  fEntries.push({ key, node });
267
248
  hooks.set(key, {
268
- id: id2,
249
+ id,
269
250
  key,
270
251
  kind: "function",
271
252
  name,
@@ -311,7 +292,7 @@ function useHookCollector() {
311
292
  return { ctx, listeners };
312
293
  }
313
294
  var ERComponentHint = {
314
- ...JSX4.JSXValueHint,
295
+ ...JSX3.JSXValueHint,
315
296
  // 1n << 0n - 1n << 63n are reserved for JSXValueHint
316
297
  // Skip function component created by React.memo
317
298
  SkipMemo: 1n << 64n,
@@ -327,6 +308,17 @@ var ERComponentHint = {
327
308
  SkipClassProperty: 1n << 69n
328
309
  };
329
310
  var DEFAULT_COMPONENT_HINT = 0n | ERComponentHint.SkipBooleanLiteral | ERComponentHint.SkipMapCallback | ERComponentHint.SkipNumberLiteral | ERComponentHint.SkipStringLiteral | ERComponentHint.SkipUndefined | ERComponentHint.SkipEmptyArray | ERComponentHint.StrictArray | ERComponentHint.StrictConditional | ERComponentHint.StrictLogical;
311
+ var COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR = [
312
+ "AssignmentExpression",
313
+ "[type]",
314
+ "[operator='=']",
315
+ "[left.type='MemberExpression']",
316
+ "[left.property.name='displayName']"
317
+ ].join("");
318
+ function isComponentDisplayNameAssignment(node) {
319
+ if (node == null) return false;
320
+ 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";
321
+ }
330
322
 
331
323
  // src/component/component-flag.ts
332
324
  var ERClassComponentFlag = {
@@ -393,10 +385,19 @@ function isPureComponent(node) {
393
385
 
394
386
  // src/component/component-lifecycle.ts
395
387
  function isComponentDidMount(node) {
396
- return AST8.isOneOf([AST_NODE_TYPES.MethodDefinition, AST_NODE_TYPES.PropertyDefinition])(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
388
+ return AST8.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidMount";
397
389
  }
398
390
  function isComponentWillUnmount(node) {
399
- return AST8.isOneOf([AST_NODE_TYPES.MethodDefinition, AST_NODE_TYPES.PropertyDefinition])(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillUnmount";
391
+ return AST8.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentWillUnmount";
392
+ }
393
+ function isComponentDidCatch(node) {
394
+ return AST8.isMethodOrProperty(node) && !node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "componentDidCatch";
395
+ }
396
+ function isGetDerivedStateFromError(node) {
397
+ return AST8.isMethodOrProperty(node) && node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromError";
398
+ }
399
+ function isGetDerivedStateFromProps(node) {
400
+ return AST8.isMethodOrProperty(node) && node.static && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "getDerivedStateFromProps";
400
401
  }
401
402
  function isFunctionOfComponentDidMount(node) {
402
403
  return AST8.isFunction(node) && isComponentDidMount(node.parent) && node.parent.value === node;
@@ -405,7 +406,7 @@ function isFunctionOfComponentWillUnmount(node) {
405
406
  return AST8.isFunction(node) && isComponentWillUnmount(node.parent) && node.parent.value === node;
406
407
  }
407
408
  function isRenderMethodLike(node) {
408
- return (node.type === AST_NODE_TYPES.MethodDefinition || node.type === AST_NODE_TYPES.PropertyDefinition) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "render" && node.parent.parent.type === AST_NODE_TYPES.ClassDeclaration;
409
+ return AST8.isMethodOrProperty(node) && node.key.type === AST_NODE_TYPES.Identifier && node.key.name === "render" && node.parent.parent.type === AST_NODE_TYPES.ClassDeclaration;
409
410
  }
410
411
  function isFunctionOfRenderMethod(node) {
411
412
  if (!isRenderMethodLike(node.parent)) {
@@ -425,9 +426,9 @@ function isComponentName(name) {
425
426
  return RE_COMPONENT_NAME.test(name);
426
427
  }
427
428
  function hasNoneOrValidComponentName(node, context) {
428
- const id2 = getFunctionComponentIdentifier(node, context);
429
- if (id2 == null) return true;
430
- const name = Array.isArray(id2) ? id2.at(-1)?.name : id2.name;
429
+ const id = getFunctionComponentIdentifier(node, context);
430
+ if (id == null) return true;
431
+ const name = Array.isArray(id) ? id.at(-1)?.name : id.name;
431
432
  return name != null && isComponentName(name);
432
433
  }
433
434
 
@@ -470,7 +471,6 @@ function getComponentFlag(initPath) {
470
471
  }
471
472
  return flag;
472
473
  }
473
- var displayNameAssignmentSelector = "AssignmentExpression[type][operator='='][left.type='MemberExpression'][left.property.name='displayName']";
474
474
  function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options = {}) {
475
475
  const { collectDisplayName = false, collectHookCalls = false } = options;
476
476
  const jsxCtx = { getScope: (node) => context.sourceCode.getScope(node) };
@@ -488,7 +488,7 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
488
488
  return functionEntries.pop();
489
489
  }
490
490
  const shouldDrop = AST8.getNestedReturnStatements(entry.node.body).slice().reverse().some((r) => {
491
- return context.sourceCode.getScope(r).block === entry.node && r.argument != null && !JSX4.isJSXValue(r.argument, jsxCtx, hint);
491
+ return context.sourceCode.getScope(r).block === entry.node && r.argument != null && !JSX3.isJSXValue(r.argument, jsxCtx, hint);
492
492
  });
493
493
  if (shouldDrop) {
494
494
  components.delete(entry.key);
@@ -514,16 +514,16 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
514
514
  return;
515
515
  }
516
516
  const { body } = entry.node;
517
- const isComponent = hasNoneOrValidComponentName(entry.node, context) && JSX4.isJSXValue(body, jsxCtx, hint) && hasValidHierarchy(entry.node, context, hint);
517
+ const isComponent = hasNoneOrValidComponentName(entry.node, context) && JSX3.isJSXValue(body, jsxCtx, hint) && hasValidHierarchy(entry.node, context, hint);
518
518
  if (!isComponent) {
519
519
  return;
520
520
  }
521
521
  const initPath = AST8.getFunctionInitPath(entry.node);
522
- const id2 = getFunctionComponentIdentifier(entry.node, context);
523
- const name = getComponentNameFromIdentifier(id2);
522
+ const id = getFunctionComponentIdentifier(entry.node, context);
523
+ const name = getComponentNameFromIdentifier(id);
524
524
  const key = getId();
525
525
  components.set(key, {
526
- id: id2,
526
+ id,
527
527
  key,
528
528
  kind: "function",
529
529
  name,
@@ -536,8 +536,9 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
536
536
  });
537
537
  },
538
538
  ...collectDisplayName ? {
539
- [displayNameAssignmentSelector](node) {
539
+ [COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR](node) {
540
540
  const { left, right } = node;
541
+ if (left.type !== AST_NODE_TYPES.MemberExpression) return;
541
542
  const componentName = left.object.type === AST_NODE_TYPES.Identifier ? left.object.name : _;
542
543
  const component = [...components.values()].findLast(({ name }) => name != null && name === componentName);
543
544
  if (component == null) {
@@ -563,17 +564,17 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
563
564
  if (entry == null) {
564
565
  return;
565
566
  }
566
- const isComponent = hasNoneOrValidComponentName(entry.node, context) && JSX4.isJSXValue(node.argument, jsxCtx, hint) && hasValidHierarchy(entry.node, context, hint);
567
+ const isComponent = hasNoneOrValidComponentName(entry.node, context) && JSX3.isJSXValue(node.argument, jsxCtx, hint) && hasValidHierarchy(entry.node, context, hint);
567
568
  if (!isComponent) {
568
569
  return;
569
570
  }
570
571
  functionEntries.pop();
571
572
  functionEntries.push({ ...entry, isComponent });
572
573
  const initPath = AST8.getFunctionInitPath(entry.node);
573
- const id2 = getFunctionComponentIdentifier(entry.node, context);
574
- const name = getComponentNameFromIdentifier(id2);
574
+ const id = getFunctionComponentIdentifier(entry.node, context);
575
+ const name = getComponentNameFromIdentifier(id);
575
576
  components.set(entry.key, {
576
- id: id2,
577
+ id,
577
578
  key: entry.key,
578
579
  kind: "function",
579
580
  name,
@@ -600,16 +601,16 @@ function useComponentCollectorLegacy() {
600
601
  if (!isClassComponent(node)) {
601
602
  return;
602
603
  }
603
- const id2 = AST8.getClassIdentifier(node);
604
+ const id = AST8.getClassIdentifier(node);
604
605
  const key = getId();
605
606
  const flag = isPureComponent(node) ? ERClassComponentFlag.PureComponent : ERClassComponentFlag.None;
606
607
  components.set(
607
608
  key,
608
609
  {
609
- id: id2,
610
+ id,
610
611
  key,
611
612
  kind: "class",
612
- name: id2?.name,
613
+ name: id?.name,
613
614
  node,
614
615
  // TODO: Get displayName of class component
615
616
  displayName: _,
@@ -636,12 +637,12 @@ function isRenderFunctionLoose(node, context) {
636
637
  if (AST8.getFunctionIdentifier(node)?.name.startsWith("render")) {
637
638
  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");
638
639
  }
639
- return JSX4.isJSXValue(
640
+ return JSX3.isJSXValue(
640
641
  body,
641
642
  {
642
643
  getScope: (node2) => context.sourceCode.getScope(node2)
643
644
  },
644
- JSX4.JSXValueHint.SkipNullLiteral | JSX4.JSXValueHint.SkipUndefined | JSX4.JSXValueHint.StrictLogical | JSX4.JSXValueHint.StrictConditional
645
+ JSX3.JSXValueHint.SkipNullLiteral | JSX3.JSXValueHint.SkipUndefined | JSX3.JSXValueHint.StrictLogical | JSX3.JSXValueHint.StrictConditional
645
646
  );
646
647
  }
647
648
  function isRenderPropLoose(node, context) {
@@ -681,4 +682,4 @@ function isFunctionOfUseEffectCleanup(node) {
681
682
  return nearFunction === nearFunctionOfReturn && isFunctionOfUseEffectSetup(nearFunction);
682
683
  }
683
684
 
684
- export { DEFAULT_COMPONENT_HINT, ERClassComponentFlag, ERComponentHint, ERFunctionComponentFlag, ERPhaseRelevance, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getElementNameOnJsxAndHtml, getFunctionComponentIdentifier, getId, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidMount, isComponentName, isComponentWillUnmount, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactMember, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, 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 };
685
+ export { COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR, DEFAULT_COMPONENT_HINT, ERClassComponentFlag, ERComponentHint, ERFunctionComponentFlag, 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "1.24.0-next.8",
3
+ "version": "1.24.0",
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": {
@@ -38,12 +38,12 @@
38
38
  "@typescript-eslint/types": "^8.20.0",
39
39
  "@typescript-eslint/utils": "^8.20.0",
40
40
  "birecord": "^0.1.1",
41
- "ts-pattern": "^5.6.0",
42
- "@eslint-react/eff": "1.24.0-next.8",
43
- "@eslint-react/ast": "1.24.0-next.8",
44
- "@eslint-react/jsx": "1.24.0-next.8",
45
- "@eslint-react/shared": "1.24.0-next.8",
46
- "@eslint-react/var": "1.24.0-next.8"
41
+ "ts-pattern": "^5.6.1",
42
+ "@eslint-react/ast": "1.24.0",
43
+ "@eslint-react/var": "1.24.0",
44
+ "@eslint-react/jsx": "1.24.0",
45
+ "@eslint-react/shared": "1.24.0",
46
+ "@eslint-react/eff": "1.24.0"
47
47
  },
48
48
  "devDependencies": {
49
49
  "tsup": "^8.3.5",