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