@eslint-react/core 4.2.4-beta.0 → 5.0.0-beta.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.
Files changed (3) hide show
  1. package/dist/index.d.ts +444 -386
  2. package/dist/index.js +539 -524
  3. package/package.json +5 -5
package/dist/index.d.ts CHANGED
@@ -1,19 +1,36 @@
1
1
  import * as ast from "@eslint-react/ast";
2
2
  import { TSESTree } from "@typescript-eslint/types";
3
+ import { SemanticNode as SemanticNode$1 } from "@eslint-react/core";
3
4
  import { RegExpLike, RuleContext } from "@eslint-react/shared";
4
- import { Scope } from "@typescript-eslint/scope-manager";
5
5
  import { ESLintUtils, TSESTree as TSESTree$1 } from "@typescript-eslint/utils";
6
+ import ts from "typescript";
7
+ import { Scope } from "@typescript-eslint/scope-manager";
6
8
 
7
- //#region src/api/find-import-source.d.ts
9
+ //#region src/api.d.ts
10
+ declare namespace isAPI {
11
+ type ReturnType = {
12
+ (context: RuleContext, node: null | TSESTree.Node): boolean;
13
+ (context: RuleContext): (node: null | TSESTree.Node) => boolean;
14
+ };
15
+ }
8
16
  /**
9
- * Find the import source of a variable
10
- * @param name The variable name
11
- * @param initialScope The initial scope to search
12
- * @returns The import source or null if not found
17
+ * Check if the node is a React API identifier or member expression
18
+ * @param api The React API name to check against (ex: "useState", "React.memo")
19
+ * @returns A predicate function to check if a node matches the API
13
20
  */
14
- declare function findImportSource(name: string, initialScope: Scope): string | null;
15
- //#endregion
16
- //#region src/api/is-from-react.d.ts
21
+ declare function isAPI(api: string): isAPI.ReturnType;
22
+ declare namespace isAPICall {
23
+ type ReturnType = {
24
+ (context: RuleContext, node: null | TSESTree.Node): node is TSESTree.CallExpression;
25
+ (context: RuleContext): (node: null | TSESTree.Node) => node is TSESTree.CallExpression;
26
+ };
27
+ }
28
+ /**
29
+ * Check if the node is a call expression to a specific React API
30
+ * @param api The React API name to check against
31
+ * @returns A predicate function to check if a node is a call to the API
32
+ */
33
+ declare function isAPICall(api: string): isAPICall.ReturnType;
17
34
  /**
18
35
  * Check if a variable is initialized from React import
19
36
  * @param name The variable name
@@ -21,9 +38,7 @@ declare function findImportSource(name: string, initialScope: Scope): string | n
21
38
  * @param importSource Alternative import source of React (ex: "preact/compat")
22
39
  * @returns True if the variable is initialized or derived from React import
23
40
  */
24
- declare function isInitializedFromReact(name: string, initialScope: Scope, importSource?: string): boolean;
25
- //#endregion
26
- //#region src/api/is-from-react-native.d.ts
41
+ declare function isAPIFromReact(name: string, initialScope: Scope, importSource?: string): boolean;
27
42
  /**
28
43
  * if a variable is initialized from React Native import
29
44
  * @param name The variable name
@@ -31,102 +46,174 @@ declare function isInitializedFromReact(name: string, initialScope: Scope, impor
31
46
  * @param importSource Alternative import source of React Native (ex: "react-native-web")
32
47
  * @returns True if the variable is initialized from React Native import
33
48
  */
34
- declare function isInitializedFromReactNative(name: string, initialScope: Scope, importSource?: string): boolean;
49
+ declare function isAPIFromReactNative(name: string, initialScope: Scope, importSource?: string): boolean;
50
+ declare const isCaptureOwnerStack: isAPI.ReturnType;
51
+ declare const isChildrenCount: isAPI.ReturnType;
52
+ declare const isChildrenForEach: isAPI.ReturnType;
53
+ declare const isChildrenMap: isAPI.ReturnType;
54
+ declare const isChildrenOnly: isAPI.ReturnType;
55
+ declare const isChildrenToArray: isAPI.ReturnType;
56
+ declare const isCloneElement: isAPI.ReturnType;
57
+ declare const isCreateContext: isAPI.ReturnType;
58
+ declare const isCreateElement: isAPI.ReturnType;
59
+ declare const isCreateRef: isAPI.ReturnType;
60
+ declare const isForwardRef: isAPI.ReturnType;
61
+ declare const isMemo: isAPI.ReturnType;
62
+ declare const isLazy: isAPI.ReturnType;
63
+ declare const isCaptureOwnerStackCall: isAPICall.ReturnType;
64
+ declare const isChildrenCountCall: isAPICall.ReturnType;
65
+ declare const isChildrenForEachCall: isAPICall.ReturnType;
66
+ declare const isChildrenMapCall: isAPICall.ReturnType;
67
+ declare const isChildrenOnlyCall: isAPICall.ReturnType;
68
+ declare const isChildrenToArrayCall: isAPICall.ReturnType;
69
+ declare const isCloneElementCall: isAPICall.ReturnType;
70
+ declare const isCreateContextCall: isAPICall.ReturnType;
71
+ declare const isCreateElementCall: isAPICall.ReturnType;
72
+ declare const isCreateRefCall: isAPICall.ReturnType;
73
+ declare const isForwardRefCall: isAPICall.ReturnType;
74
+ declare const isMemoCall: isAPICall.ReturnType;
75
+ declare const isLazyCall: isAPICall.ReturnType;
76
+ declare const isUse: isAPI.ReturnType;
77
+ declare const isUseActionState: isAPI.ReturnType;
78
+ declare const isUseCallback: isAPI.ReturnType;
79
+ declare const isUseContext: isAPI.ReturnType;
80
+ declare const isUseDebugValue: isAPI.ReturnType;
81
+ declare const isUseDeferredValue: isAPI.ReturnType;
82
+ declare const isUseEffect: isAPI.ReturnType;
83
+ declare const isUseFormStatus: isAPI.ReturnType;
84
+ declare const isUseId: isAPI.ReturnType;
85
+ declare const isUseImperativeHandle: isAPI.ReturnType;
86
+ declare const isUseInsertionEffect: isAPI.ReturnType;
87
+ declare const isUseLayoutEffect: isAPI.ReturnType;
88
+ declare const isUseMemo: isAPI.ReturnType;
89
+ declare const isUseOptimistic: isAPI.ReturnType;
90
+ declare const isUseReducer: isAPI.ReturnType;
91
+ declare const isUseRef: isAPI.ReturnType;
92
+ declare const isUseState: isAPI.ReturnType;
93
+ declare const isUseSyncExternalStore: isAPI.ReturnType;
94
+ declare const isUseTransition: isAPI.ReturnType;
95
+ declare const isUseCall: isAPICall.ReturnType;
96
+ declare const isUseActionStateCall: isAPICall.ReturnType;
97
+ declare const isUseCallbackCall: isAPICall.ReturnType;
98
+ declare const isUseContextCall: isAPICall.ReturnType;
99
+ declare const isUseDebugValueCall: isAPICall.ReturnType;
100
+ declare const isUseDeferredValueCall: isAPICall.ReturnType;
101
+ declare const isUseEffectCall: isAPICall.ReturnType;
102
+ declare const isUseFormStatusCall: isAPICall.ReturnType;
103
+ declare const isUseIdCall: isAPICall.ReturnType;
104
+ declare const isUseImperativeHandleCall: isAPICall.ReturnType;
105
+ declare const isUseInsertionEffectCall: isAPICall.ReturnType;
106
+ declare const isUseLayoutEffectCall: isAPICall.ReturnType;
107
+ declare const isUseMemoCall: isAPICall.ReturnType;
108
+ declare const isUseOptimisticCall: isAPICall.ReturnType;
109
+ declare const isUseReducerCall: isAPICall.ReturnType;
110
+ declare const isUseRefCall: isAPICall.ReturnType;
111
+ declare const isUseStateCall: isAPICall.ReturnType;
112
+ declare const isUseSyncExternalStoreCall: isAPICall.ReturnType;
113
+ declare const isUseTransitionCall: isAPICall.ReturnType;
35
114
  //#endregion
