@eslint-react/core 2.0.0-next.6 → 2.0.0-next.61
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.ts +501 -265
- package/dist/index.js +1156 -849
- package/package.json +14 -14
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import * as
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
|
|
1
|
+
import { TSESTree } from "@typescript-eslint/types";
|
|
2
|
+
import * as AST from "@eslint-react/ast";
|
|
3
|
+
import { unit } from "@eslint-react/eff";
|
|
4
|
+
import { RuleContext } from "@eslint-react/kit";
|
|
5
|
+
import * as VAR from "@eslint-react/var";
|
|
6
|
+
import * as birecord0 from "birecord";
|
|
7
|
+
import { isFalseLiteralType, isTrueLiteralType } from "ts-api-utils";
|
|
8
|
+
import ts from "typescript";
|
|
9
|
+
import { ESLintUtils, TSESTree as TSESTree$1 } from "@typescript-eslint/utils";
|
|
10
|
+
import { Scope } from "@typescript-eslint/scope-manager";
|
|
11
|
+
|
|
12
|
+
//#region src/component/component-children.d.ts
|
|
10
13
|
/**
|
|
11
14
|
* Determines whether inside `createElement`'s children.
|
|
12
15
|
* @param context The rule context
|
|
@@ -14,132 +17,139 @@ import * as VAR from '@eslint-react/var';
|
|
|
14
17
|
* @returns `true` if the node is inside createElement's children
|
|
15
18
|
*/
|
|
16
19
|
declare function isChildrenOfCreateElement(context: RuleContext, node: TSESTree.Node): boolean;
|
|
17
|
-
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/component/component-detection-hint.d.ts
|
|
18
22
|
type ComponentDetectionHint = bigint;
|
|
19
23
|
/**
|
|
20
24
|
* Hints for component collector
|
|
21
25
|
*/
|
|
22
26
|
declare const ComponentDetectionHint: {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Skip function component created by React.memo
|
|
29
|
+
*/
|
|
30
|
+
readonly SkipMemo: bigint;
|
|
31
|
+
/**
|
|
32
|
+
* Skip function component created by React.forwardRef
|
|
33
|
+
*/
|
|
34
|
+
readonly SkipForwardRef: bigint;
|
|
35
|
+
/**
|
|
36
|
+
* Skip function component defined as array map argument
|
|
37
|
+
*/
|
|
38
|
+
readonly SkipArrayMapArgument: bigint;
|
|
39
|
+
/**
|
|
40
|
+
* Skip function component defined on object method
|
|
41
|
+
*/
|
|
42
|
+
readonly SkipObjectMethod: bigint;
|
|
43
|
+
/**
|
|
44
|
+
* Skip function component defined on class method
|
|
45
|
+
*/
|
|
46
|
+
readonly SkipClassMethod: bigint;
|
|
47
|
+
/**
|
|
48
|
+
* Skip function component defined on class property
|
|
49
|
+
*/
|
|
50
|
+
readonly SkipClassProperty: bigint;
|
|
51
|
+
readonly None: 0n;
|
|
52
|
+
readonly SkipUndefined: bigint;
|
|
53
|
+
readonly SkipNullLiteral: bigint;
|
|
54
|
+
readonly SkipBooleanLiteral: bigint;
|
|
55
|
+
readonly SkipStringLiteral: bigint;
|
|
56
|
+
readonly SkipNumberLiteral: bigint;
|
|
57
|
+
readonly SkipBigIntLiteral: bigint;
|
|
58
|
+
readonly SkipEmptyArray: bigint;
|
|
59
|
+
readonly SkipCreateElement: bigint;
|
|
60
|
+
readonly StrictArray: bigint;
|
|
61
|
+
readonly StrictLogical: bigint;
|
|
62
|
+
readonly StrictConditional: bigint;
|
|
59
63
|
};
|
|
60
64
|
/**
|
|
61
65
|
* Default component detection hint
|
|
62
66
|
*/
|
|
63
67
|
declare const DEFAULT_COMPONENT_DETECTION_HINT: bigint;
|
|
64
|
-
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/component/component-phase.d.ts
|
|
65
70
|
type ComponentEffectPhaseKind = "cleanup" | "setup";
|
|
66
71
|
type ComponentLifecyclePhaseKind = "mount" | "unmount";
|
|
67
72
|
type ComponentPhaseKind = ComponentEffectPhaseKind | ComponentLifecyclePhaseKind;
|
|
68
|
-
declare const ComponentPhaseRelevance:
|
|
69
|
-
|
|
70
|
-
|
|
73
|
+
declare const ComponentPhaseRelevance: birecord0.BiRecord<{
|
|
74
|
+
readonly mount: "unmount";
|
|
75
|
+
readonly setup: "cleanup";
|
|
71
76
|
}>;
|
|
72
77
|
declare const isInversePhase: {
|
|
73
|
-
|
|
74
|
-
|
|
78
|
+
(a: ComponentPhaseKind): (b: ComponentPhaseKind) => boolean;
|
|
79
|
+
(a: ComponentPhaseKind, b: ComponentPhaseKind): boolean;
|
|
75
80
|
};
|
|
76
|
-
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/semantic/semantic-entry.d.ts
|
|
77
83
|
interface SemanticEntry {
|
|
78
|
-
|
|
79
|
-
|
|
84
|
+
node: TSESTree.Node;
|
|
85
|
+
phase: ComponentPhaseKind;
|
|
80
86
|
}
|
|
81
|
-
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/semantic/semantic-node.d.ts
|
|
82
89
|
interface SemanticNode {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
id: unit | TSESTree.Identifier | TSESTree.Identifier[];
|
|
91
|
+
key: string;
|
|
92
|
+
kind: string;
|
|
93
|
+
name: unit | string;
|
|
94
|
+
node: TSESTree.Node;
|
|
95
|
+
flag: bigint;
|
|
96
|
+
hint: bigint;
|
|
90
97
|
}
|
|
91
|
-
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/component/component-flag.d.ts
|
|
92
100
|
type ComponentFlag = bigint;
|
|
93
101
|
declare const ComponentFlag: {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
102
|
+
None: bigint;
|
|
103
|
+
PureComponent: bigint;
|
|
104
|
+
CreateElement: bigint;
|
|
105
|
+
Memo: bigint;
|
|
106
|
+
ForwardRef: bigint;
|
|
107
|
+
Async: bigint;
|
|
100
108
|
};
|
|
101
|
-
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/component/component-semantic-node.d.ts
|
|
102
111
|
interface FunctionComponent extends SemanticNode {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
112
|
+
id: unit | TSESTree.Identifier | TSESTree.Identifier[];
|
|
113
|
+
kind: "function";
|
|
114
|
+
node: AST.TSESTreeFunction;
|
|
115
|
+
flag: ComponentFlag;
|
|
116
|
+
hint: ComponentDetectionHint;
|
|
117
|
+
initPath: unit | AST.FunctionInitPath;
|
|
118
|
+
hookCalls: TSESTree.CallExpression[];
|
|
119
|
+
displayName: unit | TSESTree.Expression;
|
|
111
120
|
}
|
|
112
121
|
interface ClassComponent extends SemanticNode {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
122
|
+
id: unit | TSESTree.Identifier;
|
|
123
|
+
kind: "class";
|
|
124
|
+
node: AST.TSESTreeClass;
|
|
125
|
+
flag: ComponentFlag;
|
|
126
|
+
hint: ComponentDetectionHint;
|
|
127
|
+
methods: AST.TSESTreeMethodOrProperty[];
|
|
128
|
+
displayName: unit | TSESTree.Expression;
|
|
120
129
|
}
|
|
121
130
|
type Component = ClassComponent | FunctionComponent;
|
|
122
|
-
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/component/component-collector.d.ts
|
|
123
133
|
type FunctionEntry = {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
134
|
+
key: string;
|
|
135
|
+
node: AST.TSESTreeFunction;
|
|
136
|
+
hookCalls: TSESTree.CallExpression[];
|
|
137
|
+
isComponent: boolean;
|
|
128
138
|
};
|
|
129
139
|
declare namespace useComponentCollector {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
};
|
|
141
|
-
listeners: ESLintUtils.RuleListener;
|
|
140
|
+
type Options = {
|
|
141
|
+
collectDisplayName?: boolean;
|
|
142
|
+
collectHookCalls?: boolean;
|
|
143
|
+
hint?: ComponentDetectionHint;
|
|
144
|
+
};
|
|
145
|
+
type ReturnType = {
|
|
146
|
+
ctx: {
|
|
147
|
+
getAllComponents: (node: TSESTree.Program) => Map<string, FunctionComponent>;
|
|
148
|
+
getCurrentEntries: () => FunctionEntry[];
|
|
149
|
+
getCurrentEntry: () => FunctionEntry | unit;
|
|
142
150
|
};
|
|
151
|
+
listeners: ESLintUtils.RuleListener;
|
|
152
|
+
};
|
|
143
153
|
}
|
|
144
154
|
/**
|
|
145
155
|
* Get a ctx and listeners for the rule to collect function components
|
|
@@ -148,21 +158,23 @@ declare namespace useComponentCollector {
|
|
|
148
158
|
* @returns The component collector
|
|
149
159
|
*/
|
|
150
160
|
declare function useComponentCollector(context: RuleContext, options?: useComponentCollector.Options): useComponentCollector.ReturnType;
|
|
151
|
-
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region src/component/component-collector-legacy.d.ts
|
|
152
163
|
declare namespace useComponentCollectorLegacy {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
};
|
|
157
|
-
listeners: ESLintUtils.RuleListener;
|
|
164
|
+
type ReturnType = {
|
|
165
|
+
ctx: {
|
|
166
|
+
getAllComponents: (node: TSESTree$1.Program) => Map<string, ClassComponent>;
|
|
158
167
|
};
|
|
168
|
+
listeners: ESLintUtils.RuleListener;
|
|
169
|
+
};
|
|
159
170
|
}
|
|
160
171
|
/**
|
|
161
172
|
* Get a ctx and listeners object for the rule to collect class components
|
|
162
173
|
* @returns The context and listeners for the rule
|
|
163
174
|
*/
|
|
164
175
|
declare function useComponentCollectorLegacy(): useComponentCollectorLegacy.ReturnType;
|
|
165
|
-
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/component/component-definition.d.ts
|
|
166
178
|
/**
|
|
167
179
|
* Check whether given node is a function of a render method of a class component
|
|
168
180
|
* @example
|
|
@@ -176,12 +188,22 @@ declare function useComponentCollectorLegacy(): useComponentCollectorLegacy.Retu
|
|
|
176
188
|
* @returns `true` if node is a render function, `false` if not
|
|
177
189
|
*/
|
|
178
190
|
declare function isFunctionOfRenderMethod(node: AST.TSESTreeFunction): boolean;
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
191
|
+
/**
|
|
192
|
+
* Determines if a function node represents a valid React component definition
|
|
193
|
+
* @param context The rule context
|
|
194
|
+
* @param node The function node to check
|
|
195
|
+
* @param hint Component detection hints as bit flags
|
|
196
|
+
* @returns `true` if the node is a valid component definition, `false` otherwise
|
|
197
|
+
*/
|
|
198
|
+
declare function isComponentDefinition(context: RuleContext, node: AST.TSESTreeFunction, hint: bigint): boolean;
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region src/component/component-id.d.ts
|
|
201
|
+
declare function getFunctionComponentId(context: RuleContext, node: AST.TSESTreeFunction): TSESTree.Identifier | TSESTree.Identifier[] | unit;
|
|
202
|
+
//#endregion
|
|
203
|
+
//#region src/component/component-init-path.d.ts
|
|
183
204
|
declare function getComponentFlagFromInitPath(initPath: FunctionComponent["initPath"]): bigint;
|
|
184
|
-
|
|
205
|
+
//#endregion
|
|
206
|
+
//#region src/component/component-is.d.ts
|
|
185
207
|
/**
|
|
186
208
|
* Check if a node is a React class component
|
|
187
209
|
* @param node The AST node to check
|
|
@@ -194,58 +216,37 @@ declare function isClassComponent(node: TSESTree.Node): node is AST.TSESTreeClas
|
|
|
194
216
|
* @returns `true` if the node is a pure component, `false` otherwise
|
|
195
217
|
*/
|
|
196
218
|
declare function isPureComponent(node: TSESTree.Node): boolean;
|
|
197
|
-
|
|
219
|
+
//#endregion
|
|
220
|
+
//#region src/component/component-kind.d.ts
|
|
198
221
|
type ComponentKind = "classComponent" | "functionComponent";
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
declare
|
|
202
|
-
declare
|
|
203
|
-
declare
|
|
204
|
-
declare
|
|
205
|
-
declare
|
|
206
|
-
declare
|
|
207
|
-
declare
|
|
208
|
-
declare
|
|
209
|
-
declare
|
|
210
|
-
declare
|
|
211
|
-
declare
|
|
212
|
-
declare
|
|
213
|
-
declare
|
|
214
|
-
declare
|
|
215
|
-
declare
|
|
216
|
-
declare
|
|
217
|
-
|
|
222
|
+
//#endregion
|
|
223
|
+
//#region src/component/component-method.d.ts
|
|
224
|
+
declare const isRender: (node: TSESTree.Node) => node is AST.TSESTreeMethodOrProperty;
|
|
225
|
+
declare const isComponentDidCatch: (node: TSESTree.Node) => node is AST.TSESTreeMethodOrProperty;
|
|
226
|
+
declare const isComponentDidMount: (node: TSESTree.Node) => node is AST.TSESTreeMethodOrProperty;
|
|
227
|
+
declare const isComponentDidUpdate: (node: TSESTree.Node) => node is AST.TSESTreeMethodOrProperty;
|
|
228
|
+
declare const isComponentWillMount: (node: TSESTree.Node) => node is AST.TSESTreeMethodOrProperty;
|
|
229
|
+
declare const isComponentWillReceiveProps: (node: TSESTree.Node) => node is AST.TSESTreeMethodOrProperty;
|
|
230
|
+
declare const isComponentWillUnmount: (node: TSESTree.Node) => node is AST.TSESTreeMethodOrProperty;
|
|
231
|
+
declare const isComponentWillUpdate: (node: TSESTree.Node) => node is AST.TSESTreeMethodOrProperty;
|
|
232
|
+
declare const isGetChildContext: (node: TSESTree.Node) => node is AST.TSESTreeMethodOrProperty;
|
|
233
|
+
declare const isGetInitialState: (node: TSESTree.Node) => node is AST.TSESTreeMethodOrProperty;
|
|
234
|
+
declare const isGetSnapshotBeforeUpdate: (node: TSESTree.Node) => node is AST.TSESTreeMethodOrProperty;
|
|
235
|
+
declare const isShouldComponentUpdate: (node: TSESTree.Node) => node is AST.TSESTreeMethodOrProperty;
|
|
236
|
+
declare const isUnsafeComponentWillMount: (node: TSESTree.Node) => node is AST.TSESTreeMethodOrProperty;
|
|
237
|
+
declare const isUnsafeComponentWillReceiveProps: (node: TSESTree.Node) => node is AST.TSESTreeMethodOrProperty;
|
|
238
|
+
declare const isUnsafeComponentWillUpdate: (node: TSESTree.Node) => node is AST.TSESTreeMethodOrProperty;
|
|
239
|
+
declare const isGetDefaultProps: (node: TSESTree.Node) => node is AST.TSESTreeMethodOrProperty;
|
|
240
|
+
declare const isGetDerivedStateFromProps: (node: TSESTree.Node) => node is AST.TSESTreeMethodOrProperty;
|
|
241
|
+
declare const isGetDerivedStateFromError: (node: TSESTree.Node) => node is AST.TSESTreeMethodOrProperty;
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region src/component/component-name.d.ts
|
|
218
244
|
declare function isComponentName(name: string): boolean;
|
|
219
245
|
declare function isComponentNameLoose(name: string): boolean;
|
|
220
|
-
declare function getComponentNameFromId(id: TSESTree.Identifier | TSESTree.Identifier[] |
|
|
246
|
+
declare function getComponentNameFromId(id: TSESTree.Identifier | TSESTree.Identifier[] | unit): string | undefined;
|
|
221
247
|
declare function hasNoneOrLooseComponentName(context: RuleContext, fn: AST.TSESTreeFunction): boolean;
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
* Check whether given node is a render function of a class component
|
|
225
|
-
* @example
|
|
226
|
-
* ```tsx
|
|
227
|
-
* class Component extends React.Component {
|
|
228
|
-
* render() {
|
|
229
|
-
* return <div />;
|
|
230
|
-
* }
|
|
231
|
-
* }
|
|
232
|
-
* ```
|
|
233
|
-
* @param node The AST node to check
|
|
234
|
-
* @returns `true` if node is a render function, `false` if not
|
|
235
|
-
*/
|
|
236
|
-
declare function isRenderLike(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
237
|
-
/**
|
|
238
|
-
* Check whether given node is a function of a render function of a class component
|
|
239
|
-
* @example
|
|
240
|
-
* ```tsx
|
|
241
|
-
* class Component extends React.Component {
|
|
242
|
-
* render = () => <div />;
|
|
243
|
-
* ```
|
|
244
|
-
* @param node The AST node to check
|
|
245
|
-
* @returns `true` if node is a render function, `false` if not
|
|
246
|
-
*/
|
|
247
|
-
declare function isFunctionOfRender(node: AST.TSESTreeFunction): boolean;
|
|
248
|
-
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region src/component/component-render-method.d.ts
|
|
249
250
|
/**
|
|
250
251
|
* Check whether given node is a render method of a class component
|
|
251
252
|
* @example
|
|
@@ -259,7 +260,8 @@ declare function isFunctionOfRender(node: AST.TSESTreeFunction): boolean;
|
|
|
259
260
|
* @returns `true` if node is a render function, `false` if not
|
|
260
261
|
*/
|
|
261
262
|
declare function isRenderMethodLike(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
262
|
-
|
|
263
|
+
//#endregion
|
|
264
|
+
//#region src/component/component-render-prop.d.ts
|
|
263
265
|
/**
|
|
264
266
|
* Unsafe check whether given node is a render function
|
|
265
267
|
* ```tsx
|
|
@@ -309,11 +311,13 @@ declare function isDirectValueOfRenderPropertyLoose(node: TSESTree.Node): boolea
|
|
|
309
311
|
* @returns `true` if component is declared inside a render prop, `false` if not
|
|
310
312
|
*/
|
|
311
313
|
declare function isDeclaredInRenderPropLoose(node: TSESTree.Node): boolean;
|
|
312
|
-
|
|
314
|
+
//#endregion
|
|
315
|
+
//#region src/component/component-state.d.ts
|
|
313
316
|
type ComponentStateKind = "actionState" | "state";
|
|
314
317
|
declare function isThisSetState(node: TSESTree.CallExpression): boolean;
|
|
315
318
|
declare function isAssignmentToThisState(node: TSESTree.AssignmentExpression): boolean;
|
|
316
|
-
|
|
319
|
+
//#endregion
|
|
320
|
+
//#region src/component/component-wrapper.d.ts
|
|
317
321
|
/**
|
|
318
322
|
* Check if the node is a call expression for a component wrapper
|
|
319
323
|
* @param context The ESLint rule context
|
|
@@ -328,39 +332,73 @@ declare function isComponentWrapperCall(context: RuleContext, node: TSESTree.Nod
|
|
|
328
332
|
* @returns `true` if the node is a call expression for a component wrapper loosely
|
|
329
333
|
*/
|
|
330
334
|
declare function isComponentWrapperCallLoose(context: RuleContext, node: TSESTree.Node): boolean;
|
|
331
|
-
|
|
335
|
+
//#endregion
|
|
336
|
+
//#region src/effect/effect-kind.d.ts
|
|
332
337
|
type EffectKind = "useEffect" | "useLayoutEffect" | "useInsertionEffect";
|
|
333
|
-
|
|
338
|
+
//#endregion
|
|
339
|
+
//#region src/hook/hook-semantic-node.d.ts
|
|
334
340
|
interface Hook extends SemanticNode {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
341
|
+
id: TSESTree.Identifier | unit;
|
|
342
|
+
node: AST.TSESTreeFunction;
|
|
343
|
+
name: string;
|
|
344
|
+
hookCalls: TSESTree.CallExpression[];
|
|
339
345
|
}
|
|
340
|
-
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region src/hook/hook-collector.d.ts
|
|
341
348
|
declare namespace useHookCollector {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
};
|
|
346
|
-
listeners: ESLintUtils.RuleListener;
|
|
349
|
+
type ReturnType = {
|
|
350
|
+
ctx: {
|
|
351
|
+
getAllHooks(node: TSESTree$1.Program): Map<string, Hook>;
|
|
347
352
|
};
|
|
353
|
+
listeners: ESLintUtils.RuleListener;
|
|
354
|
+
};
|
|
348
355
|
}
|
|
349
356
|
declare function useHookCollector(): useHookCollector.ReturnType;
|
|
350
|
-
|
|
357
|
+
//#endregion
|
|
358
|
+
//#region src/hook/hook-id.d.ts
|
|
351
359
|
declare function isReactHookId(id: TSESTree.Identifier | TSESTree.MemberExpression): boolean;
|
|
352
|
-
|
|
353
|
-
|
|
360
|
+
//#endregion
|
|
361
|
+
//#region src/hook/hook-is.d.ts
|
|
362
|
+
/**
|
|
363
|
+
* Determines if a function node is a React Hook based on its name.
|
|
364
|
+
* @param node The function node to check
|
|
365
|
+
* @returns True if the function is a React Hook, false otherwise
|
|
366
|
+
*/
|
|
367
|
+
declare function isReactHook(node: AST.TSESTreeFunction | unit): boolean;
|
|
354
368
|
/**
|
|
355
369
|
* Check if the given node is a React Hook call by its name.
|
|
356
370
|
* @param node The node to check.
|
|
357
371
|
* @returns `true` if the node is a React Hook call, `false` otherwise.
|
|
358
372
|
*/
|
|
359
|
-
declare function isReactHookCall(node: TSESTree.Node |
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
373
|
+
declare function isReactHookCall(node: TSESTree.Node | unit): boolean;
|
|
374
|
+
/**
|
|
375
|
+
* Checks if a node is a call to a specific React hook, with React import validation.
|
|
376
|
+
* Returns a function that accepts a hook name to check against.
|
|
377
|
+
* @param context The rule context
|
|
378
|
+
* @param node The AST node to check
|
|
379
|
+
* @returns A function that takes a hook name and returns boolean
|
|
380
|
+
*/
|
|
381
|
+
declare function isReactHookCallWithName(context: RuleContext, node: TSESTree.Node | unit): (name: string) => boolean;
|
|
382
|
+
/**
|
|
383
|
+
* Lightweight version of isReactHookCallWithName that doesn't check imports.
|
|
384
|
+
* @param node The AST node to check
|
|
385
|
+
* @returns A function that takes a hook name and returns boolean
|
|
386
|
+
*/
|
|
387
|
+
declare function isReactHookCallWithNameLoose(node: TSESTree.Node | unit): (name: string) => boolean;
|
|
388
|
+
/**
|
|
389
|
+
* Checks if a node is a call to a specific React hook or one of its aliases.
|
|
390
|
+
* @param context The rule context
|
|
391
|
+
* @param name The primary hook name to check
|
|
392
|
+
* @param alias Optional array of alias names to also accept
|
|
393
|
+
* @returns Function that checks if a node matches the hook name or aliases
|
|
394
|
+
*/
|
|
395
|
+
declare function isReactHookCallWithNameAlias(context: RuleContext, name: string, alias?: unit | string[]): (node: TSESTree.CallExpression) => boolean;
|
|
396
|
+
/**
|
|
397
|
+
* Detects useEffect calls and variations (useLayoutEffect, etc.) using regex pattern.
|
|
398
|
+
* @param node The AST node to check
|
|
399
|
+
* @returns True if the node is a useEffect-like call
|
|
400
|
+
*/
|
|
401
|
+
declare function isUseEffectCallLoose(node: TSESTree.Node | unit): boolean;
|
|
364
402
|
declare const isUseCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
365
403
|
declare const isUseActionStateCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
366
404
|
declare const isUseCallbackCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
@@ -380,9 +418,9 @@ declare const isUseRefCall: (context: RuleContext, node: TSESTree.Node | undefin
|
|
|
380
418
|
declare const isUseStateCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
381
419
|
declare const isUseSyncExternalStoreCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
382
420
|
declare const isUseTransitionCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
421
|
+
//#endregion
|
|
422
|
+
//#region src/hook/hook-name.d.ts
|
|
423
|
+
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"];
|
|
386
424
|
/**
|
|
387
425
|
* Catch all identifiers that begin with "use" followed by an uppercase Latin
|
|
388
426
|
* character to exclude identifiers like "user".
|
|
@@ -390,17 +428,21 @@ type HookKind = "custom" | "useActionState" | "useCallback" | "useContext" | "us
|
|
|
390
428
|
* @see https://github.com/facebook/react/blob/1d6c8168db1d82713202e842df3167787ffa00ed/packages/eslint-plugin-react-hooks/src/rules/RulesOfHooks.ts#L16
|
|
391
429
|
*/
|
|
392
430
|
declare function isReactHookName(name: string): boolean;
|
|
393
|
-
|
|
431
|
+
//#endregion
|
|
432
|
+
//#region src/jsx/jsx-attribute.d.ts
|
|
394
433
|
/**
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
* @param
|
|
399
|
-
* @param
|
|
400
|
-
* @
|
|
434
|
+
* Searches for a specific JSX attribute by name in a list of attributes
|
|
435
|
+
* Returns the last matching attribute (rightmost in JSX)
|
|
436
|
+
*
|
|
437
|
+
* @param context - ESLint rule context
|
|
438
|
+
* @param name - The name of the attribute to find
|
|
439
|
+
* @param attributes - Array of JSX attributes to search through
|
|
440
|
+
* @param initialScope - Optional scope for resolving variables
|
|
441
|
+
* @returns The found attribute or undefined
|
|
401
442
|
*/
|
|
402
|
-
declare function getAttribute(context: RuleContext, name: string, attributes: (TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute)[], initialScope?: Scope): TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute |
|
|
403
|
-
|
|
443
|
+
declare function getAttribute(context: RuleContext, name: string, attributes: (TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute)[], initialScope?: Scope): TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute | unit;
|
|
444
|
+
//#endregion
|
|
445
|
+
//#region src/jsx/jsx-attribute-name.d.ts
|
|
404
446
|
/**
|
|
405
447
|
* Get the stringified name of a JSX attribute
|
|
406
448
|
* @param context The ESLint rule context
|
|
@@ -408,112 +450,306 @@ declare function getAttribute(context: RuleContext, name: string, attributes: (T
|
|
|
408
450
|
* @returns The name of the attribute
|
|
409
451
|
*/
|
|
410
452
|
declare function getAttributeName(context: RuleContext, node: TSESTree$1.JSXAttribute): string;
|
|
411
|
-
|
|
453
|
+
//#endregion
|
|
454
|
+
//#region src/jsx/jsx-attribute-value.d.ts
|
|
412
455
|
/**
|
|
413
|
-
*
|
|
414
|
-
* @param context
|
|
415
|
-
* @param node
|
|
416
|
-
* @param name
|
|
417
|
-
* @returns The
|
|
456
|
+
* Extracts the value of a JSX attribute by name
|
|
457
|
+
* @param context - ESLint rule context
|
|
458
|
+
* @param node - JSX attribute or spread attribute node
|
|
459
|
+
* @param name - Name of the attribute to extract
|
|
460
|
+
* @returns The extracted attribute value in a structured format
|
|
418
461
|
*/
|
|
419
462
|
declare function getAttributeValue(context: RuleContext, node: TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute, name: string): Exclude<VAR.LazyValue, {
|
|
420
|
-
|
|
463
|
+
kind: "lazy";
|
|
421
464
|
}>;
|
|
422
|
-
|
|
465
|
+
//#endregion
|
|
466
|
+
//#region src/jsx/jsx-detection-hint.d.ts
|
|
467
|
+
/**
|
|
468
|
+
* BitFlags for configuring JSX detection behavior
|
|
469
|
+
* Uses BigInt for bit operations to support many flags
|
|
470
|
+
*/
|
|
423
471
|
type JSXDetectionHint = bigint;
|
|
472
|
+
/**
|
|
473
|
+
* Flags to control JSX detection behavior:
|
|
474
|
+
* - Skip* flags: Ignore specific node types when detecting JSX
|
|
475
|
+
* - Strict* flags: Enforce stricter rules for container types
|
|
476
|
+
*/
|
|
424
477
|
declare const JSXDetectionHint: {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
478
|
+
readonly None: 0n;
|
|
479
|
+
readonly SkipUndefined: bigint;
|
|
480
|
+
readonly SkipNullLiteral: bigint;
|
|
481
|
+
readonly SkipBooleanLiteral: bigint;
|
|
482
|
+
readonly SkipStringLiteral: bigint;
|
|
483
|
+
readonly SkipNumberLiteral: bigint;
|
|
484
|
+
readonly SkipBigIntLiteral: bigint;
|
|
485
|
+
readonly SkipEmptyArray: bigint;
|
|
486
|
+
readonly SkipCreateElement: bigint;
|
|
487
|
+
readonly StrictArray: bigint;
|
|
488
|
+
readonly StrictLogical: bigint;
|
|
489
|
+
readonly StrictConditional: bigint;
|
|
437
490
|
};
|
|
491
|
+
/**
|
|
492
|
+
* Default JSX detection configuration
|
|
493
|
+
* Skips undefined and boolean literals (common in React)
|
|
494
|
+
*/
|
|
438
495
|
declare const DEFAULT_JSX_DETECTION_HINT: bigint;
|
|
439
|
-
|
|
496
|
+
//#endregion
|
|
497
|
+
//#region src/jsx/jsx-detection.d.ts
|
|
440
498
|
/**
|
|
441
|
-
*
|
|
499
|
+
* Checks if a node is a `JSXText` or a `Literal` node
|
|
442
500
|
* @param node The AST node to check
|
|
443
501
|
* @returns `true` if the node is a `JSXText` or a `Literal` node
|
|
444
502
|
*/
|
|
445
|
-
declare function isJsxText(node: TSESTree$1.Node | null |
|
|
503
|
+
declare function isJsxText(node: TSESTree$1.Node | null | unit): node is TSESTree$1.JSXText | TSESTree$1.Literal;
|
|
446
504
|
/**
|
|
447
|
-
*
|
|
448
|
-
*
|
|
505
|
+
* Determines if a node represents JSX-like content based on heuristics
|
|
506
|
+
* Supports configuration through hint flags to customize detection behavior
|
|
507
|
+
*
|
|
508
|
+
* @param code The source code with scope lookup capability
|
|
449
509
|
* @param code.getScope The function to get the scope of a node
|
|
450
|
-
* @param node The AST node to
|
|
451
|
-
* @param hint The
|
|
452
|
-
* @returns boolean
|
|
510
|
+
* @param node The AST node to analyze
|
|
511
|
+
* @param hint The configuration flags to adjust detection behavior
|
|
512
|
+
* @returns boolean Whether the node is considered JSX-like
|
|
453
513
|
*/
|
|
454
514
|
declare function isJsxLike(code: {
|
|
455
|
-
|
|
456
|
-
}, node: TSESTree$1.Node |
|
|
457
|
-
|
|
515
|
+
getScope: (node: TSESTree$1.Node) => Scope;
|
|
516
|
+
}, node: TSESTree$1.Node | unit | null, hint?: JSXDetectionHint): boolean;
|
|
517
|
+
//#endregion
|
|
518
|
+
//#region src/jsx/jsx-element-is.d.ts
|
|
458
519
|
/**
|
|
459
|
-
*
|
|
460
|
-
*
|
|
461
|
-
*
|
|
462
|
-
* @
|
|
520
|
+
* Determines if a JSX element is a host element
|
|
521
|
+
* Host elements in React start with lowercase letters (e.g., div, span)
|
|
522
|
+
*
|
|
523
|
+
* @param context - ESLint rule context
|
|
524
|
+
* @param node - AST node to check
|
|
525
|
+
* @returns boolean indicating if the element is a host element
|
|
526
|
+
*/
|
|
527
|
+
declare function isHostElement(context: RuleContext, node: TSESTree.Node): boolean;
|
|
528
|
+
/**
|
|
529
|
+
* Determines if a JSX element is a React Fragment
|
|
530
|
+
* Fragments can be imported from React and used like <Fragment> or <React.Fragment>
|
|
531
|
+
*
|
|
532
|
+
* @param context - ESLint rule context
|
|
533
|
+
* @param node - AST node to check
|
|
534
|
+
* @returns boolean indicating if the element is a Fragment with type narrowing
|
|
535
|
+
*/
|
|
536
|
+
declare function isFragmentElement(context: RuleContext, node: TSESTree.Node): node is TSESTree.JSXElement;
|
|
537
|
+
//#endregion
|
|
538
|
+
//#region src/jsx/jsx-element-type.d.ts
|
|
539
|
+
/**
|
|
540
|
+
* Extracts the element type name from a JSX element or fragment
|
|
541
|
+
* For JSX elements, returns the stringified name (e.g., "div", "Button", "React.Fragment")
|
|
542
|
+
* For JSX fragments, returns an empty string
|
|
543
|
+
*
|
|
544
|
+
* @param context - ESLint rule context
|
|
545
|
+
* @param node - JSX element or fragment node
|
|
546
|
+
* @returns String representation of the element type
|
|
463
547
|
*/
|
|
464
548
|
declare function getElementType(context: RuleContext, node: TSESTree.JSXElement | TSESTree.JSXFragment): string;
|
|
465
|
-
|
|
549
|
+
//#endregion
|
|
550
|
+
//#region src/jsx/jsx-has.d.ts
|
|
551
|
+
/**
|
|
552
|
+
* Checks if a JSX element has a specific attribute
|
|
553
|
+
*
|
|
554
|
+
* @param context - ESLint rule context
|
|
555
|
+
* @param name - Name of the attribute to check for
|
|
556
|
+
* @param attributes - List of JSX attributes from opening element
|
|
557
|
+
* @param initialScope - Optional scope for resolving variables in spread attributes
|
|
558
|
+
* @returns boolean indicating whether the attribute exists
|
|
559
|
+
*/
|
|
466
560
|
declare function hasAttribute(context: RuleContext, name: string, attributes: TSESTree.JSXOpeningElement["attributes"], initialScope?: Scope): boolean;
|
|
561
|
+
/**
|
|
562
|
+
* Checks if a JSX element has at least one of the specified attributes
|
|
563
|
+
*
|
|
564
|
+
* @param context - ESLint rule context
|
|
565
|
+
* @param names - Array of attribute names to check for
|
|
566
|
+
* @param attributes - List of JSX attributes from opening element
|
|
567
|
+
* @param initialScope - Optional scope for resolving variables in spread attributes
|
|
568
|
+
* @returns boolean indicating whether any of the attributes exist
|
|
569
|
+
*/
|
|
467
570
|
declare function hasAnyAttribute(context: RuleContext, names: string[], attributes: TSESTree.JSXOpeningElement["attributes"], initialScope?: Scope): boolean;
|
|
571
|
+
/**
|
|
572
|
+
* Checks if a JSX element has all of the specified attributes
|
|
573
|
+
*
|
|
574
|
+
* @param context - ESLint rule context
|
|
575
|
+
* @param names - Array of attribute names to check for
|
|
576
|
+
* @param attributes - List of JSX attributes from opening element
|
|
577
|
+
* @param initialScope - Optional scope for resolving variables in spread attributes
|
|
578
|
+
* @returns boolean indicating whether all of the attributes exist
|
|
579
|
+
*/
|
|
468
580
|
declare function hasEveryAttribute(context: RuleContext, names: string[], attributes: TSESTree.JSXOpeningElement["attributes"], initialScope?: Scope): boolean;
|
|
469
|
-
|
|
581
|
+
//#endregion
|
|
582
|
+
//#region src/jsx/jsx-hierarchy.d.ts
|
|
470
583
|
/**
|
|
471
|
-
*
|
|
472
|
-
*
|
|
473
|
-
* @param
|
|
474
|
-
* @
|
|
584
|
+
* Traverses up the AST to find a parent JSX attribute node that matches a given test
|
|
585
|
+
*
|
|
586
|
+
* @param node - The starting AST node
|
|
587
|
+
* @param test - Optional predicate function to test if the attribute meets criteria
|
|
588
|
+
* Defaults to always returning true (matches any attribute)
|
|
589
|
+
* @returns The first matching JSX attribute node found when traversing upwards, or undefined
|
|
475
590
|
*/
|
|
476
|
-
declare function findParentAttribute(node: TSESTree.Node, test?: (node: TSESTree.JSXAttribute) => boolean): TSESTree.JSXAttribute |
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
declare function isKeyedElement(context: RuleContext, node: TSESTree.Node, initialScope?: Scope): boolean;
|
|
480
|
-
declare function isFragmentElement(context: RuleContext, node: TSESTree.Node | null | _, allowJSXFragment?: false): node is TSESTree.JSXElement;
|
|
481
|
-
declare function isFragmentElement(context: RuleContext, node: TSESTree.Node | null | _, allowJSXFragment?: true): node is TSESTree.JSXElement | TSESTree.JSXFragment;
|
|
482
|
-
|
|
591
|
+
declare function findParentAttribute(node: TSESTree.Node, test?: (node: TSESTree.JSXAttribute) => boolean): TSESTree.JSXAttribute | unit;
|
|
592
|
+
//#endregion
|
|
593
|
+
//#region src/jsx/jsx-stringify.d.ts
|
|
483
594
|
/**
|
|
484
|
-
*
|
|
485
|
-
*
|
|
486
|
-
*
|
|
595
|
+
* Converts a JSX AST node to its string representation
|
|
596
|
+
* Handles different JSX node types and returns their textual form
|
|
597
|
+
*
|
|
598
|
+
* @param node - JSX node from TypeScript ESTree
|
|
599
|
+
* @returns String representation of the JSX node
|
|
487
600
|
*/
|
|
488
601
|
declare function stringifyJsx(node: TSESTree$1.JSXIdentifier | TSESTree$1.JSXMemberExpression | TSESTree$1.JSXNamespacedName | TSESTree$1.JSXOpeningElement | TSESTree$1.JSXClosingElement | TSESTree$1.JSXOpeningFragment | TSESTree$1.JSXClosingFragment | TSESTree$1.JSXText): string;
|
|
489
|
-
|
|
602
|
+
//#endregion
|
|
603
|
+
//#region src/type/type-is.d.ts
|
|
604
|
+
/** @internal */
|
|
605
|
+
declare const isAnyType: (type: ts.Type) => boolean;
|
|
606
|
+
/** @internal */
|
|
607
|
+
declare const isBigIntType: (type: ts.Type) => boolean;
|
|
608
|
+
/** @internal */
|
|
609
|
+
declare const isBooleanType: (type: ts.Type) => boolean;
|
|
610
|
+
/** @internal */
|
|
611
|
+
declare const isEnumType: (type: ts.Type) => boolean;
|
|
612
|
+
/** @internal */
|
|
613
|
+
declare const isFalsyBigIntType: (type: ts.Type) => type is ts.LiteralType & {
|
|
614
|
+
freshType: ts.FreshableType;
|
|
615
|
+
regularType: ts.FreshableType;
|
|
616
|
+
flags: ts.TypeFlags;
|
|
617
|
+
symbol: ts.Symbol;
|
|
618
|
+
pattern?: ts.DestructuringPattern;
|
|
619
|
+
aliasSymbol?: ts.Symbol;
|
|
620
|
+
aliasTypeArguments?: readonly ts.Type[];
|
|
621
|
+
getFlags: () => ts.TypeFlags;
|
|
622
|
+
getSymbol: () => ts.Symbol | undefined;
|
|
623
|
+
getProperties: () => ts.Symbol[];
|
|
624
|
+
getProperty: (propertyName: string) => ts.Symbol | undefined;
|
|
625
|
+
getApparentProperties: () => ts.Symbol[];
|
|
626
|
+
getCallSignatures: () => readonly ts.Signature[];
|
|
627
|
+
getConstructSignatures: () => readonly ts.Signature[];
|
|
628
|
+
getStringIndexType: () => ts.Type | undefined;
|
|
629
|
+
getNumberIndexType: () => ts.Type | undefined;
|
|
630
|
+
getBaseTypes: () => ts.BaseType[] | undefined;
|
|
631
|
+
getNonNullableType: () => ts.Type;
|
|
632
|
+
getConstraint: () => ts.Type | undefined;
|
|
633
|
+
getDefault: () => ts.Type | undefined;
|
|
634
|
+
isUnion: () => this is ts.UnionType;
|
|
635
|
+
isIntersection: () => this is ts.IntersectionType;
|
|
636
|
+
isUnionOrIntersection: () => this is ts.UnionOrIntersectionType;
|
|
637
|
+
isLiteral: () => this is ts.LiteralType;
|
|
638
|
+
isStringLiteral: () => this is ts.StringLiteralType;
|
|
639
|
+
isNumberLiteral: () => this is ts.NumberLiteralType;
|
|
640
|
+
isTypeParameter: () => this is ts.TypeParameter;
|
|
641
|
+
isClassOrInterface: () => this is ts.InterfaceType;
|
|
642
|
+
isClass: () => this is ts.InterfaceType;
|
|
643
|
+
isIndexType: () => this is ts.IndexType;
|
|
644
|
+
value: {
|
|
645
|
+
negative: boolean;
|
|
646
|
+
base10Value: "0";
|
|
647
|
+
};
|
|
648
|
+
};
|
|
649
|
+
/** @internal */
|
|
650
|
+
declare const isFalsyNumberType: (type: ts.Type) => boolean;
|
|
651
|
+
/** @internal */
|
|
652
|
+
declare const isFalsyStringType: (type: ts.Type) => boolean;
|
|
653
|
+
/** @internal */
|
|
654
|
+
declare const isNeverType: (type: ts.Type) => boolean;
|
|
655
|
+
/** @internal */
|
|
656
|
+
declare const isNullishType: (type: ts.Type) => boolean;
|
|
657
|
+
/** @internal */
|
|
658
|
+
declare const isNumberType: (type: ts.Type) => boolean;
|
|
659
|
+
/** @internal */
|
|
660
|
+
declare const isObjectType: (type: ts.Type) => boolean;
|
|
661
|
+
/** @internal */
|
|
662
|
+
declare const isStringType: (type: ts.Type) => boolean;
|
|
663
|
+
/** @internal */
|
|
664
|
+
declare const isTruthyBigIntType: (type: ts.Type) => type is ts.LiteralType & {
|
|
665
|
+
freshType: ts.FreshableType;
|
|
666
|
+
regularType: ts.FreshableType;
|
|
667
|
+
flags: ts.TypeFlags;
|
|
668
|
+
symbol: ts.Symbol;
|
|
669
|
+
pattern?: ts.DestructuringPattern;
|
|
670
|
+
aliasSymbol?: ts.Symbol;
|
|
671
|
+
aliasTypeArguments?: readonly ts.Type[];
|
|
672
|
+
getFlags: () => ts.TypeFlags;
|
|
673
|
+
getSymbol: () => ts.Symbol | undefined;
|
|
674
|
+
getProperties: () => ts.Symbol[];
|
|
675
|
+
getProperty: (propertyName: string) => ts.Symbol | undefined;
|
|
676
|
+
getApparentProperties: () => ts.Symbol[];
|
|
677
|
+
getCallSignatures: () => readonly ts.Signature[];
|
|
678
|
+
getConstructSignatures: () => readonly ts.Signature[];
|
|
679
|
+
getStringIndexType: () => ts.Type | undefined;
|
|
680
|
+
getNumberIndexType: () => ts.Type | undefined;
|
|
681
|
+
getBaseTypes: () => ts.BaseType[] | undefined;
|
|
682
|
+
getNonNullableType: () => ts.Type;
|
|
683
|
+
getConstraint: () => ts.Type | undefined;
|
|
684
|
+
getDefault: () => ts.Type | undefined;
|
|
685
|
+
isUnion: () => this is ts.UnionType;
|
|
686
|
+
isIntersection: () => this is ts.IntersectionType;
|
|
687
|
+
isUnionOrIntersection: () => this is ts.UnionOrIntersectionType;
|
|
688
|
+
isLiteral: () => this is ts.LiteralType;
|
|
689
|
+
isStringLiteral: () => this is ts.StringLiteralType;
|
|
690
|
+
isNumberLiteral: () => this is ts.NumberLiteralType;
|
|
691
|
+
isTypeParameter: () => this is ts.TypeParameter;
|
|
692
|
+
isClassOrInterface: () => this is ts.InterfaceType;
|
|
693
|
+
isClass: () => this is ts.InterfaceType;
|
|
694
|
+
isIndexType: () => this is ts.IndexType;
|
|
695
|
+
value: ts.PseudoBigInt;
|
|
696
|
+
};
|
|
697
|
+
/** @internal */
|
|
698
|
+
declare const isTruthyNumberType: (type: ts.Type) => boolean;
|
|
490
699
|
/** @internal */
|
|
700
|
+
declare const isTruthyStringType: (type: ts.Type) => boolean;
|
|
701
|
+
/** @internal */
|
|
702
|
+
declare const isUnknownType: (type: ts.Type) => boolean;
|
|
703
|
+
//#endregion
|
|
704
|
+
//#region src/type/type-variant.d.ts
|
|
705
|
+
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";
|
|
706
|
+
/**
|
|
707
|
+
* Ported from https://github.com/typescript-eslint/typescript-eslint/blob/eb736bbfc22554694400e6a4f97051d845d32e0b/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts#L826 with some enhancements
|
|
708
|
+
* Get the variants of an array of types.
|
|
709
|
+
* @param types The types to get the variants of
|
|
710
|
+
* @returns The variants of the types
|
|
711
|
+
* @internal
|
|
712
|
+
*/
|
|
713
|
+
declare function getTypeVariants(types: ts.Type[]): Set<TypeVariant>;
|
|
714
|
+
//#endregion
|
|
715
|
+
//#region src/utils/get-instance-id.d.ts
|
|
716
|
+
/**
|
|
717
|
+
* Gets the identifier node of an instance based on AST node relationships.
|
|
718
|
+
* Used for tracking where hooks or components are being assigned in the code.
|
|
719
|
+
* @param node The current AST node to evaluate
|
|
720
|
+
* @param prev The previous AST node in the traversal (used for context)
|
|
721
|
+
* @internal
|
|
722
|
+
*/
|
|
491
723
|
declare function getInstanceId(node: TSESTree.Node, prev?: TSESTree.Node): TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpression | TSESTree.AssignmentExpression | TSESTree.AwaitExpression | TSESTree.BinaryExpression | TSESTree.CallExpression | TSESTree.ChainExpression | TSESTree.ClassExpression | TSESTree.ConditionalExpression | TSESTree.FunctionExpression | TSESTree.Identifier | TSESTree.ImportExpression | TSESTree.JSXElement | TSESTree.JSXFragment | TSESTree.BigIntLiteral | TSESTree.BooleanLiteral | TSESTree.NullLiteral | TSESTree.NumberLiteral | TSESTree.RegExpLiteral | TSESTree.StringLiteral | TSESTree.LogicalExpression | TSESTree.MemberExpressionComputedName | TSESTree.MemberExpressionNonComputedName | TSESTree.MetaProperty | TSESTree.NewExpression | TSESTree.ObjectExpression | TSESTree.ObjectPattern | TSESTree.PrivateIdentifier | TSESTree.SequenceExpression | TSESTree.Super | TSESTree.TaggedTemplateExpression | TSESTree.TemplateLiteral | TSESTree.ThisExpression | TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion | TSESTree.UnaryExpression | TSESTree.UpdateExpression | TSESTree.YieldExpression | undefined;
|
|
492
|
-
|
|
724
|
+
//#endregion
|
|
725
|
+
//#region src/utils/is-from-react.d.ts
|
|
493
726
|
/**
|
|
494
|
-
* Check if an identifier is initialized from react
|
|
727
|
+
* Check if an identifier name is initialized from react
|
|
495
728
|
* @param name The top-level identifier's name
|
|
496
729
|
* @param importSource The import source to check against
|
|
497
730
|
* @param initialScope Initial scope to search for the identifier
|
|
498
|
-
* @returns Whether the identifier is initialized from react
|
|
731
|
+
* @returns Whether the identifier name is initialized from react
|
|
732
|
+
* @internal
|
|
499
733
|
*/
|
|
500
734
|
declare function isInitializedFromReact(name: string, importSource: string, initialScope: Scope): boolean;
|
|
501
|
-
|
|
735
|
+
//#endregion
|
|
736
|
+
//#region src/utils/is-instance-id-equal.d.ts
|
|
502
737
|
/** @internal */
|
|
503
738
|
declare function isInstanceIdEqual(context: RuleContext, a: TSESTree.Node, b: TSESTree.Node): boolean;
|
|
504
|
-
|
|
739
|
+
//#endregion
|
|
740
|
+
//#region src/utils/is-react-api.d.ts
|
|
505
741
|
declare namespace isReactAPI {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
742
|
+
type ReturnType = {
|
|
743
|
+
(context: RuleContext, node: unit | null | TSESTree.Node): node is TSESTree.Identifier | TSESTree.MemberExpression;
|
|
744
|
+
(context: RuleContext): (node: unit | null | TSESTree.Node) => node is TSESTree.MemberExpression | TSESTree.Identifier;
|
|
745
|
+
};
|
|
510
746
|
}
|
|
511
747
|
declare function isReactAPI(api: string): isReactAPI.ReturnType;
|
|
512
748
|
declare namespace isReactAPICall {
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
749
|
+
type ReturnType = {
|
|
750
|
+
(context: RuleContext, node: unit | null | TSESTree.Node): node is TSESTree.CallExpression;
|
|
751
|
+
(context: RuleContext): (node: unit | null | TSESTree.Node) => node is TSESTree.CallExpression;
|
|
752
|
+
};
|
|
517
753
|
}
|
|
518
754
|
declare function isReactAPICall(api: string): isReactAPICall.ReturnType;
|
|
519
755
|
declare const isCaptureOwnerStack: isReactAPI.ReturnType;
|
|
@@ -542,5 +778,5 @@ declare const isCreateRefCall: isReactAPICall.ReturnType;
|
|
|
542
778
|
declare const isForwardRefCall: isReactAPICall.ReturnType;
|
|
543
779
|
declare const isMemoCall: isReactAPICall.ReturnType;
|
|
544
780
|
declare const isLazyCall: isReactAPICall.ReturnType;
|
|
545
|
-
|
|
546
|
-
export {
|
|
781
|
+
//#endregion
|
|
782
|
+
export { ClassComponent, Component, ComponentDetectionHint, ComponentEffectPhaseKind, ComponentFlag, ComponentKind, ComponentLifecyclePhaseKind, ComponentPhaseKind, ComponentPhaseRelevance, ComponentStateKind, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, EffectKind, FunctionComponent, Hook, JSXDetectionHint, REACT_BUILTIN_HOOK_NAMES, SemanticEntry, SemanticNode, TypeVariant, findParentAttribute, getAttribute, getAttributeName, getAttributeValue, getComponentFlagFromInitPath, getComponentNameFromId, getElementType, getFunctionComponentId, getInstanceId, getTypeVariants, hasAnyAttribute, hasAttribute, hasEveryAttribute, hasNoneOrLooseComponentName, isAnyType, isAssignmentToThisState, isBigIntType, isBooleanType, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDefinition, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isEnumType, isFalseLiteralType, isFalsyBigIntType, isFalsyNumberType, isFalsyStringType, isForwardRef, isForwardRefCall, isFragmentElement, isFunctionOfRenderMethod, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isHostElement, isInitializedFromReact, isInstanceIdEqual, isInversePhase, isJsxLike, isJsxText, isLazy, isLazyCall, isMemo, isMemoCall, isNeverType, isNullishType, isNumberType, isObjectType, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookId, isReactHookName, isRender, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isShouldComponentUpdate, isStringType, isThisSetState, isTrueLiteralType, isTruthyBigIntType, isTruthyNumberType, isTruthyStringType, isUnknownType, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, stringifyJsx, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
|