@eslint-react/core 2.0.0-next.9 → 2.0.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +479 -292
- package/dist/index.js +1140 -864
- package/package.json +14 -14
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { Scope } from
|
|
8
|
-
import * as
|
|
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 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
|
|
10
11
|
/**
|
|
11
12
|
* Determines whether inside `createElement`'s children.
|
|
12
13
|
* @param context The rule context
|
|
@@ -14,132 +15,135 @@ import * as VAR from '@eslint-react/var';
|
|
|
14
15
|
* @returns `true` if the node is inside createElement's children
|
|
15
16
|
*/
|
|
16
17
|
declare function isChildrenOfCreateElement(context: RuleContext, node: TSESTree.Node): boolean;
|
|
17
|
-
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/component/component-detection-hint.d.ts
|
|
18
20
|
type ComponentDetectionHint = bigint;
|
|
19
21
|
/**
|
|
20
22
|
* Hints for component collector
|
|
21
23
|
*/
|
|
22
24
|
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
|
-
|
|
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;
|
|
59
61
|
};
|
|
60
62
|
/**
|
|
61
63
|
* Default component detection hint
|
|
62
64
|
*/
|
|
63
65
|
declare const DEFAULT_COMPONENT_DETECTION_HINT: bigint;
|
|
64
|
-
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/component/component-phase.d.ts
|
|
65
68
|
type ComponentEffectPhaseKind = "cleanup" | "setup";
|
|
66
69
|
type ComponentLifecyclePhaseKind = "mount" | "unmount";
|
|
67
70
|
type ComponentPhaseKind = ComponentEffectPhaseKind | ComponentLifecyclePhaseKind;
|
|
68
|
-
declare const ComponentPhaseRelevance:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
declare const ComponentPhaseRelevance: birecord0.BiRecord<{
|
|
72
|
+
readonly mount: "unmount";
|
|
73
|
+
readonly setup: "cleanup";
|
|
71
74
|
}>;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
(a: ComponentPhaseKind, b: ComponentPhaseKind): boolean;
|
|
75
|
-
};
|
|
76
|
-
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/semantic/semantic-entry.d.ts
|
|
77
77
|
interface SemanticEntry {
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
node: TSESTree.Node;
|
|
79
|
+
phase: ComponentPhaseKind;
|
|
80
80
|
}
|
|
81
|
-
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/semantic/semantic-node.d.ts
|
|
82
83
|
interface SemanticNode {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
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;
|
|
90
91
|
}
|
|
91
|
-
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/component/component-flag.d.ts
|
|
92
94
|
type ComponentFlag = bigint;
|
|
93
95
|
declare const ComponentFlag: {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
None: bigint;
|
|
97
|
+
PureComponent: bigint;
|
|
98
|
+
CreateElement: bigint;
|
|
99
|
+
Memo: bigint;
|
|
100
|
+
ForwardRef: bigint;
|
|
101
|
+
Async: bigint;
|
|
100
102
|
};
|
|
101
|
-
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/component/component-semantic-node.d.ts
|
|
102
105
|
interface FunctionComponent extends SemanticNode {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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;
|
|
111
114
|
}
|
|
112
115
|
interface ClassComponent extends SemanticNode {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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;
|
|
120
123
|
}
|
|
121
124
|
type Component = ClassComponent | FunctionComponent;
|
|
122
|
-
|
|
125
|
+
//#endregion
|
|
126
|
+
//#region src/component/component-collector.d.ts
|
|
123
127
|
type FunctionEntry = {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
+
key: string;
|
|
129
|
+
node: AST.TSESTreeFunction;
|
|
130
|
+
hookCalls: TSESTree.CallExpression[];
|
|
131
|
+
isComponent: boolean;
|
|
128
132
|
};
|
|
129
133
|
declare namespace useComponentCollector {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
};
|
|
141
|
-
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;
|
|
142
144
|
};
|
|
145
|
+
listeners: ESLintUtils.RuleListener;
|
|
146
|
+
};
|
|
143
147
|
}
|
|
144
148
|
/**
|
|
145
149
|
* Get a ctx and listeners for the rule to collect function components
|
|
@@ -148,21 +152,23 @@ declare namespace useComponentCollector {
|
|
|
148
152
|
* @returns The component collector
|
|
149
153
|
*/
|
|
150
154
|
declare function useComponentCollector(context: RuleContext, options?: useComponentCollector.Options): useComponentCollector.ReturnType;
|
|
151
|
-
|
|
155
|
+
//#endregion
|
|
156
|
+
//#region src/component/component-collector-legacy.d.ts
|
|
152
157
|
declare namespace useComponentCollectorLegacy {
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
};
|
|
157
|
-
listeners: ESLintUtils.RuleListener;
|
|
158
|
+
type ReturnType = {
|
|
159
|
+
ctx: {
|
|
160
|
+
getAllComponents: (node: TSESTree$1.Program) => Map<string, ClassComponent>;
|
|
158
161
|
};
|
|
162
|
+
listeners: ESLintUtils.RuleListener;
|
|
163
|
+
};
|
|
159
164
|
}
|
|
160
165
|
/**
|
|
161
166
|
* Get a ctx and listeners object for the rule to collect class components
|
|
162
167
|
* @returns The context and listeners for the rule
|
|
163
168
|
*/
|
|
164
169
|
declare function useComponentCollectorLegacy(): useComponentCollectorLegacy.ReturnType;
|
|
165
|
-
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region src/component/component-definition.d.ts
|
|
166
172
|
/**
|
|
167
173
|
* Check whether given node is a function of a render method of a class component
|
|
168
174
|
* @example
|
|
@@ -176,12 +182,22 @@ declare function useComponentCollectorLegacy(): useComponentCollectorLegacy.Retu
|
|
|
176
182
|
* @returns `true` if node is a render function, `false` if not
|
|
177
183
|
*/
|
|
178
184
|
declare function isFunctionOfRenderMethod(node: AST.TSESTreeFunction): boolean;
|
|
179
|
-
|
|
180
|
-
|
|
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
|
|
195
|
+
declare function getFunctionComponentId(context: RuleContext, node: AST.TSESTreeFunction): TSESTree.Identifier | TSESTree.Identifier[] | unit;
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region src/component/component-init-path.d.ts
|
|
183
198
|
declare function getComponentFlagFromInitPath(initPath: FunctionComponent["initPath"]): bigint;
|
|
184
|
-
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region src/component/component-is.d.ts
|
|
185
201
|
/**
|
|
186
202
|
* Check if a node is a React class component
|
|
187
203
|
* @param node The AST node to check
|
|
@@ -194,58 +210,48 @@ declare function isClassComponent(node: TSESTree.Node): node is AST.TSESTreeClas
|
|
|
194
210
|
* @returns `true` if the node is a pure component, `false` otherwise
|
|
195
211
|
*/
|
|
196
212
|
declare function isPureComponent(node: TSESTree.Node): boolean;
|
|
197
|
-
|
|
213
|
+
//#endregion
|
|
214
|
+
//#region src/component/component-kind.d.ts
|
|
198
215
|
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
|
-
|
|
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
|
|
218
242
|
declare function isComponentName(name: string): boolean;
|
|
219
243
|
declare function isComponentNameLoose(name: string): boolean;
|
|
220
|
-
declare function getComponentNameFromId(id: TSESTree.Identifier | TSESTree.Identifier[] |
|
|
244
|
+
declare function getComponentNameFromId(id: TSESTree.Identifier | TSESTree.Identifier[] | unit): string | undefined;
|
|
221
245
|
declare function hasNoneOrLooseComponentName(context: RuleContext, fn: AST.TSESTreeFunction): boolean;
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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
|
-
|
|
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
|
|
249
255
|
/**
|
|
250
256
|
* Check whether given node is a render method of a class component
|
|
251
257
|
* @example
|
|
@@ -259,7 +265,8 @@ declare function isFunctionOfRender(node: AST.TSESTreeFunction): boolean;
|
|
|
259
265
|
* @returns `true` if node is a render function, `false` if not
|
|
260
266
|
*/
|
|
261
267
|
declare function isRenderMethodLike(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
262
|
-
|
|
268
|
+
//#endregion
|
|
269
|
+
//#region src/component/component-render-prop.d.ts
|
|
263
270
|
/**
|
|
264
271
|
* Unsafe check whether given node is a render function
|
|
265
272
|
* ```tsx
|
|
@@ -309,11 +316,13 @@ declare function isDirectValueOfRenderPropertyLoose(node: TSESTree.Node): boolea
|
|
|
309
316
|
* @returns `true` if component is declared inside a render prop, `false` if not
|
|
310
317
|
*/
|
|
311
318
|
declare function isDeclaredInRenderPropLoose(node: TSESTree.Node): boolean;
|
|
312
|
-
|
|
319
|
+
//#endregion
|
|
320
|
+
//#region src/component/component-state.d.ts
|
|
313
321
|
type ComponentStateKind = "actionState" | "state";
|
|
314
322
|
declare function isThisSetState(node: TSESTree.CallExpression): boolean;
|
|
315
323
|
declare function isAssignmentToThisState(node: TSESTree.AssignmentExpression): boolean;
|
|
316
|
-
|
|
324
|
+
//#endregion
|
|
325
|
+
//#region src/component/component-wrapper.d.ts
|
|
317
326
|
/**
|
|
318
327
|
* Check if the node is a call expression for a component wrapper
|
|
319
328
|
* @param context The ESLint rule context
|
|
@@ -328,61 +337,87 @@ declare function isComponentWrapperCall(context: RuleContext, node: TSESTree.Nod
|
|
|
328
337
|
* @returns `true` if the node is a call expression for a component wrapper loosely
|
|
329
338
|
*/
|
|
330
339
|
declare function isComponentWrapperCallLoose(context: RuleContext, node: TSESTree.Node): boolean;
|
|
331
|
-
|
|
340
|
+
//#endregion
|
|
341
|
+
//#region src/effect/effect-kind.d.ts
|
|
332
342
|
type EffectKind = "useEffect" | "useLayoutEffect" | "useInsertionEffect";
|
|
333
|
-
|
|
343
|
+
//#endregion
|
|
344
|
+
//#region src/hook/hook-semantic-node.d.ts
|
|
334
345
|
interface Hook extends SemanticNode {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
346
|
+
id: TSESTree.Identifier | unit;
|
|
347
|
+
node: AST.TSESTreeFunction;
|
|
348
|
+
name: string;
|
|
349
|
+
hookCalls: TSESTree.CallExpression[];
|
|
339
350
|
}
|
|
340
|
-
|
|
351
|
+
//#endregion
|
|
352
|
+
//#region src/hook/hook-collector.d.ts
|
|
341
353
|
declare namespace useHookCollector {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
};
|
|
346
|
-
listeners: ESLintUtils.RuleListener;
|
|
354
|
+
type ReturnType = {
|
|
355
|
+
ctx: {
|
|
356
|
+
getAllHooks(node: TSESTree$1.Program): Map<string, Hook>;
|
|
347
357
|
};
|
|
358
|
+
listeners: ESLintUtils.RuleListener;
|
|
359
|
+
};
|
|
348
360
|
}
|
|
349
361
|
declare function useHookCollector(): useHookCollector.ReturnType;
|
|
350
|
-
|
|
362
|
+
//#endregion
|
|
363
|
+
//#region src/hook/hook-id.d.ts
|
|
351
364
|
declare function isReactHookId(id: TSESTree.Identifier | TSESTree.MemberExpression): boolean;
|
|
352
|
-
|
|
353
|
-
|
|
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
|
+
*/
|
|
372
|
+
declare function isReactHook(node: AST.TSESTreeFunction | unit): boolean;
|
|
354
373
|
/**
|
|
355
374
|
* Check if the given node is a React Hook call by its name.
|
|
356
375
|
* @param node The node to check.
|
|
357
376
|
* @returns `true` if the node is a React Hook call, `false` otherwise.
|
|
358
377
|
*/
|
|
359
|
-
declare function isReactHookCall(node: TSESTree.Node |
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
declare
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
declare
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
declare
|
|
380
|
-
declare const
|
|
381
|
-
declare const
|
|
382
|
-
declare const
|
|
383
|
-
|
|
384
|
-
|
|
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
|
|
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"];
|
|
386
421
|
/**
|
|
387
422
|
* Catch all identifiers that begin with "use" followed by an uppercase Latin
|
|
388
423
|
* character to exclude identifiers like "user".
|
|
@@ -390,17 +425,15 @@ type HookKind = "custom" | "useActionState" | "useCallback" | "useContext" | "us
|
|
|
390
425
|
* @see https://github.com/facebook/react/blob/1d6c8168db1d82713202e842df3167787ffa00ed/packages/eslint-plugin-react-hooks/src/rules/RulesOfHooks.ts#L16
|
|
391
426
|
*/
|
|
392
427
|
declare function isReactHookName(name: string): boolean;
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
declare function getAttribute(context: RuleContext, name: string, attributes: (TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute)[], initialScope?: Scope): TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute | _;
|
|
403
|
-
|
|
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
|
|
404
437
|
/**
|
|
405
438
|
* Get the stringified name of a JSX attribute
|
|
406
439
|
* @param context The ESLint rule context
|
|
@@ -408,112 +441,266 @@ declare function getAttribute(context: RuleContext, name: string, attributes: (T
|
|
|
408
441
|
* @returns The name of the attribute
|
|
409
442
|
*/
|
|
410
443
|
declare function getAttributeName(context: RuleContext, node: TSESTree$1.JSXAttribute): string;
|
|
411
|
-
|
|
444
|
+
//#endregion
|
|
445
|
+
//#region src/jsx/jsx-attribute-value.d.ts
|
|
412
446
|
/**
|
|
413
|
-
*
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
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
|
|
418
536
|
*/
|
|
419
|
-
declare function getAttributeValue(context: RuleContext, node: TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute, name: string): Exclude<VAR.LazyValue, {
|
|
420
|
-
kind: "lazy";
|
|
421
|
-
}>;
|
|
422
|
-
|
|
423
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
|
+
*/
|
|
424
543
|
declare const JSXDetectionHint: {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
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;
|
|
437
556
|
};
|
|
557
|
+
/**
|
|
558
|
+
* Default JSX detection configuration
|
|
559
|
+
* Skips undefined and boolean literals (common in React)
|
|
560
|
+
*/
|
|
438
561
|
declare const DEFAULT_JSX_DETECTION_HINT: bigint;
|
|
439
|
-
|
|
440
562
|
/**
|
|
441
|
-
*
|
|
563
|
+
* Checks if a node is a `JSXText` or a `Literal` node
|
|
442
564
|
* @param node The AST node to check
|
|
443
565
|
* @returns `true` if the node is a `JSXText` or a `Literal` node
|
|
444
566
|
*/
|
|
445
|
-
declare function isJsxText(node: TSESTree$1.Node | null |
|
|
567
|
+
declare function isJsxText(node: TSESTree$1.Node | null | unit): node is TSESTree$1.JSXText | TSESTree$1.Literal;
|
|
446
568
|
/**
|
|
447
|
-
*
|
|
448
|
-
*
|
|
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
|
|
449
573
|
* @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
|
|
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
|
|
453
577
|
*/
|
|
454
578
|
declare function isJsxLike(code: {
|
|
455
|
-
|
|
456
|
-
}, node: TSESTree$1.Node |
|
|
457
|
-
|
|
579
|
+
getScope: (node: TSESTree$1.Node) => Scope;
|
|
580
|
+
}, node: TSESTree$1.Node | unit | null, hint?: JSXDetectionHint): boolean;
|
|
581
|
+
//#endregion
|
|
582
|
+
//#region src/jsx/jsx-element-is.d.ts
|
|
458
583
|
/**
|
|
459
|
-
*
|
|
460
|
-
*
|
|
461
|
-
*
|
|
462
|
-
* @
|
|
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
|
|
463
611
|
*/
|
|
464
612
|
declare function getElementType(context: RuleContext, node: TSESTree.JSXElement | TSESTree.JSXFragment): string;
|
|
465
|
-
|
|
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
|
+
*/
|
|
466
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
|
+
*/
|
|
467
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
|
+
*/
|
|
468
644
|
declare function hasEveryAttribute(context: RuleContext, names: string[], attributes: TSESTree.JSXOpeningElement["attributes"], initialScope?: Scope): boolean;
|
|
469
|
-
|
|
645
|
+
//#endregion
|
|
646
|
+
//#region src/jsx/jsx-hierarchy.d.ts
|
|
470
647
|
/**
|
|
471
|
-
*
|
|
472
|
-
*
|
|
473
|
-
* @param
|
|
474
|
-
* @
|
|
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
|
|
475
654
|
*/
|
|
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
|
-
|
|
655
|
+
declare function findParentAttribute(node: TSESTree.Node, test?: (node: TSESTree.JSXAttribute) => boolean): TSESTree.JSXAttribute | unit;
|
|
656
|
+
//#endregion
|
|
657
|
+
//#region src/jsx/jsx-stringify.d.ts
|
|
483
658
|
/**
|
|
484
|
-
*
|
|
485
|
-
*
|
|
486
|
-
* @
|
|
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
|
|
663
|
+
*/
|
|
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
|
|
667
|
+
/**
|
|
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
|
|
487
673
|
*/
|
|
488
|
-
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
|
-
|
|
490
|
-
/** @internal */
|
|
491
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;
|
|
492
|
-
|
|
675
|
+
//#endregion
|
|
676
|
+
//#region src/utils/is-from-react.d.ts
|
|
493
677
|
/**
|
|
494
|
-
* Check if an identifier is initialized from react
|
|
678
|
+
* Check if an identifier name is initialized from react
|
|
495
679
|
* @param name The top-level identifier's name
|
|
496
680
|
* @param importSource The import source to check against
|
|
497
681
|
* @param initialScope Initial scope to search for the identifier
|
|
498
|
-
* @returns Whether the identifier is initialized from react
|
|
682
|
+
* @returns Whether the identifier name is initialized from react
|
|
683
|
+
* @internal
|
|
499
684
|
*/
|
|
500
685
|
declare function isInitializedFromReact(name: string, importSource: string, initialScope: Scope): boolean;
|
|
501
|
-
|
|
686
|
+
//#endregion
|
|
687
|
+
//#region src/utils/is-instance-id-equal.d.ts
|
|
502
688
|
/** @internal */
|
|
503
689
|
declare function isInstanceIdEqual(context: RuleContext, a: TSESTree.Node, b: TSESTree.Node): boolean;
|
|
504
|
-
|
|
690
|
+
//#endregion
|
|
691
|
+
//#region src/utils/is-react-api.d.ts
|
|
505
692
|
declare namespace isReactAPI {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
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
|
+
};
|
|
510
697
|
}
|
|
511
698
|
declare function isReactAPI(api: string): isReactAPI.ReturnType;
|
|
512
699
|
declare namespace isReactAPICall {
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
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
|
+
};
|
|
517
704
|
}
|
|
518
705
|
declare function isReactAPICall(api: string): isReactAPICall.ReturnType;
|
|
519
706
|
declare const isCaptureOwnerStack: isReactAPI.ReturnType;
|
|
@@ -542,5 +729,5 @@ declare const isCreateRefCall: isReactAPICall.ReturnType;
|
|
|
542
729
|
declare const isForwardRefCall: isReactAPICall.ReturnType;
|
|
543
730
|
declare const isMemoCall: isReactAPICall.ReturnType;
|
|
544
731
|
declare const isLazyCall: isReactAPICall.ReturnType;
|
|
545
|
-
|
|
546
|
-
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 };
|