36
- //#region src/api/is-react-api.d.ts
37
- declare namespace isReactAPI {
38
- type ReturnType = {
39
- (context: RuleContext, node: null | TSESTree.Node): boolean;
40
- (context: RuleContext): (node: null | TSESTree.Node) => boolean;
41
- };
42
- }
115
+ //#region src/class-component.d.ts
43
116
  /**
44
- * Check if the node is a React API identifier or member expression
45
- * @param api The React API name to check against (ex: "useState", "React.memo")
46
- * @returns A predicate function to check if a node matches the API
117
+ * @deprecated Class components are legacy. This type exists only to support legacy rules.
47
118
  */
48
- declare function isReactAPI(api: string): isReactAPI.ReturnType;
49
- declare namespace isReactAPICall {
50
- type ReturnType = {
51
- (context: RuleContext, node: null | TSESTree.Node): node is TSESTree.CallExpression;
52
- (context: RuleContext): (node: null | TSESTree.Node) => node is TSESTree.CallExpression;
53
- };
119
+ interface ClassComponentSemanticNode extends SemanticNode$1 {
120
+ id: null | TSESTree.BindingName;
121
+ kind: "class-component";
122
+ displayName: null | TSESTree.Expression;
123
+ flag: bigint;
124
+ hint: bigint;
125
+ methods: ast.TSESTreeMethodOrProperty[];
126
+ node: ast.TSESTreeClass;
54
127
  }
55
128
  /**
56
- * Check if the node is a call expression to a specific React API
57
- * @param api The React API name to check against
58
- * @returns A predicate function to check if a node is a call to the API
129
+ * @param node The AST node to check.
130
+ * @deprecated Class components are legacy. This function exists only to support legacy rules.
59
131
  */
60
- declare function isReactAPICall(api: string): isReactAPICall.ReturnType;
61
- declare const isCaptureOwnerStack: isReactAPI.ReturnType;
62
- declare const isChildrenCount: isReactAPI.ReturnType;
63
- declare const isChildrenForEach: isReactAPI.ReturnType;
64
- declare const isChildrenMap: isReactAPI.ReturnType;
65
- declare const isChildrenOnly: isReactAPI.ReturnType;
66
- declare const isChildrenToArray: isReactAPI.ReturnType;
67
- declare const isCloneElement: isReactAPI.ReturnType;
68
- declare const isCreateContext: isReactAPI.ReturnType;
69
- declare const isCreateElement: isReactAPI.ReturnType;
70
- declare const isCreateRef: isReactAPI.ReturnType;
71
- declare const isForwardRef: isReactAPI.ReturnType;
72
- declare const isMemo: isReactAPI.ReturnType;
73
- declare const isLazy: isReactAPI.ReturnType;
74
- declare const isCaptureOwnerStackCall: isReactAPICall.ReturnType;
75
- declare const isChildrenCountCall: isReactAPICall.ReturnType;
76
- declare const isChildrenForEachCall: isReactAPICall.ReturnType;
77
- declare const isChildrenMapCall: isReactAPICall.ReturnType;
78
- declare const isChildrenOnlyCall: isReactAPICall.ReturnType;
79
- declare const isChildrenToArrayCall: isReactAPICall.ReturnType;
80
- declare const isCloneElementCall: isReactAPICall.ReturnType;
81
- declare const isCreateContextCall: isReactAPICall.ReturnType;
82
- declare const isCreateElementCall: isReactAPICall.ReturnType;
83
- declare const isCreateRefCall: isReactAPICall.ReturnType;
84
- declare const isForwardRefCall: isReactAPICall.ReturnType;
85
- declare const isMemoCall: isReactAPICall.ReturnType;
86
- declare const isLazyCall: isReactAPICall.ReturnType;
87
- //#endregion
88
- //#region src/component/component-detection.d.ts
89
- type ComponentDetectionHint = bigint;
132
+ declare function isClassComponent(node: TSESTree.Node): node is ast.TSESTreeClass;
90
133
  /**
91
- * Hints for component collector
134
+ * @param node The AST node to check.
135
+ * @param context The rule context.
136
+ * @deprecated Class components are legacy. This function exists only to support legacy rules.
92
137
  */
93
- declare const ComponentDetectionHint: {
94
- readonly DoNotIncludeFunctionDefinedAsClassMethod: bigint;
95
- readonly DoNotIncludeFunctionDefinedAsClassProperty: bigint;
96
- readonly DoNotIncludeFunctionDefinedAsObjectMethod: bigint;
97
- readonly DoNotIncludeFunctionDefinedAsArrayExpressionElement: bigint;
98
- readonly DoNotIncludeFunctionDefinedAsArrayPatternElement: bigint;
99
- readonly DoNotIncludeFunctionDefinedAsArbitraryCallExpressionCallback: bigint;
100
- readonly DoNotIncludeFunctionDefinedAsArrayFlatMapCallback: bigint;
101
- readonly DoNotIncludeFunctionDefinedAsArrayMapCallback: bigint;
102
- readonly None: 0n;
103
- readonly DoNotIncludeJsxWithNullValue: bigint;
104
- readonly DoNotIncludeJsxWithNumberValue: bigint;
105
- readonly DoNotIncludeJsxWithBigIntValue: bigint;
106
- readonly DoNotIncludeJsxWithStringValue: bigint;
107
- readonly DoNotIncludeJsxWithBooleanValue: bigint;
108
- readonly DoNotIncludeJsxWithUndefinedValue: bigint;
109
- readonly DoNotIncludeJsxWithEmptyArrayValue: bigint;
110
- readonly DoNotIncludeJsxWithCreateElementValue: bigint;
111
- readonly RequireAllArrayElementsToBeJsx: bigint;
112
- readonly RequireBothSidesOfLogicalExpressionToBeJsx: bigint;
113
- readonly RequireBothBranchesOfConditionalExpressionToBeJsx: bigint;
114
- };
138
+ declare function isClassComponent(node: TSESTree.Node, context: RuleContext): node is ast.TSESTreeClass;
139
+ declare function isClassComponentLoose(node: TSESTree.Node): node is ast.TSESTreeClass;
115
140
  /**
116
- * Default component detection hint
141
+ * @param node The AST node to check.
142
+ * @deprecated Class components are legacy. This function exists only to support legacy rules.
117
143
  */
118
- declare const DEFAULT_COMPONENT_DETECTION_HINT: bigint;
144
+ declare function isPureComponent(node: TSESTree.Node): boolean;
145
+ /** @deprecated Class components are legacy. */
146
+ declare const isRender: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
147
+ /** @deprecated Class components are legacy. */
148
+ declare const isComponentDidCatch: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
149
+ /** @deprecated Class components are legacy. */
150
+ declare const isComponentDidMount: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
151
+ /** @deprecated Class components are legacy. */
152
+ declare const isComponentDidUpdate: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
153
+ /** @deprecated Class components are legacy. */
154
+ declare const isComponentWillMount: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
155
+ /** @deprecated Class components are legacy. */
156
+ declare const isComponentWillReceiveProps: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
157
+ /** @deprecated Class components are legacy. */
158
+ declare const isComponentWillUnmount: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
159
+ /** @deprecated Class components are legacy. */
160
+ declare const isComponentWillUpdate: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
161
+ /** @deprecated Class components are legacy. */
162
+ declare const isGetChildContext: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
163
+ /** @deprecated Class components are legacy. */
164
+ declare const isGetInitialState: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
165
+ /** @deprecated Class components are legacy. */
166
+ declare const isGetSnapshotBeforeUpdate: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
167
+ /** @deprecated Class components are legacy. */
168
+ declare const isShouldComponentUpdate: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
169
+ /** @deprecated Class components are legacy. */
170
+ declare const isUnsafeComponentWillMount: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
171
+ /** @deprecated Class components are legacy. */
172
+ declare const isUnsafeComponentWillReceiveProps: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
173
+ /** @deprecated Class components are legacy. */
174
+ declare const isUnsafeComponentWillUpdate: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
175
+ /** @deprecated Class components are legacy. */
176
+ declare const isGetDefaultProps: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
177
+ /** @deprecated Class components are legacy. */
178
+ declare const isGetDerivedStateFromProps: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
179
+ /** @deprecated Class components are legacy. */
180
+ declare const isGetDerivedStateFromError: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
119
181
  /**
120
- * Determine if a function node represents a valid React component definition
121
- *
122
- * @param context The rule context
123
- * @param node The function node to analyze
124
- * @param hint Component detection hints (bit flags) to customize detection logic
125
- * @returns `true` if the node is considered a component definition
182
+ * @param node The AST node to check.
183
+ * @deprecated Class components are legacy. This function exists only to support legacy rules.
126
184
  */
127
- declare function isComponentDefinition(context: RuleContext, node: ast.TSESTreeFunction, hint: bigint): boolean;
185
+ declare function isRenderMethodLike(node: TSESTree.Node): node is ast.TSESTreeMethodOrProperty;
186
+ declare function isRenderMethodCallback(node: ast.TSESTreeFunction): boolean;
187
+ /**
188
+ * @param node The call expression node to check.
189
+ * @deprecated Class components are legacy. This function exists only to support legacy rules.
190
+ */
191
+ declare function isThisSetStateCall(node: TSESTree.CallExpression): boolean;
192
+ /**
193
+ * @param node The assignment expression node to check.
194
+ * @deprecated Class components are legacy. This function exists only to support legacy rules.
195
+ */
196
+ declare function isAssignmentToThisState(node: TSESTree.AssignmentExpression): boolean;
128
197
  //#endregion
129
- //#region src/semantic/semantic-node.d.ts
198
+ //#region src/class-component-collector.d.ts
199
+ /**
200
+ * @deprecated Class components are legacy. This namespace exists only to support legacy rules.
201
+ */
202
+ declare namespace getClassComponentCollector {
203
+ type ReturnType = {
204
+ api: {
205
+ getAllComponents: (node: TSESTree.Program) => ClassComponentSemanticNode[];
206
+ };
207
+ visitor: ESLintUtils.RuleListener;
208
+ };
209
+ }
210
+ /**
211
+ * @param context The rule context.
212
+ * @deprecated Class components are legacy. This function exists only to support legacy rules.
213
+ */
214
+ declare function getClassComponentCollector(context: RuleContext): getClassComponentCollector.ReturnType;
215
+ //#endregion
216
+ //#region src/semantic.d.ts
130
217
  /**
131
218
  * Represents a semantic node in the AST
132
219
  * This is the base interface for all semantic nodes in the React semantic analysis
@@ -147,8 +234,6 @@ interface SemanticNode {
147
234
  /** The AST node */
148
235
  node: TSESTree.Node;
149
236
  }
