@eslint-react/core 1.39.0-beta.0 → 1.39.0-beta.2

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
@@ -6,11 +6,11 @@ import { _ } from '@eslint-react/eff';
6
6
  import * as birecord from 'birecord';
7
7
  import { Scope } from '@typescript-eslint/scope-manager';
8
8
 
9
- type ERComponentHint = bigint;
9
+ type ComponentCollectorHint = bigint;
10
10
  /**
11
- * hints for component collector
11
+ * Hints for component collector
12
12
  */
13
- declare const ERComponentHint: {
13
+ declare const ComponentCollectorHint: {
14
14
  /**
15
15
  * Skip function component created by React.memo
16
16
  */
@@ -48,9 +48,12 @@ declare const ERComponentHint: {
48
48
  readonly StrictLogical: bigint;
49
49
  readonly StrictConditional: bigint;
50
50
  };
51
+ /**
52
+ * Default component collector hint
53
+ */
51
54
  declare const DEFAULT_COMPONENT_HINT: bigint;
52
55
 
53
- interface ERSemanticNode {
56
+ interface SemanticNode {
54
57
  id: _ | TSESTree.Identifier | TSESTree.Identifier[];
55
58
  key: string;
56
59
  kind: string;
@@ -60,8 +63,8 @@ interface ERSemanticNode {
60
63
  hint: bigint;
61
64
  }
62
65
 
63
- type ERComponentFlag = bigint;
64
- declare const ERComponentFlag: {
66
+ type ComponentFlag = bigint;
67
+ declare const ComponentFlag: {
65
68
  None: bigint;
66
69
  PureComponent: bigint;
67
70
  CreateElement: bigint;
@@ -70,26 +73,26 @@ declare const ERComponentFlag: {
70
73
  Async: bigint;
71
74
  };
72
75
 
73
- interface ERFunctionComponent extends ERSemanticNode {
76
+ interface FunctionComponent extends SemanticNode {
74
77
  id: _ | TSESTree.Identifier | TSESTree.Identifier[];
75
78
  kind: "function";
76
79
  node: AST.TSESTreeFunction;
77
- flag: ERComponentFlag;
78
- hint: ERComponentHint;
80
+ flag: ComponentFlag;
81
+ hint: ComponentCollectorHint;
79
82
  initPath: _ | AST.FunctionInitPath;
80
83
  hookCalls: TSESTree.CallExpression[];
81
84
  displayName: _ | TSESTree.Expression;
82
85
  }
83
- interface ERClassComponent extends ERSemanticNode {
86
+ interface ClassComponent extends SemanticNode {
84
87
  id: _ | TSESTree.Identifier;
85
88
  kind: "class";
86
89
  node: AST.TSESTreeClass;
87
- flag: ERComponentFlag;
88
- hint: ERComponentHint;
90
+ flag: ComponentFlag;
91
+ hint: ComponentCollectorHint;
89
92
  methods: AST.TSESTreeMethodOrProperty[];
90
93
  displayName: _ | TSESTree.Expression;
91
94
  }
92
- type ERComponent = ERClassComponent | ERFunctionComponent;
95
+ type Component = ClassComponent | FunctionComponent;
93
96
 
94
97
  type FunctionEntry = {
95
98
  key: string;
@@ -101,11 +104,11 @@ declare namespace useComponentCollector {
101
104
  type Options = {
102
105
  collectDisplayName?: boolean;
103
106
  collectHookCalls?: boolean;
104
- hint?: ERComponentHint;
107
+ hint?: ComponentCollectorHint;
105
108
  };
106
109
  type ReturnType = {
107
110
  ctx: {
108
- getAllComponents: (node: TSESTree.Program) => Map<string, ERFunctionComponent>;
111
+ getAllComponents: (node: TSESTree.Program) => Map<string, FunctionComponent>;
109
112
  getCurrentEntries: () => FunctionEntry[];
110
113
  getCurrentEntry: () => FunctionEntry | _;
111
114
  };
@@ -123,20 +126,22 @@ declare function useComponentCollector(context: RuleContext, options?: useCompon
123
126
  declare namespace useComponentCollectorLegacy {
124
127
  type ReturnType = {
125
128
  ctx: {
126
- getAllComponents: (node: TSESTree$1.Program) => Map<string, ERClassComponent>;
129
+ getAllComponents: (node: TSESTree$1.Program) => Map<string, ClassComponent>;
127
130
  };
128
131
  listeners: ESLintUtils.RuleListener;
129
132
  };
130
133
  }
131
134
  /**
132
- * Get a ctx and listeners for the rule to collect class components
135
+ * Get a ctx and listeners object for the rule to collect class components
133
136
  * @returns The context and listeners for the rule
134
137
  */
135
138
  declare function useComponentCollectorLegacy(): useComponentCollectorLegacy.ReturnType;
136
139
 
137
140
  declare function getFunctionComponentId(context: RuleContext, node: AST.TSESTreeFunction): TSESTree.Identifier | TSESTree.Identifier[] | _;
138
141
 
139
- type ERComponentKind = "classComponent" | "functionComponent";
142
+ declare function getComponentFlagFromInitPath(initPath: FunctionComponent["initPath"]): bigint;
143
+
144
+ type ComponentKind = "classComponent" | "functionComponent";
140
145
 
141
146
  declare function isComponentDidMount(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
142
147
  declare function isComponentWillUnmount(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
@@ -147,22 +152,6 @@ declare function isFunctionOfComponentDidMount(node: TSESTree.Node): boolean;
147
152
  declare function isFunctionOfComponentWillUnmount(node: TSESTree.Node): boolean;
148
153
  declare function isRenderMethodLike(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
149
154
  declare function isFunctionOfRenderMethod(node: AST.TSESTreeFunction): boolean;
150
- /**
151
- * Check whether given node is declared inside class component's render block
152
- * ```tsx
153
- * class Component extends React.Component {
154
- * render() {
155
- * class NestedClassComponent extends React.Component {
156
- * render() { return <div />; }
157
- * }
158
- * const nestedFunctionComponent = () => <div />;
159
- * }
160
- * }
161
- * ```
162
- * @param node The AST node being checked
163
- * @returns `true` if node is inside class component's render block, `false` if not
164
- */
165
- declare function isInsideRenderMethod(node: TSESTree.Node): boolean;
166
155
 
167
156
  declare const RE_COMPONENT_NAME: RegExp;
168
157
  declare const RE_COMPONENT_NAME_LOOSE: RegExp;
@@ -171,16 +160,16 @@ declare function isComponentNameLoose(name: string): boolean;
171
160
  declare function getComponentNameFromId(id: TSESTree.Identifier | TSESTree.Identifier[] | _): string | undefined;
172
161
  declare function hasNoneOrLooseComponentName(context: RuleContext, fn: AST.TSESTreeFunction): boolean;
173
162
 
174
- type EREffectPhaseKind = "cleanup" | "setup";
175
- type ERLifecyclePhaseKind = "mount" | "unmount";
176
- type ERPhaseKind = EREffectPhaseKind | ERLifecyclePhaseKind;
177
- declare const ERPhaseRelevance: birecord.BiRecord<{
163
+ type ComponentEffectPhaseKind = "cleanup" | "setup";
164
+ type ComponentLifecyclePhaseKind = "mount" | "unmount";
165
+ type ComponentPhaseKind = ComponentEffectPhaseKind | ComponentLifecyclePhaseKind;
166
+ declare const ComponentPhaseRelevance: birecord.BiRecord<{
178
167
  readonly mount: "unmount";
179
168
  readonly setup: "cleanup";
180
169
  }>;
181
170
  declare const isInversePhase: {
182
- (a: ERPhaseKind): (b: ERPhaseKind) => boolean;
183
- (a: ERPhaseKind, b: ERPhaseKind): boolean;
171
+ (a: ComponentPhaseKind): (b: ComponentPhaseKind) => boolean;
172
+ (a: ComponentPhaseKind, b: ComponentPhaseKind): boolean;
184
173
  };
185
174
 
186
175
  /**
@@ -233,12 +222,48 @@ declare function isDirectValueOfRenderPropertyLoose(node: TSESTree.Node): boolea
233
222
  */
234
223
  declare function isDeclaredInRenderPropLoose(node: TSESTree.Node): boolean;
235
224
 
236
- type ERStateKind = "actionState" | "state";
225
+ type ComponentStateKind = "actionState" | "state";
237
226
  declare function isThisSetState(node: TSESTree.CallExpression): boolean;
238
227
  declare function isAssignmentToThisState(node: TSESTree.AssignmentExpression): boolean;
239
228
 
240
- /** @internal */
241
- declare function hasValidHierarchy(context: RuleContext, node: AST.TSESTreeFunction, hint: bigint): boolean;
229
+ /**
230
+ * Check if the node is a call expression for a component wrapper
231
+ * @param context The ESLint rule context
232
+ * @param node The node to check
233
+ * @returns `true` if the node is a call expression for a component wrapper
234
+ */
235
+ declare function isComponentWrapperCall(context: RuleContext, node: TSESTree.Node): boolean;
236
+ /**
237
+ * Check if the node is a call expression for a component wrapper loosely
238
+ * @param context The ESLint rule context
239
+ * @param node The node to check
240
+ * @returns `true` if the node is a call expression for a component wrapper loosely
241
+ */
242
+ declare function isComponentWrapperCallLoose(context: RuleContext, node: TSESTree.Node): boolean;
243
+
244
+ /**
245
+ * Determines whether inside `createElement`'s children.
246
+ * @param context The rule context
247
+ * @param node The AST node to check
248
+ * @returns `true` if the node is inside createElement's children
249
+ */
250
+ declare function isChildrenOfCreateElement(context: RuleContext, node: TSESTree.Node): boolean;
251
+ /**
252
+ * Check whether given node is declared inside class component's render block
253
+ * ```tsx
254
+ * class Component extends React.Component {
255
+ * render() {
256
+ * class NestedClassComponent extends React.Component {
257
+ * render() { return <div />; }
258
+ * }
259
+ * const nestedFunctionComponent = () => <div />;
260
+ * }
261
+ * }
262
+ * ```
263
+ * @param node The AST node being checked
264
+ * @returns `true` if node is inside class component's render block, `false` if not
265
+ */
266
+ declare function isInsideRenderMethod(node: TSESTree.Node): boolean;
242
267
 
243
268
  /**
244
269
  * Check if a node is a React class component
@@ -258,12 +283,12 @@ declare function isPureComponent(node: TSESTree.Node): boolean;
258
283
  */
259
284
  declare const DISPLAY_NAME_ASSIGNMENT_SELECTOR: string;
260
285
 
261
- type EREffectKind = "useEffect" | "useLayoutEffect" | "useInsertionEffect";
286
+ type EffectKind = "useEffect" | "useLayoutEffect" | "useInsertionEffect";
262
287
 
263
288
  declare function isFunctionOfUseEffectSetup(node: TSESTree.Node | _): boolean;
264
289
  declare function isFunctionOfUseEffectCleanup(node: TSESTree.Node | _): boolean;
265
290
 
266
- interface ERHook extends ERSemanticNode {
291
+ interface Hook extends SemanticNode {
267
292
  id: TSESTree.Identifier | _;
268
293
  node: AST.TSESTreeFunction;
269
294
  name: string;
@@ -273,14 +298,14 @@ interface ERHook extends ERSemanticNode {
273
298
  declare namespace useHookCollector {
274
299
  type ReturnType = {
275
300
  ctx: {
276
- getAllHooks(node: TSESTree$1.Program): Map<string, ERHook>;
301
+ getAllHooks(node: TSESTree$1.Program): Map<string, Hook>;
277
302
  };
278
303
  listeners: ESLintUtils.RuleListener;
279
304
  };
280
305
  }
281
306
  declare function useHookCollector(): useHookCollector.ReturnType;
282
307
 
283
- type ERHookKind = "custom" | "useActionState" | "useCallback" | "useContext" | "useDebugValue" | "useDeferredValue" | "useEffect" | "useId" | "useImperativeHandle" | "useInsertionEffect" | "useLayoutEffect" | "useMemo" | "useOptimistic" | "useReducer" | "useRef" | "useState" | "useSyncExternalStore" | "useTransition";
308
+ type HookKind = "custom" | "useActionState" | "useCallback" | "useContext" | "useDebugValue" | "useDeferredValue" | "useEffect" | "useId" | "useImperativeHandle" | "useInsertionEffect" | "useLayoutEffect" | "useMemo" | "useOptimistic" | "useReducer" | "useRef" | "useState" | "useSyncExternalStore" | "useTransition";
284
309
 
285
310
  declare const RE_HOOK_NAME: RegExp;
286
311
  declare function isReactHookName(name: string): boolean;
@@ -317,9 +342,9 @@ declare const isUseStateCall: (context: RuleContext, node: TSESTree.Node | undef
317
342
  declare const isUseSyncExternalStoreCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
318
343
  declare const isUseTransitionCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
319
344
 
320
- interface ERSemanticEntry {
345
+ interface SemanticEntry {
321
346
  node: TSESTree.Node;
322
- phase: ERPhaseKind;
347
+ phase: ComponentPhaseKind;
323
348
  }
324
349
 
325
350
  /** @internal */
@@ -391,4 +416,4 @@ declare const isCreateRefCall: isCallFromReact.ReturnType;
391
416
  declare const isForwardRefCall: isCallFromReact.ReturnType;
392
417
  declare const isMemoCall: isCallFromReact.ReturnType;
393
418
 
394
- 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_COMPONENT_NAME_LOOSE, RE_HOOK_NAME, getComponentNameFromId, getFunctionComponentId, getInstanceId, hasNoneOrLooseComponentName, hasValidHierarchy, isAssignmentToThisState, isCallFromReact, isCallFromReactObject, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentName, isComponentNameLoose, isComponentWillUnmount, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactLoose, isFromReactObject, isFromReactStrict, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInsideRenderMethod, isInstanceIdEqual, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isReactHookNameLoose, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isThisSetState, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
419
+ export { type ClassComponent, type Component, ComponentCollectorHint, type ComponentEffectPhaseKind, ComponentFlag, type ComponentKind, type ComponentLifecyclePhaseKind, type ComponentPhaseKind, ComponentPhaseRelevance, type ComponentStateKind, DEFAULT_COMPONENT_HINT, DISPLAY_NAME_ASSIGNMENT_SELECTOR, type EffectKind, type FunctionComponent, type Hook, type HookKind, RE_COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE, RE_HOOK_NAME, type SemanticEntry, type SemanticNode, getComponentFlagFromInitPath, getComponentNameFromId, getFunctionComponentId, getInstanceId, hasNoneOrLooseComponentName, isAssignmentToThisState, isCallFromReact, isCallFromReactObject, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentName, isComponentNameLoose, isComponentWillUnmount, isComponentWrapperCall, isComponentWrapperCallLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactLoose, isFromReactObject, isFromReactStrict, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInsideRenderMethod, isInstanceIdEqual, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isReactHookNameLoose, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isThisSetState, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
package/dist/index.d.ts CHANGED
@@ -6,11 +6,11 @@ import { _ } from '@eslint-react/eff';
6
6
  import * as birecord from 'birecord';
7
7
  import { Scope } from '@typescript-eslint/scope-manager';
8
8
 
9
- type ERComponentHint = bigint;
9
+ type ComponentCollectorHint = bigint;
10
10
  /**
11
- * hints for component collector
11
+ * Hints for component collector
12
12
  */
13
- declare const ERComponentHint: {
13
+ declare const ComponentCollectorHint: {
14
14
  /**
15
15
  * Skip function component created by React.memo
16
16
  */
@@ -48,9 +48,12 @@ declare const ERComponentHint: {
48
48
  readonly StrictLogical: bigint;
49
49
  readonly StrictConditional: bigint;
50
50
  };
51
+ /**
52
+ * Default component collector hint
53
+ */
51
54
  declare const DEFAULT_COMPONENT_HINT: bigint;
52
55
 
53
- interface ERSemanticNode {
56
+ interface SemanticNode {
54
57
  id: _ | TSESTree.Identifier | TSESTree.Identifier[];
55
58
  key: string;
56
59
  kind: string;
@@ -60,8 +63,8 @@ interface ERSemanticNode {
60
63
  hint: bigint;
61
64
  }
62
65
 
63
- type ERComponentFlag = bigint;
64
- declare const ERComponentFlag: {
66
+ type ComponentFlag = bigint;
67
+ declare const ComponentFlag: {
65
68
  None: bigint;
66
69
  PureComponent: bigint;
67
70
  CreateElement: bigint;
@@ -70,26 +73,26 @@ declare const ERComponentFlag: {
70
73
  Async: bigint;
71
74
  };
72
75
 
73
- interface ERFunctionComponent extends ERSemanticNode {
76
+ interface FunctionComponent extends SemanticNode {
74
77
  id: _ | TSESTree.Identifier | TSESTree.Identifier[];
75
78
  kind: "function";
76
79
  node: AST.TSESTreeFunction;
77
- flag: ERComponentFlag;
78
- hint: ERComponentHint;
80
+ flag: ComponentFlag;
81
+ hint: ComponentCollectorHint;
79
82
  initPath: _ | AST.FunctionInitPath;
80
83
  hookCalls: TSESTree.CallExpression[];
81
84
  displayName: _ | TSESTree.Expression;
82
85
  }
83
- interface ERClassComponent extends ERSemanticNode {
86
+ interface ClassComponent extends SemanticNode {
84
87
  id: _ | TSESTree.Identifier;
85
88
  kind: "class";
86
89
  node: AST.TSESTreeClass;
87
- flag: ERComponentFlag;
88
- hint: ERComponentHint;
90
+ flag: ComponentFlag;
91
+ hint: ComponentCollectorHint;
89
92
  methods: AST.TSESTreeMethodOrProperty[];
90
93
  displayName: _ | TSESTree.Expression;
91
94
  }
92
- type ERComponent = ERClassComponent | ERFunctionComponent;
95
+ type Component = ClassComponent | FunctionComponent;
93
96
 
94
97
  type FunctionEntry = {
95
98
  key: string;
@@ -101,11 +104,11 @@ declare namespace useComponentCollector {
101
104
  type Options = {
102
105
  collectDisplayName?: boolean;
103
106
  collectHookCalls?: boolean;
104
- hint?: ERComponentHint;
107
+ hint?: ComponentCollectorHint;
105
108
  };
106
109
  type ReturnType = {
107
110
  ctx: {
108
- getAllComponents: (node: TSESTree.Program) => Map<string, ERFunctionComponent>;
111
+ getAllComponents: (node: TSESTree.Program) => Map<string, FunctionComponent>;
109
112
  getCurrentEntries: () => FunctionEntry[];
110
113
  getCurrentEntry: () => FunctionEntry | _;
111
114
  };
@@ -123,20 +126,22 @@ declare function useComponentCollector(context: RuleContext, options?: useCompon
123
126
  declare namespace useComponentCollectorLegacy {
124
127
  type ReturnType = {
125
128
  ctx: {
126
- getAllComponents: (node: TSESTree$1.Program) => Map<string, ERClassComponent>;
129
+ getAllComponents: (node: TSESTree$1.Program) => Map<string, ClassComponent>;
127
130
  };
128
131
  listeners: ESLintUtils.RuleListener;
129
132
  };
130
133
  }
131
134
  /**
132
- * Get a ctx and listeners for the rule to collect class components
135
+ * Get a ctx and listeners object for the rule to collect class components
133
136
  * @returns The context and listeners for the rule
134
137
  */
135
138
  declare function useComponentCollectorLegacy(): useComponentCollectorLegacy.ReturnType;
136
139
 
137
140
  declare function getFunctionComponentId(context: RuleContext, node: AST.TSESTreeFunction): TSESTree.Identifier | TSESTree.Identifier[] | _;
138
141
 
139
- type ERComponentKind = "classComponent" | "functionComponent";
142
+ declare function getComponentFlagFromInitPath(initPath: FunctionComponent["initPath"]): bigint;
143
+
144
+ type ComponentKind = "classComponent" | "functionComponent";
140
145
 
141
146
  declare function isComponentDidMount(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
142
147
  declare function isComponentWillUnmount(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
@@ -147,22 +152,6 @@ declare function isFunctionOfComponentDidMount(node: TSESTree.Node): boolean;
147
152
  declare function isFunctionOfComponentWillUnmount(node: TSESTree.Node): boolean;
148
153
  declare function isRenderMethodLike(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
149
154
  declare function isFunctionOfRenderMethod(node: AST.TSESTreeFunction): boolean;
150
- /**
151
- * Check whether given node is declared inside class component's render block
152
- * ```tsx
153
- * class Component extends React.Component {
154
- * render() {
155
- * class NestedClassComponent extends React.Component {
156
- * render() { return <div />; }
157
- * }
158
- * const nestedFunctionComponent = () => <div />;
159
- * }
160
- * }
161
- * ```
162
- * @param node The AST node being checked
163
- * @returns `true` if node is inside class component's render block, `false` if not
164
- */
165
- declare function isInsideRenderMethod(node: TSESTree.Node): boolean;
166
155
 
167
156
  declare const RE_COMPONENT_NAME: RegExp;
168
157
  declare const RE_COMPONENT_NAME_LOOSE: RegExp;
@@ -171,16 +160,16 @@ declare function isComponentNameLoose(name: string): boolean;
171
160
  declare function getComponentNameFromId(id: TSESTree.Identifier | TSESTree.Identifier[] | _): string | undefined;
172
161
  declare function hasNoneOrLooseComponentName(context: RuleContext, fn: AST.TSESTreeFunction): boolean;
173
162
 
174
- type EREffectPhaseKind = "cleanup" | "setup";
175
- type ERLifecyclePhaseKind = "mount" | "unmount";
176
- type ERPhaseKind = EREffectPhaseKind | ERLifecyclePhaseKind;
177
- declare const ERPhaseRelevance: birecord.BiRecord<{
163
+ type ComponentEffectPhaseKind = "cleanup" | "setup";
164
+ type ComponentLifecyclePhaseKind = "mount" | "unmount";
165
+ type ComponentPhaseKind = ComponentEffectPhaseKind | ComponentLifecyclePhaseKind;
166
+ declare const ComponentPhaseRelevance: birecord.BiRecord<{
178
167
  readonly mount: "unmount";
179
168
  readonly setup: "cleanup";
180
169
  }>;
181
170
  declare const isInversePhase: {
182
- (a: ERPhaseKind): (b: ERPhaseKind) => boolean;
183
- (a: ERPhaseKind, b: ERPhaseKind): boolean;
171
+ (a: ComponentPhaseKind): (b: ComponentPhaseKind) => boolean;
172
+ (a: ComponentPhaseKind, b: ComponentPhaseKind): boolean;
184
173
  };
185
174
 
186
175
  /**
@@ -233,12 +222,48 @@ declare function isDirectValueOfRenderPropertyLoose(node: TSESTree.Node): boolea
233
222
  */
234
223
  declare function isDeclaredInRenderPropLoose(node: TSESTree.Node): boolean;
235
224
 
236
- type ERStateKind = "actionState" | "state";
225
+ type ComponentStateKind = "actionState" | "state";
237
226
  declare function isThisSetState(node: TSESTree.CallExpression): boolean;
238
227
  declare function isAssignmentToThisState(node: TSESTree.AssignmentExpression): boolean;
239
228
 
240
- /** @internal */
241
- declare function hasValidHierarchy(context: RuleContext, node: AST.TSESTreeFunction, hint: bigint): boolean;
229
+ /**
230
+ * Check if the node is a call expression for a component wrapper
231
+ * @param context The ESLint rule context
232
+ * @param node The node to check
233
+ * @returns `true` if the node is a call expression for a component wrapper
234
+ */
235
+ declare function isComponentWrapperCall(context: RuleContext, node: TSESTree.Node): boolean;
236
+ /**
237
+ * Check if the node is a call expression for a component wrapper loosely
238
+ * @param context The ESLint rule context
239
+ * @param node The node to check
240
+ * @returns `true` if the node is a call expression for a component wrapper loosely
241
+ */
242
+ declare function isComponentWrapperCallLoose(context: RuleContext, node: TSESTree.Node): boolean;
243
+
244
+ /**
245
+ * Determines whether inside `createElement`'s children.
246
+ * @param context The rule context
247
+ * @param node The AST node to check
248
+ * @returns `true` if the node is inside createElement's children
249
+ */
250
+ declare function isChildrenOfCreateElement(context: RuleContext, node: TSESTree.Node): boolean;
251
+ /**
252
+ * Check whether given node is declared inside class component's render block
253
+ * ```tsx
254
+ * class Component extends React.Component {
255
+ * render() {
256
+ * class NestedClassComponent extends React.Component {
257
+ * render() { return <div />; }
258
+ * }
259
+ * const nestedFunctionComponent = () => <div />;
260
+ * }
261
+ * }
262
+ * ```
263
+ * @param node The AST node being checked
264
+ * @returns `true` if node is inside class component's render block, `false` if not
265
+ */
266
+ declare function isInsideRenderMethod(node: TSESTree.Node): boolean;
242
267
 
243
268
  /**
244
269
  * Check if a node is a React class component
@@ -258,12 +283,12 @@ declare function isPureComponent(node: TSESTree.Node): boolean;
258
283
  */
259
284
  declare const DISPLAY_NAME_ASSIGNMENT_SELECTOR: string;
260
285
 
261
- type EREffectKind = "useEffect" | "useLayoutEffect" | "useInsertionEffect";
286
+ type EffectKind = "useEffect" | "useLayoutEffect" | "useInsertionEffect";
262
287
 
263
288
  declare function isFunctionOfUseEffectSetup(node: TSESTree.Node | _): boolean;
264
289
  declare function isFunctionOfUseEffectCleanup(node: TSESTree.Node | _): boolean;
265
290
 
266
- interface ERHook extends ERSemanticNode {
291
+ interface Hook extends SemanticNode {
267
292
  id: TSESTree.Identifier | _;
268
293
  node: AST.TSESTreeFunction;
269
294
  name: string;
@@ -273,14 +298,14 @@ interface ERHook extends ERSemanticNode {
273
298
  declare namespace useHookCollector {
274
299
  type ReturnType = {
275
300
  ctx: {
276
- getAllHooks(node: TSESTree$1.Program): Map<string, ERHook>;
301
+ getAllHooks(node: TSESTree$1.Program): Map<string, Hook>;
277
302
  };
278
303
  listeners: ESLintUtils.RuleListener;
279
304
  };
280
305
  }
281
306
  declare function useHookCollector(): useHookCollector.ReturnType;
282
307
 
283
- type ERHookKind = "custom" | "useActionState" | "useCallback" | "useContext" | "useDebugValue" | "useDeferredValue" | "useEffect" | "useId" | "useImperativeHandle" | "useInsertionEffect" | "useLayoutEffect" | "useMemo" | "useOptimistic" | "useReducer" | "useRef" | "useState" | "useSyncExternalStore" | "useTransition";
308
+ type HookKind = "custom" | "useActionState" | "useCallback" | "useContext" | "useDebugValue" | "useDeferredValue" | "useEffect" | "useId" | "useImperativeHandle" | "useInsertionEffect" | "useLayoutEffect" | "useMemo" | "useOptimistic" | "useReducer" | "useRef" | "useState" | "useSyncExternalStore" | "useTransition";
284
309
 
285
310
  declare const RE_HOOK_NAME: RegExp;
286
311
  declare function isReactHookName(name: string): boolean;
@@ -317,9 +342,9 @@ declare const isUseStateCall: (context: RuleContext, node: TSESTree.Node | undef
317
342
  declare const isUseSyncExternalStoreCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
318
343
  declare const isUseTransitionCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
319
344
 
320
- interface ERSemanticEntry {
345
+ interface SemanticEntry {
321
346
  node: TSESTree.Node;
322
- phase: ERPhaseKind;
347
+ phase: ComponentPhaseKind;
323
348
  }
324
349
 
325
350
  /** @internal */
@@ -391,4 +416,4 @@ declare const isCreateRefCall: isCallFromReact.ReturnType;
391
416
  declare const isForwardRefCall: isCallFromReact.ReturnType;
392
417
  declare const isMemoCall: isCallFromReact.ReturnType;
393
418
 
394
- 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_COMPONENT_NAME_LOOSE, RE_HOOK_NAME, getComponentNameFromId, getFunctionComponentId, getInstanceId, hasNoneOrLooseComponentName, hasValidHierarchy, isAssignmentToThisState, isCallFromReact, isCallFromReactObject, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentName, isComponentNameLoose, isComponentWillUnmount, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactLoose, isFromReactObject, isFromReactStrict, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInsideRenderMethod, isInstanceIdEqual, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isReactHookNameLoose, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isThisSetState, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
419
+ export { type ClassComponent, type Component, ComponentCollectorHint, type ComponentEffectPhaseKind, ComponentFlag, type ComponentKind, type ComponentLifecyclePhaseKind, type ComponentPhaseKind, ComponentPhaseRelevance, type ComponentStateKind, DEFAULT_COMPONENT_HINT, DISPLAY_NAME_ASSIGNMENT_SELECTOR, type EffectKind, type FunctionComponent, type Hook, type HookKind, RE_COMPONENT_NAME, RE_COMPONENT_NAME_LOOSE, RE_HOOK_NAME, type SemanticEntry, type SemanticNode, getComponentFlagFromInitPath, getComponentNameFromId, getFunctionComponentId, getInstanceId, hasNoneOrLooseComponentName, isAssignmentToThisState, isCallFromReact, isCallFromReactObject, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentName, isComponentNameLoose, isComponentWillUnmount, isComponentWrapperCall, isComponentWrapperCallLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactLoose, isFromReactObject, isFromReactStrict, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInsideRenderMethod, isInstanceIdEqual, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isReactHookNameLoose, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isThisSetState, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };