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