150
- //#endregion
151
- //#region src/semantic/semantic-func.d.ts
152
237
  /**
153
238
  * Represents a semantic function node in the AST
154
239
  * This interface extends SemanticNode and provides additional properties for function analysis
@@ -172,7 +257,35 @@ interface SemanticFunc extends SemanticNode {
172
257
  typeParameters: TSESTree.TSTypeParameterDeclaration | null;
173
258
  }
174
259
  //#endregion
175
- //#region src/component/component-semantic-node.d.ts
260
+ //#region src/function.d.ts
261
+ /**
262
+ * Represents the kind of a React function
263
+ */
264
+ type FunctionKind = "client-function" | "server-function";
265
+ /**
266
+ * Represents a React Client Function
267
+ */
268
+ interface ClientFunctionSemanticNode extends SemanticFunc {
269
+ /**
270
+ * The kind of function
271
+ */
272
+ kind: "client-function";
273
+ }
274
+ /**
275
+ * Represents a React Server Function
276
+ */
277
+ interface ServerFunctionSemanticNode extends SemanticFunc {
278
+ /**
279
+ * The kind of function
280
+ */
281
+ kind: "server-function";
282
+ }
283
+ /**
284
+ * Represents a React Function
285
+ */
286
+ type FunctionSemanticNode = ClientFunctionSemanticNode | ServerFunctionSemanticNode;
287
+ //#endregion
288
+ //#region src/function-component.d.ts
176
289
  /**
177
290
  * Represents a React Function Component
178
291
  */
@@ -226,170 +339,10 @@ interface FunctionComponentSemanticNode extends SemanticNode {
226
339
  */
227
340
  directives: ast.TSESTreeDirective[];
228
341
  }
