@eslint-react/core 2.0.0-next.146 → 2.0.0-next.148
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 +286 -243
- package/dist/index.js +1027 -879
- package/package.json +12 -12
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import * as
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
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 VAR from "@eslint-react/var";
|
|
6
|
+
import * as birecord0 from "birecord";
|
|
7
|
+
import { isFalseLiteralType, isTrueLiteralType } from "ts-api-utils";
|
|
8
|
+
import ts from "typescript";
|
|
9
|
+
import { ESLintUtils, TSESTree as TSESTree$1 } from "@typescript-eslint/utils";
|
|
10
|
+
import { Scope } from "@typescript-eslint/scope-manager";
|
|
11
|
+
|
|
12
|
+
//#region src/component/component-children.d.ts
|
|
12
13
|
/**
|
|
13
14
|
* Determines whether inside `createElement`'s children.
|
|
14
15
|
* @param context The rule context
|
|
@@ -16,132 +17,139 @@ export { isFalseLiteralType, isTrueLiteralType } from 'ts-api-utils';
|
|
|
16
17
|
* @returns `true` if the node is inside createElement's children
|
|
17
18
|
*/
|
|
18
19
|
declare function isChildrenOfCreateElement(context: RuleContext, node: TSESTree.Node): boolean;
|
|
19
|
-
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/component/component-detection-hint.d.ts
|
|
20
22
|
type ComponentDetectionHint = bigint;
|
|
21
23
|
/**
|
|
22
24
|
* Hints for component collector
|
|
23
25
|
*/
|
|
24
26
|
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
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Skip function component created by React.memo
|
|
29
|
+
*/
|
|
30
|
+
readonly SkipMemo: bigint;
|
|
31
|
+
/**
|
|
32
|
+
* Skip function component created by React.forwardRef
|
|
33
|
+
*/
|
|
34
|
+
readonly SkipForwardRef: bigint;
|
|
35
|
+
/**
|
|
36
|
+
* Skip function component defined as array map argument
|
|
37
|
+
*/
|
|
38
|
+
readonly SkipArrayMapArgument: bigint;
|
|
39
|
+
/**
|
|
40
|
+
* Skip function component defined on object method
|
|
41
|
+
*/
|
|
42
|
+
readonly SkipObjectMethod: bigint;
|
|
43
|
+
/**
|
|
44
|
+
* Skip function component defined on class method
|
|
45
|
+
*/
|
|
46
|
+
readonly SkipClassMethod: bigint;
|
|
47
|
+
/**
|
|
48
|
+
* Skip function component defined on class property
|
|
49
|
+
*/
|
|
50
|
+
readonly SkipClassProperty: bigint;
|
|
51
|
+
readonly None: 0n;
|
|
52
|
+
readonly SkipUndefined: bigint;
|
|
53
|
+
readonly SkipNullLiteral: bigint;
|
|
54
|
+
readonly SkipBooleanLiteral: bigint;
|
|
55
|
+
readonly SkipStringLiteral: bigint;
|
|
56
|
+
readonly SkipNumberLiteral: bigint;
|
|
57
|
+
readonly SkipBigIntLiteral: bigint;
|
|
58
|
+
readonly SkipEmptyArray: bigint;
|
|
59
|
+
readonly SkipCreateElement: bigint;
|
|
60
|
+
readonly StrictArray: bigint;
|
|
61
|
+
readonly StrictLogical: bigint;
|
|
62
|
+
readonly StrictConditional: bigint;
|
|
61
63
|
};
|
|
62
64
|
/**
|
|
63
65
|
* Default component detection hint
|
|
64
66
|
*/
|
|
65
67
|
declare const DEFAULT_COMPONENT_DETECTION_HINT: bigint;
|
|
66
|
-
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/component/component-phase.d.ts
|
|
67
70
|
type ComponentEffectPhaseKind = "cleanup" | "setup";
|
|
68
71
|
type ComponentLifecyclePhaseKind = "mount" | "unmount";
|
|
69
72
|
type ComponentPhaseKind = ComponentEffectPhaseKind | ComponentLifecyclePhaseKind;
|
|
70
|
-
declare const ComponentPhaseRelevance:
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
declare const ComponentPhaseRelevance: birecord0.BiRecord<{
|
|
74
|
+
readonly mount: "unmount";
|
|
75
|
+
readonly setup: "cleanup";
|
|
73
76
|
}>;
|
|
74
77
|
declare const isInversePhase: {
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
(a: ComponentPhaseKind): (b: ComponentPhaseKind) => boolean;
|
|
79
|
+
(a: ComponentPhaseKind, b: ComponentPhaseKind): boolean;
|
|
77
80
|
};
|
|
78
|
-
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/semantic/semantic-entry.d.ts
|
|
79
83
|
interface SemanticEntry {
|
|
80
|
-
|
|
81
|
-
|
|
84
|
+
node: TSESTree.Node;
|
|
85
|
+
phase: ComponentPhaseKind;
|
|
82
86
|
}
|
|
83
|
-
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/semantic/semantic-node.d.ts
|
|
84
89
|
interface SemanticNode {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
id: unit | TSESTree.Identifier | TSESTree.Identifier[];
|
|
91
|
+
key: string;
|
|
92
|
+
kind: string;
|
|
93
|
+
name: unit | string;
|
|
94
|
+
node: TSESTree.Node;
|
|
95
|
+
flag: bigint;
|
|
96
|
+
hint: bigint;
|
|
92
97
|
}
|
|
93
|
-
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/component/component-flag.d.ts
|
|
94
100
|
type ComponentFlag = bigint;
|
|
95
101
|
declare const ComponentFlag: {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
+
None: bigint;
|
|
103
|
+
PureComponent: bigint;
|
|
104
|
+
CreateElement: bigint;
|
|
105
|
+
Memo: bigint;
|
|
106
|
+
ForwardRef: bigint;
|
|
107
|
+
Async: bigint;
|
|
102
108
|
};
|
|
103
|
-
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/component/component-semantic-node.d.ts
|
|
104
111
|
interface FunctionComponent extends SemanticNode {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
112
|
+
id: unit | TSESTree.Identifier | TSESTree.Identifier[];
|
|
113
|
+
kind: "function";
|
|
114
|
+
node: AST.TSESTreeFunction;
|
|
115
|
+
flag: ComponentFlag;
|
|
116
|
+
hint: ComponentDetectionHint;
|
|
117
|
+
initPath: unit | AST.FunctionInitPath;
|
|
118
|
+
hookCalls: TSESTree.CallExpression[];
|
|
119
|
+
displayName: unit | TSESTree.Expression;
|
|
113
120
|
}
|
|
114
121
|
interface ClassComponent extends SemanticNode {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
+
id: unit | TSESTree.Identifier;
|
|
123
|
+
kind: "class";
|
|
124
|
+
node: AST.TSESTreeClass;
|
|
125
|
+
flag: ComponentFlag;
|
|
126
|
+
hint: ComponentDetectionHint;
|
|
127
|
+
methods: AST.TSESTreeMethodOrProperty[];
|
|
128
|
+
displayName: unit | TSESTree.Expression;
|
|
122
129
|
}
|
|
123
130
|
type Component = ClassComponent | FunctionComponent;
|
|
124
|
-
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/component/component-collector.d.ts
|
|
125
133
|
type FunctionEntry = {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
134
|
+
key: string;
|
|
135
|
+
node: AST.TSESTreeFunction;
|
|
136
|
+
hookCalls: TSESTree.CallExpression[];
|
|
137
|
+
isComponent: boolean;
|
|
130
138
|
};
|
|
131
139
|
declare namespace useComponentCollector {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
};
|
|
143
|
-
listeners: ESLintUtils.RuleListener;
|
|
140
|
+
type Options = {
|
|
141
|
+
collectDisplayName?: boolean;
|
|
142
|
+
collectHookCalls?: boolean;
|
|
143
|
+
hint?: ComponentDetectionHint;
|
|
144
|
+
};
|
|
145
|
+
type ReturnType = {
|
|
146
|
+
ctx: {
|
|
147
|
+
getAllComponents: (node: TSESTree.Program) => Map<string, FunctionComponent>;
|
|
148
|
+
getCurrentEntries: () => FunctionEntry[];
|
|
149
|
+
getCurrentEntry: () => FunctionEntry | unit;
|
|
144
150
|
};
|
|
151
|
+
listeners: ESLintUtils.RuleListener;
|
|
152
|
+
};
|
|
145
153
|
}
|
|
146
154
|
/**
|
|
147
155
|
* Get a ctx and listeners for the rule to collect function components
|
|
@@ -150,21 +158,23 @@ declare namespace useComponentCollector {
|
|
|
150
158
|
* @returns The component collector
|
|
151
159
|
*/
|
|
152
160
|
declare function useComponentCollector(context: RuleContext, options?: useComponentCollector.Options): useComponentCollector.ReturnType;
|
|
153
|
-
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region src/component/component-collector-legacy.d.ts
|
|
154
163
|
declare namespace useComponentCollectorLegacy {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
};
|
|
159
|
-
listeners: ESLintUtils.RuleListener;
|
|
164
|
+
type ReturnType = {
|
|
165
|
+
ctx: {
|
|
166
|
+
getAllComponents: (node: TSESTree$1.Program) => Map<string, ClassComponent>;
|
|
160
167
|
};
|
|
168
|
+
listeners: ESLintUtils.RuleListener;
|
|
169
|
+
};
|
|
161
170
|
}
|
|
162
171
|
/**
|
|
163
172
|
* Get a ctx and listeners object for the rule to collect class components
|
|
164
173
|
* @returns The context and listeners for the rule
|
|
165
174
|
*/
|
|
166
175
|
declare function useComponentCollectorLegacy(): useComponentCollectorLegacy.ReturnType;
|
|
167
|
-
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/component/component-definition.d.ts
|
|
168
178
|
/**
|
|
169
179
|
* Check whether given node is a function of a render method of a class component
|
|
170
180
|
* @example
|
|
@@ -179,11 +189,14 @@ declare function useComponentCollectorLegacy(): useComponentCollectorLegacy.Retu
|
|
|
179
189
|
*/
|
|
180
190
|
declare function isFunctionOfRenderMethod(node: AST.TSESTreeFunction): boolean;
|
|
181
191
|
declare function isValidComponentDefinition(context: RuleContext, node: AST.TSESTreeFunction, hint: bigint): boolean;
|
|
182
|
-
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region src/component/component-id.d.ts
|
|
183
194
|
declare function getFunctionComponentId(context: RuleContext, node: AST.TSESTreeFunction): TSESTree.Identifier | TSESTree.Identifier[] | unit;
|
|
184
|
-
|
|
195
|
+
//#endregion
|
|
196
|
+
//#region src/component/component-init-path.d.ts
|
|
185
197
|
declare function getComponentFlagFromInitPath(initPath: FunctionComponent["initPath"]): bigint;
|
|
186
|
-
|
|
198
|
+
//#endregion
|
|
199
|
+
//#region src/component/component-is.d.ts
|
|
187
200
|
/**
|
|
188
201
|
* Check if a node is a React class component
|
|
189
202
|
* @param node The AST node to check
|
|
@@ -196,9 +209,11 @@ declare function isClassComponent(node: TSESTree.Node): node is AST.TSESTreeClas
|
|
|
196
209
|
* @returns `true` if the node is a pure component, `false` otherwise
|
|
197
210
|
*/
|
|
198
211
|
declare function isPureComponent(node: TSESTree.Node): boolean;
|
|
199
|
-
|
|
212
|
+
//#endregion
|
|
213
|
+
//#region src/component/component-kind.d.ts
|
|
200
214
|
type ComponentKind = "classComponent" | "functionComponent";
|
|
201
|
-
|
|
215
|
+
//#endregion
|
|
216
|
+
//#region src/component/component-method.d.ts
|
|
202
217
|
declare function isComponentDidCatch(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
203
218
|
declare function isComponentDidMount(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
204
219
|
declare function isComponentDidUpdate(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
@@ -216,12 +231,14 @@ declare function isUnsafeComponentWillReceiveProps(node: TSESTree.Node): node is
|
|
|
216
231
|
declare function isUnsafeComponentWillUpdate(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
217
232
|
declare function isGetDerivedStateFromProps(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
218
233
|
declare function isGetDerivedStateFromError(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
219
|
-
|
|
234
|
+
//#endregion
|
|
235
|
+
//#region src/component/component-name.d.ts
|
|
220
236
|
declare function isComponentName(name: string): boolean;
|
|
221
237
|
declare function isComponentNameLoose(name: string): boolean;
|
|
222
238
|
declare function getComponentNameFromId(id: TSESTree.Identifier | TSESTree.Identifier[] | unit): string | undefined;
|
|
223
239
|
declare function hasNoneOrLooseComponentName(context: RuleContext, fn: AST.TSESTreeFunction): boolean;
|
|
224
|
-
|
|
240
|
+
//#endregion
|
|
241
|
+
//#region src/component/component-render.d.ts
|
|
225
242
|
/**
|
|
226
243
|
* Check whether given node is a render function of a class component
|
|
227
244
|
* @example
|
|
@@ -247,7 +264,8 @@ declare function isRenderLike(node: TSESTree.Node): node is AST.TSESTreeMethodOr
|
|
|
247
264
|
* @returns `true` if node is a render function, `false` if not
|
|
248
265
|
*/
|
|
249
266
|
declare function isFunctionOfRender(node: AST.TSESTreeFunction): boolean;
|
|
250
|
-
|
|
267
|
+
//#endregion
|
|
268
|
+
//#region src/component/component-render-method.d.ts
|
|
251
269
|
/**
|
|
252
270
|
* Check whether given node is a render method of a class component
|
|
253
271
|
* @example
|
|
@@ -261,7 +279,8 @@ declare function isFunctionOfRender(node: AST.TSESTreeFunction): boolean;
|
|
|
261
279
|
* @returns `true` if node is a render function, `false` if not
|
|
262
280
|
*/
|
|
263
281
|
declare function isRenderMethodLike(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
264
|
-
|
|
282
|
+
//#endregion
|
|
283
|
+
//#region src/component/component-render-prop.d.ts
|
|
265
284
|
/**
|
|
266
285
|
* Unsafe check whether given node is a render function
|
|
267
286
|
* ```tsx
|
|
@@ -311,11 +330,13 @@ declare function isDirectValueOfRenderPropertyLoose(node: TSESTree.Node): boolea
|
|
|
311
330
|
* @returns `true` if component is declared inside a render prop, `false` if not
|
|
312
331
|
*/
|
|
313
332
|
declare function isDeclaredInRenderPropLoose(node: TSESTree.Node): boolean;
|
|
314
|
-
|
|
333
|
+
//#endregion
|
|
334
|
+
//#region src/component/component-state.d.ts
|
|
315
335
|
type ComponentStateKind = "actionState" | "state";
|
|
316
336
|
declare function isThisSetState(node: TSESTree.CallExpression): boolean;
|
|
317
337
|
declare function isAssignmentToThisState(node: TSESTree.AssignmentExpression): boolean;
|
|
318
|
-
|
|
338
|
+
//#endregion
|
|
339
|
+
//#region src/component/component-wrapper.d.ts
|
|
319
340
|
/**
|
|
320
341
|
* Check if the node is a call expression for a component wrapper
|
|
321
342
|
* @param context The ESLint rule context
|
|
@@ -330,28 +351,33 @@ declare function isComponentWrapperCall(context: RuleContext, node: TSESTree.Nod
|
|
|
330
351
|
* @returns `true` if the node is a call expression for a component wrapper loosely
|
|
331
352
|
*/
|
|
332
353
|
declare function isComponentWrapperCallLoose(context: RuleContext, node: TSESTree.Node): boolean;
|
|
333
|
-
|
|
354
|
+
//#endregion
|
|
355
|
+
//#region src/effect/effect-kind.d.ts
|
|
334
356
|
type EffectKind = "useEffect" | "useLayoutEffect" | "useInsertionEffect";
|
|
335
|
-
|
|
357
|
+
//#endregion
|
|
358
|
+
//#region src/hook/hook-semantic-node.d.ts
|
|
336
359
|
interface Hook extends SemanticNode {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
360
|
+
id: TSESTree.Identifier | unit;
|
|
361
|
+
node: AST.TSESTreeFunction;
|
|
362
|
+
name: string;
|
|
363
|
+
hookCalls: TSESTree.CallExpression[];
|
|
341
364
|
}
|
|
342
|
-
|
|
365
|
+
//#endregion
|
|
366
|
+
//#region src/hook/hook-collector.d.ts
|
|
343
367
|
declare namespace useHookCollector {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
};
|
|
348
|
-
listeners: ESLintUtils.RuleListener;
|
|
368
|
+
type ReturnType = {
|
|
369
|
+
ctx: {
|
|
370
|
+
getAllHooks(node: TSESTree$1.Program): Map<string, Hook>;
|
|
349
371
|
};
|
|
372
|
+
listeners: ESLintUtils.RuleListener;
|
|
373
|
+
};
|
|
350
374
|
}
|
|
351
375
|
declare function useHookCollector(): useHookCollector.ReturnType;
|
|
352
|
-
|
|
376
|
+
//#endregion
|
|
377
|
+
//#region src/hook/hook-id.d.ts
|
|
353
378
|
declare function isReactHookId(id: TSESTree.Identifier | TSESTree.MemberExpression): boolean;
|
|
354
|
-
|
|
379
|
+
//#endregion
|
|
380
|
+
//#region src/hook/hook-is.d.ts
|
|
355
381
|
declare function isReactHook(node: AST.TSESTreeFunction | unit): boolean;
|
|
356
382
|
/**
|
|
357
383
|
* Check if the given node is a React Hook call by its name.
|
|
@@ -382,7 +408,8 @@ declare const isUseRefCall: (context: RuleContext, node: TSESTree.Node | undefin
|
|
|
382
408
|
declare const isUseStateCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
383
409
|
declare const isUseSyncExternalStoreCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
384
410
|
declare const isUseTransitionCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
385
|
-
|
|
411
|
+
//#endregion
|
|
412
|
+
//#region src/hook/hook-name.d.ts
|
|
386
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"];
|
|
387
414
|
/**
|
|
388
415
|
* Catch all identifiers that begin with "use" followed by an uppercase Latin
|
|
@@ -391,7 +418,8 @@ declare const REACT_BUILTIN_HOOK_NAMES: readonly ["use", "useActionState", "useC
|
|
|
391
418
|
* @see https://github.com/facebook/react/blob/1d6c8168db1d82713202e842df3167787ffa00ed/packages/eslint-plugin-react-hooks/src/rules/RulesOfHooks.ts#L16
|
|
392
419
|
*/
|
|
393
420
|
declare function isReactHookName(name: string): boolean;
|
|
394
|
-
|
|
421
|
+
//#endregion
|
|
422
|
+
//#region src/jsx/jsx-attribute.d.ts
|
|
395
423
|
/**
|
|
396
424
|
* Get the JSX attribute node with the given name
|
|
397
425
|
* @param context The ESLint rule context
|
|
@@ -401,7 +429,8 @@ declare function isReactHookName(name: string): boolean;
|
|
|
401
429
|
* @returns The JSX attribute node or undefined
|
|
402
430
|
*/
|
|
403
431
|
declare function getAttribute(context: RuleContext, name: string, attributes: (TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute)[], initialScope?: Scope): TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute | unit;
|
|
404
|
-
|
|
432
|
+
//#endregion
|
|
433
|
+
//#region src/jsx/jsx-attribute-name.d.ts
|
|
405
434
|
/**
|
|
406
435
|
* Get the stringified name of a JSX attribute
|
|
407
436
|
* @param context The ESLint rule context
|
|
@@ -409,7 +438,8 @@ declare function getAttribute(context: RuleContext, name: string, attributes: (T
|
|
|
409
438
|
* @returns The name of the attribute
|
|
410
439
|
*/
|
|
411
440
|
declare function getAttributeName(context: RuleContext, node: TSESTree$1.JSXAttribute): string;
|
|
412
|
-
|
|
441
|
+
//#endregion
|
|
442
|
+
//#region src/jsx/jsx-attribute-value.d.ts
|
|
413
443
|
/**
|
|
414
444
|
* Get a StaticValue of the attribute value
|
|
415
445
|
* @param context The rule context
|
|
@@ -418,26 +448,28 @@ declare function getAttributeName(context: RuleContext, node: TSESTree$1.JSXAttr
|
|
|
418
448
|
* @returns The StaticValue of the attribute value
|
|
419
449
|
*/
|
|
420
450
|
declare function getAttributeValue(context: RuleContext, node: TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute, name: string): Exclude<VAR.LazyValue, {
|
|
421
|
-
|
|
451
|
+
kind: "lazy";
|
|
422
452
|
}>;
|
|
423
|
-
|
|
453
|
+
//#endregion
|
|
454
|
+
//#region src/jsx/jsx-detection-hint.d.ts
|
|
424
455
|
type JSXDetectionHint = bigint;
|
|
425
456
|
declare const JSXDetectionHint: {
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
457
|
+
readonly None: 0n;
|
|
458
|
+
readonly SkipUndefined: bigint;
|
|
459
|
+
readonly SkipNullLiteral: bigint;
|
|
460
|
+
readonly SkipBooleanLiteral: bigint;
|
|
461
|
+
readonly SkipStringLiteral: bigint;
|
|
462
|
+
readonly SkipNumberLiteral: bigint;
|
|
463
|
+
readonly SkipBigIntLiteral: bigint;
|
|
464
|
+
readonly SkipEmptyArray: bigint;
|
|
465
|
+
readonly SkipCreateElement: bigint;
|
|
466
|
+
readonly StrictArray: bigint;
|
|
467
|
+
readonly StrictLogical: bigint;
|
|
468
|
+
readonly StrictConditional: bigint;
|
|
438
469
|
};
|
|
439
470
|
declare const DEFAULT_JSX_DETECTION_HINT: bigint;
|
|
440
|
-
|
|
471
|
+
//#endregion
|
|
472
|
+
//#region src/jsx/jsx-detection.d.ts
|
|
441
473
|
/**
|
|
442
474
|
* Check if a node is a `JSXText` or a `Literal` node
|
|
443
475
|
* @param node The AST node to check
|
|
@@ -453,12 +485,14 @@ declare function isJsxText(node: TSESTree$1.Node | null | unit): node is TSESTre
|
|
|
453
485
|
* @returns boolean
|
|
454
486
|
*/
|
|
455
487
|
declare function isJsxLike(code: {
|
|
456
|
-
|
|
488
|
+
getScope: (node: TSESTree$1.Node) => Scope;
|
|
457
489
|
}, node: TSESTree$1.Node | unit | null, hint?: JSXDetectionHint): boolean;
|
|
458
|
-
|
|
490
|
+
//#endregion
|
|
491
|
+
//#region src/jsx/jsx-element-is.d.ts
|
|
459
492
|
declare function isHostElement(context: RuleContext, node: TSESTree.Node): boolean;
|
|
460
493
|
declare function isFragmentElement(context: RuleContext, node: TSESTree.Node): node is TSESTree.JSXElement;
|
|
461
|
-
|
|
494
|
+
//#endregion
|
|
495
|
+
//#region src/jsx/jsx-element-type.d.ts
|
|
462
496
|
/**
|
|
463
497
|
* Get the stringified type of a JSX element
|
|
464
498
|
* @param context The ESLint rule context
|
|
@@ -466,11 +500,13 @@ declare function isFragmentElement(context: RuleContext, node: TSESTree.Node): n
|
|
|
466
500
|
* @returns The type of the element
|
|
467
501
|
*/
|
|
468
502
|
declare function getElementType(context: RuleContext, node: TSESTree.JSXElement | TSESTree.JSXFragment): string;
|
|
469
|
-
|
|
503
|
+
//#endregion
|
|
504
|
+
//#region src/jsx/jsx-has.d.ts
|
|
470
505
|
declare function hasAttribute(context: RuleContext, name: string, attributes: TSESTree.JSXOpeningElement["attributes"], initialScope?: Scope): boolean;
|
|
471
506
|
declare function hasAnyAttribute(context: RuleContext, names: string[], attributes: TSESTree.JSXOpeningElement["attributes"], initialScope?: Scope): boolean;
|
|
472
507
|
declare function hasEveryAttribute(context: RuleContext, names: string[], attributes: TSESTree.JSXOpeningElement["attributes"], initialScope?: Scope): boolean;
|
|
473
|
-
|
|
508
|
+
//#endregion
|
|
509
|
+
//#region src/jsx/jsx-hierarchy.d.ts
|
|
474
510
|
/**
|
|
475
511
|
* Find the parent JSX attribute node of a node
|
|
476
512
|
* @param node The node to find the parent attribute of
|
|
@@ -478,14 +514,16 @@ declare function hasEveryAttribute(context: RuleContext, names: string[], attrib
|
|
|
478
514
|
* @returns The parent attribute node or undefined
|
|
479
515
|
*/
|
|
480
516
|
declare function findParentAttribute(node: TSESTree.Node, test?: (node: TSESTree.JSXAttribute) => boolean): TSESTree.JSXAttribute | unit;
|
|
481
|
-
|
|
517
|
+
//#endregion
|
|
518
|
+
//#region src/jsx/jsx-stringify.d.ts
|
|
482
519
|
/**
|
|
483
520
|
* Get the stringified representation of a JSX node
|
|
484
521
|
* @param node The JSX node
|
|
485
522
|
* @returns The stringified representation
|
|
486
523
|
*/
|
|
487
524
|
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;
|
|
488
|
-
|
|
525
|
+
//#endregion
|
|
526
|
+
//#region src/type/type-is.d.ts
|
|
489
527
|
/** @internal */
|
|
490
528
|
declare const isAnyType: (type: ts.Type) => boolean;
|
|
491
529
|
/** @internal */
|
|
@@ -496,40 +534,40 @@ declare const isBooleanType: (type: ts.Type) => boolean;
|
|
|
496
534
|
declare const isEnumType: (type: ts.Type) => boolean;
|
|
497
535
|
/** @internal */
|
|
498
536
|
declare const isFalsyBigIntType: (type: ts.Type) => type is ts.LiteralType & {
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
537
|
+
freshType: ts.FreshableType;
|
|
538
|
+
regularType: ts.FreshableType;
|
|
539
|
+
flags: ts.TypeFlags;
|
|
540
|
+
symbol: ts.Symbol;
|
|
541
|
+
pattern?: ts.DestructuringPattern;
|
|
542
|
+
aliasSymbol?: ts.Symbol;
|
|
543
|
+
aliasTypeArguments?: readonly ts.Type[];
|
|
544
|
+
getFlags: () => ts.TypeFlags;
|
|
545
|
+
getSymbol: () => ts.Symbol | undefined;
|
|
546
|
+
getProperties: () => ts.Symbol[];
|
|
547
|
+
getProperty: (propertyName: string) => ts.Symbol | undefined;
|
|
548
|
+
getApparentProperties: () => ts.Symbol[];
|
|
549
|
+
getCallSignatures: () => readonly ts.Signature[];
|
|
550
|
+
getConstructSignatures: () => readonly ts.Signature[];
|
|
551
|
+
getStringIndexType: () => ts.Type | undefined;
|
|
552
|
+
getNumberIndexType: () => ts.Type | undefined;
|
|
553
|
+
getBaseTypes: () => ts.BaseType[] | undefined;
|
|
554
|
+
getNonNullableType: () => ts.Type;
|
|
555
|
+
getConstraint: () => ts.Type | undefined;
|
|
556
|
+
getDefault: () => ts.Type | undefined;
|
|
557
|
+
isUnion: () => this is ts.UnionType;
|
|
558
|
+
isIntersection: () => this is ts.IntersectionType;
|
|
559
|
+
isUnionOrIntersection: () => this is ts.UnionOrIntersectionType;
|
|
560
|
+
isLiteral: () => this is ts.LiteralType;
|
|
561
|
+
isStringLiteral: () => this is ts.StringLiteralType;
|
|
562
|
+
isNumberLiteral: () => this is ts.NumberLiteralType;
|
|
563
|
+
isTypeParameter: () => this is ts.TypeParameter;
|
|
564
|
+
isClassOrInterface: () => this is ts.InterfaceType;
|
|
565
|
+
isClass: () => this is ts.InterfaceType;
|
|
566
|
+
isIndexType: () => this is ts.IndexType;
|
|
567
|
+
value: {
|
|
568
|
+
negative: boolean;
|
|
569
|
+
base10Value: "0";
|
|
570
|
+
};
|
|
533
571
|
};
|
|
534
572
|
/** @internal */
|
|
535
573
|
declare const isFalsyNumberType: (type: ts.Type) => boolean;
|
|
@@ -547,37 +585,37 @@ declare const isObjectType: (type: ts.Type) => boolean;
|
|
|
547
585
|
declare const isStringType: (type: ts.Type) => boolean;
|
|
548
586
|
/** @internal */
|
|
549
587
|
declare const isTruthyBigIntType: (type: ts.Type) => type is ts.LiteralType & {
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
588
|
+
freshType: ts.FreshableType;
|
|
589
|
+
regularType: ts.FreshableType;
|
|
590
|
+
flags: ts.TypeFlags;
|
|
591
|
+
symbol: ts.Symbol;
|
|
592
|
+
pattern?: ts.DestructuringPattern;
|
|
593
|
+
aliasSymbol?: ts.Symbol;
|
|
594
|
+
aliasTypeArguments?: readonly ts.Type[];
|
|
595
|
+
getFlags: () => ts.TypeFlags;
|
|
596
|
+
getSymbol: () => ts.Symbol | undefined;
|
|
597
|
+
getProperties: () => ts.Symbol[];
|
|
598
|
+
getProperty: (propertyName: string) => ts.Symbol | undefined;
|
|
599
|
+
getApparentProperties: () => ts.Symbol[];
|
|
600
|
+
getCallSignatures: () => readonly ts.Signature[];
|
|
601
|
+
getConstructSignatures: () => readonly ts.Signature[];
|
|
602
|
+
getStringIndexType: () => ts.Type | undefined;
|
|
603
|
+
getNumberIndexType: () => ts.Type | undefined;
|
|
604
|
+
getBaseTypes: () => ts.BaseType[] | undefined;
|
|
605
|
+
getNonNullableType: () => ts.Type;
|
|
606
|
+
getConstraint: () => ts.Type | undefined;
|
|
607
|
+
getDefault: () => ts.Type | undefined;
|
|
608
|
+
isUnion: () => this is ts.UnionType;
|
|
609
|
+
isIntersection: () => this is ts.IntersectionType;
|
|
610
|
+
isUnionOrIntersection: () => this is ts.UnionOrIntersectionType;
|
|
611
|
+
isLiteral: () => this is ts.LiteralType;
|
|
612
|
+
isStringLiteral: () => this is ts.StringLiteralType;
|
|
613
|
+
isNumberLiteral: () => this is ts.NumberLiteralType;
|
|
614
|
+
isTypeParameter: () => this is ts.TypeParameter;
|
|
615
|
+
isClassOrInterface: () => this is ts.InterfaceType;
|
|
616
|
+
isClass: () => this is ts.InterfaceType;
|
|
617
|
+
isIndexType: () => this is ts.IndexType;
|
|
618
|
+
value: ts.PseudoBigInt;
|
|
581
619
|
};
|
|
582
620
|
/** @internal */
|
|
583
621
|
declare const isTruthyNumberType: (type: ts.Type) => boolean;
|
|
@@ -585,7 +623,8 @@ declare const isTruthyNumberType: (type: ts.Type) => boolean;
|
|
|
585
623
|
declare const isTruthyStringType: (type: ts.Type) => boolean;
|
|
586
624
|
/** @internal */
|
|
587
625
|
declare const isUnknownType: (type: ts.Type) => boolean;
|
|
588
|
-
|
|
626
|
+
//#endregion
|
|
627
|
+
//#region src/type/type-variant.d.ts
|
|
589
628
|
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";
|
|
590
629
|
/**
|
|
591
630
|
* Ported from https://github.com/typescript-eslint/typescript-eslint/blob/eb736bbfc22554694400e6a4f97051d845d32e0b/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts#L826 with some enhancements
|
|
@@ -595,10 +634,12 @@ type TypeVariant = "any" | "bigint" | "boolean" | "enum" | "never" | "nullish" |
|
|
|
595
634
|
* @internal
|
|
596
635
|
*/
|
|
597
636
|
declare function getTypeVariants(types: ts.Type[]): Set<TypeVariant>;
|
|
598
|
-
|
|
637
|
+
//#endregion
|
|
638
|
+
//#region src/utils/get-instance-id.d.ts
|
|
599
639
|
/** @internal */
|
|
600
640
|
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;
|
|
601
|
-
|
|
641
|
+
//#endregion
|
|
642
|
+
//#region src/utils/is-from-react.d.ts
|
|
602
643
|
/**
|
|
603
644
|
* Check if an identifier name is initialized from react
|
|
604
645
|
* @param name The top-level identifier's name
|
|
@@ -608,22 +649,24 @@ declare function getInstanceId(node: TSESTree.Node, prev?: TSESTree.Node): TSEST
|
|
|
608
649
|
* @internal
|
|
609
650
|
*/
|
|
610
651
|
declare function isInitializedFromReact(name: string, importSource: string, initialScope: Scope): boolean;
|
|
611
|
-
|
|
652
|
+
//#endregion
|
|
653
|
+
//#region src/utils/is-instance-id-equal.d.ts
|
|
612
654
|
/** @internal */
|
|
613
655
|
declare function isInstanceIdEqual(context: RuleContext, a: TSESTree.Node, b: TSESTree.Node): boolean;
|
|
614
|
-
|
|
656
|
+
//#endregion
|
|
657
|
+
//#region src/utils/is-react-api.d.ts
|
|
615
658
|
declare namespace isReactAPI {
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
659
|
+
type ReturnType = {
|
|
660
|
+
(context: RuleContext, node: unit | null | TSESTree.Node): node is TSESTree.Identifier | TSESTree.MemberExpression;
|
|
661
|
+
(context: RuleContext): (node: unit | null | TSESTree.Node) => node is TSESTree.MemberExpression | TSESTree.Identifier;
|
|
662
|
+
};
|
|
620
663
|
}
|
|
621
664
|
declare function isReactAPI(api: string): isReactAPI.ReturnType;
|
|
622
665
|
declare namespace isReactAPICall {
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
666
|
+
type ReturnType = {
|
|
667
|
+
(context: RuleContext, node: unit | null | TSESTree.Node): node is TSESTree.CallExpression;
|
|
668
|
+
(context: RuleContext): (node: unit | null | TSESTree.Node) => node is TSESTree.CallExpression;
|
|
669
|
+
};
|
|
627
670
|
}
|
|
628
671
|
declare function isReactAPICall(api: string): isReactAPICall.ReturnType;
|
|
629
672
|
declare const isCaptureOwnerStack: isReactAPI.ReturnType;
|
|
@@ -652,5 +695,5 @@ declare const isCreateRefCall: isReactAPICall.ReturnType;
|
|
|
652
695
|
declare const isForwardRefCall: isReactAPICall.ReturnType;
|
|
653
696
|
declare const isMemoCall: isReactAPICall.ReturnType;
|
|
654
697
|
declare const isLazyCall: isReactAPICall.ReturnType;
|
|
655
|
-
|
|
656
|
-
export {
|
|
698
|
+
//#endregion
|
|
699
|
+
export { ClassComponent, Component, ComponentDetectionHint, ComponentEffectPhaseKind, ComponentFlag, ComponentKind, ComponentLifecyclePhaseKind, ComponentPhaseKind, ComponentPhaseRelevance, ComponentStateKind, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, EffectKind, FunctionComponent, Hook, JSXDetectionHint, REACT_BUILTIN_HOOK_NAMES, SemanticEntry, SemanticNode, TypeVariant, findParentAttribute, getAttribute, getAttributeName, getAttributeValue, getComponentFlagFromInitPath, getComponentNameFromId, getElementType, getFunctionComponentId, getInstanceId, getTypeVariants, hasAnyAttribute, hasAttribute, hasEveryAttribute, hasNoneOrLooseComponentName, isAnyType, isAssignmentToThisState, isBigIntType, isBooleanType, isCaptureOwnerStack, isCaptureOwnerStackCall, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDidUpdate, isComponentName, isComponentNameLoose, isComponentWillMount, isComponentWillReceiveProps, isComponentWillUnmount, isComponentWillUpdate, isComponentWrapperCall, isComponentWrapperCallLoose, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isEnumType, isFalseLiteralType, isFalsyBigIntType, isFalsyNumberType, isFalsyStringType, isForwardRef, isForwardRefCall, isFragmentElement, isFunctionOfRender, isFunctionOfRenderMethod, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isHostElement, isInitializedFromReact, isInstanceIdEqual, isInversePhase, isJsxLike, isJsxText, isLazy, isLazyCall, isMemo, isMemoCall, isNeverType, isNullishType, isNumberType, isObjectType, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookId, isReactHookName, isRenderFunctionLoose, isRenderLike, isRenderMethodLike, isRenderPropLoose, isShouldComponentUpdate, isStringType, isThisSetState, isTrueLiteralType, isTruthyBigIntType, isTruthyNumberType, isTruthyStringType, isUnknownType, isUnsafeComponentWillMount, isUnsafeComponentWillReceiveProps, isUnsafeComponentWillUpdate, isUseActionStateCall, isUseCall, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseFormStatusCall, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseOptimisticCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, isValidComponentDefinition, stringifyJsx, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
|