229
- /**
230
- * Represents a React Class Component
231
- */
232
- interface ClassComponentSemanticNode extends SemanticNode {
233
- /**
234
- * The identifier of the component
235
- */
236
- id: null | TSESTree.BindingName;
237
- /**
238
- * The kind of component
239
- */
240
- kind: "class-component";
241
- /**
242
- * The AST node of the class
243
- */
244
- node: ast.TSESTreeClass;
245
- /**
246
- * Flags describing the component's characteristics
247
- */
248
- flag: bigint;
249
- /**
250
- * Hint for how the component was detected
251
- */
252
- hint: bigint;
253
- /**
254
- * List of methods and properties in the class
255
- */
256
- methods: ast.TSESTreeMethodOrProperty[];
257
- /**
258
- * The display name of the component
259
- */
260
- displayName: null | TSESTree.Expression;
261
- }
262
- /**
263
- * Represents a React Component
264
- */
265
- type ComponentSemanticNode = ClassComponentSemanticNode | FunctionComponentSemanticNode;
266
- //#endregion
267
- //#region src/component/component-collector.d.ts
268
- declare namespace getComponentCollector {
269
- type Options = {
270
- collectDisplayName?: boolean;
271
- hint?: ComponentDetectionHint;
272
- };
273
- type ReturnType = {
274
- api: {
275
- getAllComponents: (node: TSESTree.Program) => FunctionComponentSemanticNode[];
276
- };
277
- visitor: ESLintUtils.RuleListener;
278
- };
279
- }
280
- /**
281
- * Get an api and visitor object for the rule to collect function components
282
- * @param context The ESLint rule context
283
- * @param options The options to use
284
- * @returns The api and visitor of the collector
285
- */
286
- declare function getComponentCollector(context: RuleContext, options?: getComponentCollector.Options): getComponentCollector.ReturnType;
287
- //#endregion
288
- //#region src/component/component-collector-legacy.d.ts
289
- declare namespace getComponentCollectorLegacy {
290
- type ReturnType = {
291
- api: {
292
- getAllComponents: (node: TSESTree$1.Program) => ClassComponentSemanticNode[];
293
- };
294
- visitor: ESLintUtils.RuleListener;
295
- };
296
- }
297
- /**
298
- * Get an api and visitor object for the rule to collect class components
299
- * @param context The ESLint rule context
300
- * @returns The api and visitor of the collector
301
- */
302
- declare function getComponentCollectorLegacy(context: RuleContext): getComponentCollectorLegacy.ReturnType;
303
- //#endregion
304
- //#region src/component/component-detection-legacy.d.ts
305
- /**
306
- * Check if a node is a React class component
307
- * @param node The AST node to check
308
- * @returns `true` if the node is a class component, `false` otherwise
309
- */
310
- declare function isClassComponent(node: TSESTree.Node): node is ast.TSESTreeClass;
311
- declare function isClassComponent(node: TSESTree.Node, context: RuleContext): node is ast.TSESTreeClass;
312
- /**
313
- * Check if a node is a React PureComponent
314
- * @param node The AST node to check
315
- * @returns `true` if the node is a PureComponent, `false` otherwise
316
- */
317
- declare function isPureComponent(node: TSESTree.Node): boolean;
318
- declare const isRender: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
319
- declare const isComponentDidCatch: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
320
- declare const isComponentDidMount: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
321
- declare const isComponentDidUpdate: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
322
- declare const isComponentWillMount: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
323
- declare const isComponentWillReceiveProps: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
324
- declare const isComponentWillUnmount: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
325
- declare const isComponentWillUpdate: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
326
- declare const isGetChildContext: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
327
- declare const isGetInitialState: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
328
- declare const isGetSnapshotBeforeUpdate: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
329
- declare const isShouldComponentUpdate: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
330
- declare const isUnsafeComponentWillMount: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
331
- declare const isUnsafeComponentWillReceiveProps: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
332
- declare const isUnsafeComponentWillUpdate: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
333
- declare const isGetDefaultProps: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
334
- declare const isGetDerivedStateFromProps: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
335
- declare const isGetDerivedStateFromError: (node: TSESTree.Node) => node is ast.TSESTreeMethodOrProperty;
336
- /**
337
- * Check if the given node is a componentDidMount callback
338
- * @param node The node to check
339
- * @returns True if the node is a componentDidMount callback, false otherwise
340
- */
341
- declare function isComponentDidMountCallback(node: TSESTree.Node): boolean;
342
- /**
343
- * Check if the given node is a componentWillUnmount callback
344
- * @param node The node to check
345
- * @returns True if the node is a componentWillUnmount callback, false otherwise
346
- */
347
- declare function isComponentWillUnmountCallback(node: TSESTree.Node): boolean;
348
- /**
349
- * Check whether given node is a render method of a class component
350
- * @example
351
- * ```tsx
352
- * class Component extends React.Component {
353
- * renderHeader = () => <div />;
354
- * renderFooter = () => <div />;
355
- * }
356
- * ```
357
- * @param node The AST node to check
358
- * @returns `true` if node is a render function, `false` if not
359
- */
360
- declare function isRenderMethodLike(node: TSESTree.Node): node is ast.TSESTreeMethodOrProperty;
361
- /**
362
- * Check if the given node is a function within a render method of a class component
363
- *
364
- * @param node The AST node to check
365
- * @returns `true` if the node is a render function inside a class component
366
- *
367
- * @example
368
- * ```tsx
369
- * class Component extends React.Component {
370
- * renderHeader = () => <div />; // Returns true
371
- * }
372
- * ```
373
- */
374
- declare function isRenderMethodCallback(node: ast.TSESTreeFunction): boolean;
375
- /**
376
- * Check whether the given node is a this.setState() call
377
- * @param node The node to check
378
- * @internal
379
- */
380
- declare function isThisSetStateCall(node: TSESTree.CallExpression): boolean;
381
- /**
382
- * Check whether the given node is an assignment to this.state
383
- * @param node The node to check
384
- * @internal
385
- */
386
- declare function isAssignmentToThisState(node: TSESTree.AssignmentExpression): boolean;
387
- //#endregion
388
- //#region src/component/component-flag.d.ts
389
342
  /**
390
343
  * Component flag constants
391
344
  */
392
- declare const ComponentFlag: {
345
+ declare const FunctionComponentFlag: {
393
346
  /** No flags set */None: bigint; /** Indicates the component is a pure component (ex: extends PureComponent) */
394
347
  PureComponent: bigint; /** Indicates the component creates elements using `createElement` instead of JSX */
395
348
  CreateElement: bigint; /** Indicates the component is memoized (ex: React.memo) */
@@ -400,29 +353,40 @@ declare const ComponentFlag: {
400
353
  * Get component flag from init path
401
354
  * @param initPath The init path of the function component
402
355
  * @returns The component flag
356
+ * @internal
403
357
  */
404
- declare function getComponentFlagFromInitPath(initPath: FunctionComponentSemanticNode["initPath"]): bigint;
405
- //#endregion
406
- //#region src/component/component-id.d.ts
358
+ declare function getFunctionComponentFlagFromInitPath(initPath: FunctionComponentSemanticNode["initPath"]): bigint;
359
+ /**
360
+ * Check if the node is a call expression for a component wrapper
361
+ * @param context The ESLint rule context
362
+ * @param node The node to check
363
+ * @returns `true` if the node is a call expression for a component wrapper
364
+ */
365
+ declare function isFunctionComponentWrapperCall(context: RuleContext, node: TSESTree.Node): boolean;
366
+ /**
367
+ * Check if the node is a callback function passed to a component wrapper
368
+ * @param context The ESLint rule context
369
+ * @param node The node to check
370
+ * @returns `true` if the node is a callback function passed to a component wrapper
371
+ */
372
+ declare function isFunctionComponentWrapperCallback(context: RuleContext, node: TSESTree.Node): boolean;
407
373
  /**
408
374
  * Get function component identifier from `const Component = memo(() => {});`
409
375
  * @param context The rule context
410
- * @param node The function node to analyze
411
- * @returns The function identifier or `null` if not found
376
+ * @param node The AST node to get the function component identifier from
377
+ * @internal
412
378
  */
413
379
  declare function getFunctionComponentId(context: RuleContext, node: ast.TSESTreeFunction): ast.FunctionID;
414
- //#endregion
415
- //#region src/component/component-name.d.ts
416
380
  /**
417
381
  * Check if a string matches the strict component name pattern
418
382
  * @param name The name to check
419
383
  */
420
- declare function isComponentName(name: string): boolean;
384
+ declare function isFunctionComponentName(name: string): boolean;
421
385
  /**
422
386
  * Check if a string matches the loose component name pattern
423
387
  * @param name The name to check
424
388
  */
425
- declare function isComponentNameLoose(name: string): boolean;
389
+ declare function isFunctionComponentNameLoose(name: string): boolean;
426
390
  /**
427
391
  * Check if a function has a loose component name
428
392
  * @param context The rule context
@@ -431,130 +395,99 @@ declare function isComponentNameLoose(name: string): boolean;
431
395
  * @returns Whether the function has a loose component name
432
396
  */
433
397
  declare function isFunctionWithLooseComponentName(context: RuleContext, fn: ast.TSESTreeFunction, allowNone?: boolean): boolean;
434
- //#endregion
435
- //#region src/component/component-wrapper.d.ts
436
- /**
437
- * Check if the node is a call expression for a component wrapper
438
- * @param context The ESLint rule context
439
- * @param node The node to check
440
- * @returns `true` if the node is a call expression for a component wrapper
441
- */
442
- declare function isComponentWrapperCall(context: RuleContext, node: TSESTree.Node): boolean;
443
- /**
444
- * Check if the node is a callback function passed to a component wrapper
445
- * @param context The ESLint rule context
446
- * @param node The node to check
447
- * @returns `true` if the node is a callback function passed to a component wrapper
448
- */
398
+ type FunctionComponentDetectionHint = bigint;
449
399
  /**
450
- * Check if the node is a call expression for a component wrapper loosely
451
- * @param context The ESLint rule context
452
- * @param node The node to check
453
- * @returns `true` if the node is a call expression for a component wrapper loosely
454
- */
455
- declare function isComponentWrapperCallLoose(context: RuleContext, node: TSESTree.Node): boolean;
456
- /**
457
- * Check if the node is a callback function passed to a component wrapper
458
- * @param context The ESLint rule context
459
- * @param node The node to check
460
- * @returns `true` if the node is a callback function passed to a component wrapper
400
+ * Hints for component collector
461
401
  */
462
- declare function isComponentWrapperCallback(context: RuleContext, node: TSESTree.Node): boolean;
402
+ declare const FunctionComponentDetectionHint: {
403
+ readonly DoNotIncludeFunctionDefinedAsClassMethod: bigint;
404
+ readonly DoNotIncludeFunctionDefinedAsClassProperty: bigint;
405
+ readonly DoNotIncludeFunctionDefinedAsObjectMethod: bigint;
406
+ readonly DoNotIncludeFunctionDefinedAsArrayExpressionElement: bigint;
407
+ readonly DoNotIncludeFunctionDefinedAsArrayPatternElement: bigint;
408
+ readonly DoNotIncludeFunctionDefinedAsArbitraryCallExpressionCallback: bigint;
409
+ readonly DoNotIncludeFunctionDefinedAsArrayFlatMapCallback: bigint;
410
+ readonly DoNotIncludeFunctionDefinedAsArrayMapCallback: bigint;
411
+ readonly None: 0n;
412
+ readonly DoNotIncludeJsxWithNullValue: bigint;
413
+ readonly DoNotIncludeJsxWithNumberValue: bigint;
414
+ readonly DoNotIncludeJsxWithBigIntValue: bigint;
415
+ readonly DoNotIncludeJsxWithStringValue: bigint;
416
+ readonly DoNotIncludeJsxWithBooleanValue: bigint;
417
+ readonly DoNotIncludeJsxWithUndefinedValue: bigint;
418
+ readonly DoNotIncludeJsxWithEmptyArrayValue: bigint;
419
+ readonly DoNotIncludeJsxWithCreateElementValue: bigint;
420
+ readonly RequireAllArrayElementsToBeJsx: bigint;
421
+ readonly RequireBothSidesOfLogicalExpressionToBeJsx: bigint;
422
+ readonly RequireBothBranchesOfConditionalExpressionToBeJsx: bigint;
423
+ };
463
424
  /**
464
- * Check if the node is a callback function passed to a component wrapper loosely
465
- * @param context The ESLint rule context
466
- * @param node The node to check
467
- * @returns `true` if the node is a callback function passed to a component wrapper loosely
425
+ * Default component detection hint
468
426
  */
469
- declare function isComponentWrapperCallbackLoose(context: RuleContext, node: TSESTree.Node): boolean;
470
- //#endregion
471
- //#region src/function/function-kind.d.ts
427
+ declare const DEFAULT_COMPONENT_DETECTION_HINT: bigint;
472
428
  /**
473
- * Represents the kind of a React function
429
+ * Determine if a function node represents a valid React component definition
430
+ *
431
+ * @param context The rule context
432
+ * @param node The function node to analyze
433
+ * @param hint Component detection hints (bit flags) to customize detection logic
434
+ * @returns `true` if the node is considered a component definition
474
435
  */
475
- type FunctionKind = "client-function" | "server-function";
436
+ declare function isFunctionComponentDefinition(context: RuleContext, node: ast.TSESTreeFunction, hint: bigint): boolean;
476
437
  //#endregion
477
- //#region src/function/function-semantic-node.d.ts
478
- /**
479
- * Represents a React Client Function
480
- */
481
- interface ClientFunctionSemanticNode extends SemanticFunc {
482
- /**
483
- * The kind of function
484
- */
485
- kind: "client-function";
486
- }
487
- /**
488
- * Represents a React Server Function
489
- */
490
- interface ServerFunctionSemanticNode extends SemanticFunc {
491
- /**
492
- * The kind of function
493
- */
494
- kind: "server-function";
438
+ //#region src/function-component-collector.d.ts
439
+ declare namespace getFunctionComponentCollector {
440
+ type Options = {
441
+ collectDisplayName?: boolean;
442
+ hint?: FunctionComponentDetectionHint;
443
+ };
444
+ type ReturnType = {
445
+ api: {
446
+ getAllComponents: (node: TSESTree.Program) => FunctionComponentSemanticNode[];
447
+ };
448
+ visitor: ESLintUtils.RuleListener;
449
+ };
495
450
  }
496
451
  /**
497
- * Represents a React Function
498
- */
499
- type FunctionSemanticNode = ClientFunctionSemanticNode | ServerFunctionSemanticNode;
500
- //#endregion
501
- //#region src/hook/hook-callback.d.ts
502
- /**
503
- * Determine if a node is the setup function passed to a useEffect-like hook
504
- * @param node The AST node to check
505
- */
506
- declare function isUseEffectSetupCallback(node: TSESTree.Node | null): boolean;
507
- /**
508
- * Determine if a node is the cleanup function returned by a useEffect-like hook's setup function
509
- * @param node The AST node to check
452
+ * Get an api and visitor object for the rule to collect function components
453
+ * @param context The ESLint rule context
454
+ * @param options The options to use
455
+ * @returns The api and visitor of the collector
510
456
  */
511
- declare function isUseEffectCleanupCallback(node: TSESTree.Node | null): boolean;
457
+ declare function getFunctionComponentCollector(context: RuleContext, options?: getFunctionComponentCollector.Options): getFunctionComponentCollector.ReturnType;
512
458
  //#endregion
513
- //#region src/hook/hook-semantic-node.d.ts
459
+ //#region src/hook.d.ts
514
460
  /**
515
461
  * Represents a semantic hook node in the AST
516
- * This interface extends SemanticNode and provides additional properties for React hook analysis
517
462
  */
518
463
  interface HookSemanticNode extends SemanticNode {
519
464
  /** The identifier of the hook */
520
465
  id: ast.FunctionID;
521
466
  /** The AST node of the hook */
522
467
  node: ast.TSESTreeFunction;
523
- /** The name of the hook */
524
- name: string;
525
468
  /** The kind of hook */
526
469
  kind: "hook";
470
+ /** List of expressions returned by the hook */
471
+ rets: TSESTree.ReturnStatement["argument"][];
527
472
  /** The other hooks called by the hook */
528
473
  hookCalls: TSESTree.CallExpression[];
529
474
  /** The directives used in the function (ex: "use strict", "use client", etc.) */
530
475
  directives: ast.TSESTreeDirective[];
531
476
  }
532
- //#endregion
533
- //#region src/hook/hook-collector.d.ts
534
- declare namespace getHookCollector {
535
- type ReturnType = {
536
- api: {
537
- getAllHooks(node: TSESTree$1.Program): HookSemanticNode[];
538
- };
539
- visitor: ESLintUtils.RuleListener;
540
- };
541
- }
477
+ declare const REACT_BUILTIN_HOOK_NAMES: readonly ["use", "useActionState", "useCallback", "useContext", "useDebugValue", "useDeferredValue", "useEffect", "useFormStatus", "useId", "useImperativeHandle", "useInsertionEffect", "useLayoutEffect", "useMemo", "useOptimistic", "useReducer", "useRef", "useState", "useSyncExternalStore", "useTransition"];
542
478
  /**
543
- * Get an api and visitor object for the rule to collect hooks
544
- * @param context The ESLint rule context
545
- * @returns The api and visitor of the collector
479
+ * Catch all identifiers that begin with "use" followed by an uppercase Latin
480
+ * character to exclude identifiers like "user".
481
+ * @param name The name of the identifier to check.
482
+ * @see https://github.com/facebook/react/blob/1d6c8168db1d82713202e842df3167787ffa00ed/packages/eslint-plugin-react-hooks/src/rules/RulesOfHooks.ts#L16
546
483
  */
547
- declare function getHookCollector(context: RuleContext): getHookCollector.ReturnType;
548
- //#endregion
549
- //#region src/hook/hook-id.d.ts
484
+ declare function isHookName(name: string): boolean;
550
485
  /**
551
486
  * Checks if the given node is a hook identifier
552
487
  * @param id The AST node to check
553
488
  * @returns `true` if the node is a hook identifier or member expression with hook name, `false` otherwise
554
489
  */
555
490
  declare function isHookId(id: TSESTree.Node): id is TSESTree.Identifier | TSESTree.MemberExpression;
556
- //#endregion
557
- //#region src/hook/hook-is.d.ts
558
491
  /**
559
492
  * Determine if a function node is a React Hook based on its name.
560
493
  * @param node The function node to check
@@ -575,40 +508,165 @@ declare function isHookCall(node: TSESTree.Node | null): node is TSESTree.CallEx
575
508
  */
576
509
  declare function isUseEffectLikeCall(node: TSESTree.Node | null, additionalEffectHooks?: RegExpLike): node is TSESTree.CallExpression;
577
510
  /**
578
- * Detect useState calls and variations (useCustomState, etc.) using a regex pattern
511
+ * Detect useState calls and variations using a regex pattern
579
512
  * @param node The AST node to check
580
513
  * @param additionalStateHooks Regex pattern matching custom hooks that should be treated as state hooks
581
514
  * @returns True if the node is a useState-like call
582
515
  */
583
516
  declare function isUseStateLikeCall(node: TSESTree.Node | null, additionalStateHooks?: RegExpLike): node is TSESTree.CallExpression;
584
- declare const isUseCall: (node: TSESTree.Node | null) => boolean;
585
- declare const isUseActionStateCall: (node: TSESTree.Node | null) => boolean;
586
- declare const isUseCallbackCall: (node: TSESTree.Node | null) => boolean;
587
- declare const isUseContextCall: (node: TSESTree.Node | null) => boolean;
588
- declare const isUseDebugValueCall: (node: TSESTree.Node | null) => boolean;
589
- declare const isUseDeferredValueCall: (node: TSESTree.Node | null) => boolean;
590
- declare const isUseEffectCall: (node: TSESTree.Node | null) => boolean;
591
- declare const isUseFormStatusCall: (node: TSESTree.Node | null) => boolean;
592
- declare const isUseIdCall: (node: TSESTree.Node | null) => boolean;
593
- declare const isUseImperativeHandleCall: (node: TSESTree.Node | null) => boolean;
594
- declare const isUseInsertionEffectCall: (node: TSESTree.Node | null) => boolean;
595
- declare const isUseLayoutEffectCall: (node: TSESTree.Node | null) => boolean;
596
- declare const isUseMemoCall: (node: TSESTree.Node | null) => boolean;
597
- declare const isUseOptimisticCall: (node: TSESTree.Node | null) => boolean;
598
- declare const isUseReducerCall: (node: TSESTree.Node | null) => boolean;
599
- declare const isUseRefCall: (node: TSESTree.Node | null) => boolean;
600
- declare const isUseStateCall: (node: TSESTree.Node | null) => boolean;
601
- declare const isUseSyncExternalStoreCall: (node: TSESTree.Node | null) => boolean;
602
- declare const isUseTransitionCall: (node: TSESTree.Node | null) => boolean;
517
+ /**
518
+ * Determine if a node is the setup function passed to a useEffect-like hook
519
+ * @param node The AST node to check
520
+ */
521
+ declare function isUseEffectSetupCallback(node: TSESTree.Node | null): boolean;
522
+ /**
523
+ * Determine if a node is the cleanup function returned by a useEffect-like hook's setup function
524
+ * @param node The AST node to check
525
+ */
526
+ declare function isUseEffectCleanupCallback(node: TSESTree.Node | null): boolean;
603
527
  //#endregion
604
- //#region src/hook/hook-name.d.ts
605
- declare const REACT_BUILTIN_HOOK_NAMES: readonly ["use", "useActionState", "useCallback", "useContext", "useDebugValue", "useDeferredValue", "useEffect", "useFormStatus", "useId", "useImperativeHandle", "useInsertionEffect", "useLayoutEffect", "useMemo", "useOptimistic", "useReducer", "useRef", "useState", "useSyncExternalStore", "useTransition"];
528
+ //#region src/hook-collector.d.ts
529
+ declare namespace getHookCollector {
530
+ type ReturnType = {
531
+ api: {
532
+ getAllHooks(node: TSESTree$1.Program): HookSemanticNode[];
533
+ };
534
+ visitor: ESLintUtils.RuleListener;
535
+ };
536
+ }
606
537
  /**
607
- * Catch all identifiers that begin with "use" followed by an uppercase Latin
608
- * character to exclude identifiers like "user".
609
- * @param name The name of the identifier to check.
610
- * @see https://github.com/facebook/react/blob/1d6c8168db1d82713202e842df3167787ffa00ed/packages/eslint-plugin-react-hooks/src/rules/RulesOfHooks.ts#L16
538
+ * Get an api and visitor object for the rule to collect hooks
539
+ * @param context The ESLint rule context
540
+ * @returns The api and visitor of the collector
611
541
  */
612
- declare function isHookName(name: string): boolean;
542
+ declare function getHookCollector(context: RuleContext): getHookCollector.ReturnType;
543
+ //#endregion
544
+ //#region src/type-is.d.ts
545
+ declare function isBooleanLiteralType<TType extends ts.Type>(type: TType): type is TType & {
546
+ intrinsicName: "false" | "true";
547
+ };
548
+ /** @internal */
549
+ declare const isFalseLiteralType: (type: ts.Type) => boolean;
550
+ /** @internal */
551
+ declare const isTrueLiteralType: (type: ts.Type) => boolean;
552
+ /** @internal */
553
+ declare const isAnyType: (type: ts.Type) => boolean;
554
+ /** @internal */
555
+ declare const isBigIntType: (type: ts.Type) => boolean;
556
+ /** @internal */
557
+ declare const isBooleanType: (type: ts.Type) => boolean;
558
+ /** @internal */
559
+ declare const isEnumType: (type: ts.Type) => boolean;
560
+ /** @internal */
561
+ declare const isFalsyBigIntType: (type: ts.Type) => type is ts.LiteralType & {
562
+ freshType: ts.FreshableType;
563
+ regularType: ts.FreshableType;
564
+ flags: ts.TypeFlags;
565
+ symbol: ts.Symbol;
566
+ pattern?: ts.DestructuringPattern;
567
+ aliasSymbol?: ts.Symbol;
568
+ aliasTypeArguments?: readonly ts.Type[];
569
+ getFlags: () => ts.TypeFlags;
570
+ getSymbol: () => ts.Symbol | undefined;
571
+ getProperties: () => ts.Symbol[];
572
+ getProperty: (propertyName: string) => ts.Symbol | undefined;
573
+ getApparentProperties: () => ts.Symbol[];
574
+ getCallSignatures: () => readonly ts.Signature[];
575
+ getConstructSignatures: () => readonly ts.Signature[];
576
+ getStringIndexType: () => ts.Type | undefined;
577
+ getNumberIndexType: () => ts.Type | undefined;
578
+ getBaseTypes: () => ts.BaseType[] | undefined;
579
+ getNonNullableType: () => ts.Type;
580
+ getConstraint: () => ts.Type | undefined;
581
+ getDefault: () => ts.Type | undefined;
582
+ isUnion: () => this is ts.UnionType;
583
+ isIntersection: () => this is ts.IntersectionType;
584
+ isUnionOrIntersection: () => this is ts.UnionOrIntersectionType;
585
+ isLiteral: () => this is ts.LiteralType;
586
+ isStringLiteral: () => this is ts.StringLiteralType;
587
+ isNumberLiteral: () => this is ts.NumberLiteralType;
588
+ isTypeParameter: () => this is ts.TypeParameter;
589
+ isClassOrInterface: () => this is ts.InterfaceType;
590
+ isClass: () => this is ts.InterfaceType;
591
+ isIndexType: () => this is ts.IndexType;
592
+ value: {
593
+ negative: boolean;
594
+ base10Value: "0";
595
+ };
596
+ };
597
+ /** @internal */
598
+ declare const isFalsyNumberType: (type: ts.Type) => boolean;
599
+ /** @internal */
600
+ declare const isFalsyStringType: (type: ts.Type) => boolean;
601
+ /** @internal */
602
+ declare const isNeverType: (type: ts.Type) => boolean;
603
+ /** @internal */
604
+ declare const isNullishType: (type: ts.Type) => boolean;
605
+ /** @internal */
606
+ declare const isNumberType: (type: ts.Type) => boolean;
607
+ /** @internal */
608
+ declare const isObjectType: (type: ts.Type) => boolean;
609
+ /** @internal */
610
+ declare const isStringType: (type: ts.Type) => boolean;
611
+ /** @internal */
612
+ declare const isTruthyBigIntType: (type: ts.Type) => type is ts.LiteralType & {
613
+ freshType: ts.FreshableType;
614
+ regularType: ts.FreshableType;
615
+ flags: ts.TypeFlags;
616
+ symbol: ts.Symbol;
617
+ pattern?: ts.DestructuringPattern;
618
+ aliasSymbol?: ts.Symbol;
619
+ aliasTypeArguments?: readonly ts.Type[];
620
+ getFlags: () => ts.TypeFlags;
621
+ getSymbol: () => ts.Symbol | undefined;
622
+ getProperties: () => ts.Symbol[];
623
+ getProperty: (propertyName: string) => ts.Symbol | undefined;
624
+ getApparentProperties: () => ts.Symbol[];
625
+ getCallSignatures: () => readonly ts.Signature[];
626
+ getConstructSignatures: () => readonly ts.Signature[];
627
+ getStringIndexType: () => ts.Type | undefined;
628
+ getNumberIndexType: () => ts.Type | undefined;
629
+ getBaseTypes: () => ts.BaseType[] | undefined;
630
+ getNonNullableType: () => ts.Type;
631
+ getConstraint: () => ts.Type | undefined;
632
+ getDefault: () => ts.Type | undefined;
633
+ isUnion: () => this is ts.UnionType;
634
+ isIntersection: () => this is ts.IntersectionType;
635
+ isUnionOrIntersection: () => this is ts.UnionOrIntersectionType;
636
+ isLiteral: () => this is ts.LiteralType;
637
+ isStringLiteral: () => this is ts.StringLiteralType;
638
+ isNumberLiteral: () => this is ts.NumberLiteralType;
639
+ isTypeParameter: () => this is ts.TypeParameter;
640
+ isClassOrInterface: () => this is ts.InterfaceType;
641
+ isClass: () => this is ts.InterfaceType;
642
+ isIndexType: () => this is ts.IndexType;
643
+ value: ts.PseudoBigInt;
644
+ };
645
+ /** @internal */
646
+ declare const isTruthyNumberType: (type: ts.Type) => boolean;
647
+ /** @internal */
648
+ declare const isTruthyStringType: (type: ts.Type) => boolean;
649
+ /** @internal */
650
+ declare const isUnknownType: (type: ts.Type) => boolean;
651
+ //#endregion
652
+ //#region src/type-name.d.ts
653
+ /**
654
+ * An enhanced version of getFullyQualifiedName that handles cases that original function does not handle
655
+ * @param checker TypeScript type checker
656
+ * @param symbol Symbol to get fully qualified name for
657
+ * @returns Fully qualified name of the symbol
658
+ */
659
+ declare function getFullyQualifiedNameEx(checker: ts.TypeChecker, symbol: ts.Symbol): string;
660
+ //#endregion
661
+ //#region src/type-variant.d.ts
662
+ type TypeVariant = "any" | "bigint" | "boolean" | "enum" | "never" | "nullish" | "number" | "object" | "string" | "unknown" | "falsy bigint" | "falsy boolean" | "falsy number" | "falsy string" | "truthy bigint" | "truthy boolean" | "truthy number" | "truthy string";
663
+ /**
664
+ * Ported from https://github.com/typescript-eslint/typescript-eslint/blob/eb736bbfc22554694400e6a4f97051d845d32e0b/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts#L826 with some enhancements
665
+ * Get the variants of an array of types.
666
+ * @param types The types to get the variants of
667
+ * @returns The variants of the types
668
+ * @internal
669
+ */
670
+ declare function getTypeVariants(types: ts.Type[]): Set<TypeVariant>;
613
671
  //#endregion
614
- export { ClassComponentSemanticNode, ClientFunctionSemanticNode, ComponentDetectionHint, ComponentFlag, ComponentSemanticNode, DEFAULT_COMPONENT_DETECTION_HINT, FunctionComponentSemanticNode, FunctionKind, FunctionSemanticNode, HookSemanticNode, REACT_BUILTIN_HOOK_NAMES, SemanticFunc, SemanticNode, ServerFunctionSemanticNode, findImportSource, getComponentCollector, getComponentCollectorLegacy, getComponentFlagFromInitPath, getFunctionComponentId, getHookCollector, isAssignmentToThisState, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDefinition, isComponentDidCatch, isComponentDidMount, isComponentDidMountCallback, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUnmountCallback, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isComponentWrapperCallback, isComponentWrapperCallbackLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isForwardRef, isForwardRefCall, isFunctionWithLooseComponentName, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isHookCall, isHookDefinition, isHookId, isHookName, isInitializedFromReact, isInitializedFromReactNative, isLazy, isLazyCall, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isRender, isRenderMethodCallback, isRenderMethodLike, isShouldComponentUpdate, isThisSetStateCall, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCleanupCallback, isUseEffectLikeCall, isUseEffectSetupCallback, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseStateLikeCall, isUseSyncExternalStoreCall, isUseTransitionCall };
672
+ export { ClassComponentSemanticNode, ClientFunctionSemanticNode, DEFAULT_COMPONENT_DETECTION_HINT, FunctionComponentDetectionHint, FunctionComponentFlag, FunctionComponentSemanticNode, FunctionKind, FunctionSemanticNode, HookSemanticNode, REACT_BUILTIN_HOOK_NAMES, SemanticFunc, SemanticNode, ServerFunctionSemanticNode, TypeVariant, getClassComponentCollector, getFullyQualifiedNameEx, getFunctionComponentCollector, getFunctionComponentFlagFromInitPath, getFunctionComponentId, getHookCollector, getTypeVariants, isAPI, isAPICall, isAPIFromReact, isAPIFromReactNative, isAnyType, isAssignmentToThisState, isBigIntType, isBooleanLiteralType, isBooleanType, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isClassComponentLoose, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUpdate, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isEnumType, isFalseLiteralType, isFalsyBigIntType, isFalsyNumberType, isFalsyStringType, isForwardRef, isForwardRefCall, isFunctionComponentDefinition, isFunctionComponentName, isFunctionComponentNameLoose, isFunctionComponentWrapperCall, isFunctionComponentWrapperCallback, isFunctionWithLooseComponentName, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isHookCall, isHookDefinition, isHookId, isHookName, isLazy, isLazyCall, isMemo, isMemoCall, isNeverType, isNullishType, isNumberType, isObjectType, isPureComponent, isRender, isRenderMethodCallback, isRenderMethodLike, isShouldComponentUpdate, isStringType, isThisSetStateCall, isTrueLiteralType, isTruthyBigIntType, isTruthyNumberType, isTruthyStringType, isUnknownType, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUse, isUseActionState, isUseActionStateCall, isUseCall, isUseCallback, isUseCallbackCall, isUseContext, isUseContextCall, isUseDebugValue, isUseDebugValueCall, isUseDeferredValue, isUseDeferredValueCall, isUseEffect, isUseEffectCall, isUseEffectCleanupCallback, isUseEffectLikeCall, isUseEffectSetupCallback, isUseFormStatus, isUseFormStatusCall, isUseId, isUseIdCall, isUseImperativeHandle, isUseImperativeHandleCall, isUseInsertionEffect, isUseInsertionEffectCall, isUseLayoutEffect, isUseLayoutEffectCall, isUseMemo, isUseMemoCall, isUseOptimistic, isUseOptimisticCall, isUseReducer, isUseReducerCall, isUseRef, isUseRefCall, isUseState, isUseStateCall, isUseStateLikeCall, isUseSyncExternalStore, isUseSyncExternalStoreCall, isUseTransition, isUseTransitionCall };