@eslint-react/core 1.52.10-beta.0 → 1.52.10-beta.1
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.mts +218 -176
- package/dist/index.d.ts +218 -176
- package/dist/index.js +978 -823
- package/dist/index.mjs +966 -808
- package/package.json +8 -8
package/dist/index.d.mts
CHANGED
|
@@ -1,137 +1,144 @@
|
|
|
1
|
-
import * as AST from
|
|
2
|
-
import { unit } from
|
|
3
|
-
import { RuleContext } from
|
|
4
|
-
import { TSESTree } from
|
|
5
|
-
import
|
|
6
|
-
import * as
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
|
|
1
|
+
import * as AST from "@eslint-react/ast";
|
|
2
|
+
import { unit } from "@eslint-react/eff";
|
|
3
|
+
import { RuleContext } from "@eslint-react/kit";
|
|
4
|
+
import { TSESTree } from "@typescript-eslint/types";
|
|
5
|
+
import * as VAR from "@eslint-react/var";
|
|
6
|
+
import * as birecord0 from "birecord";
|
|
7
|
+
import { ESLintUtils, TSESTree as TSESTree$1 } from "@typescript-eslint/utils";
|
|
8
|
+
import { Scope } from "@typescript-eslint/scope-manager";
|
|
9
|
+
|
|
10
|
+
//#region src/component/component-detection-hint.d.ts
|
|
10
11
|
type ComponentDetectionHint = bigint;
|
|
11
12
|
/**
|
|
12
13
|
* Hints for component collector
|
|
13
14
|
*/
|
|
14
15
|
declare const ComponentDetectionHint: {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Skip function component created by React.memo
|
|
18
|
+
*/
|
|
19
|
+
readonly SkipMemo: bigint;
|
|
20
|
+
/**
|
|
21
|
+
* Skip function component created by React.forwardRef
|
|
22
|
+
*/
|
|
23
|
+
readonly SkipForwardRef: bigint;
|
|
24
|
+
/**
|
|
25
|
+
* Skip function component defined as array map argument
|
|
26
|
+
*/
|
|
27
|
+
readonly SkipArrayMapArgument: bigint;
|
|
28
|
+
/**
|
|
29
|
+
* Skip function component defined on object method
|
|
30
|
+
*/
|
|
31
|
+
readonly SkipObjectMethod: bigint;
|
|
32
|
+
/**
|
|
33
|
+
* Skip function component defined on class method
|
|
34
|
+
*/
|
|
35
|
+
readonly SkipClassMethod: bigint;
|
|
36
|
+
/**
|
|
37
|
+
* Skip function component defined on class property
|
|
38
|
+
*/
|
|
39
|
+
readonly SkipClassProperty: bigint;
|
|
40
|
+
readonly None: 0n;
|
|
41
|
+
readonly SkipUndefined: bigint;
|
|
42
|
+
readonly SkipNullLiteral: bigint;
|
|
43
|
+
readonly SkipBooleanLiteral: bigint;
|
|
44
|
+
readonly SkipStringLiteral: bigint;
|
|
45
|
+
readonly SkipNumberLiteral: bigint;
|
|
46
|
+
readonly SkipBigIntLiteral: bigint;
|
|
47
|
+
readonly SkipEmptyArray: bigint;
|
|
48
|
+
readonly SkipCreateElement: bigint;
|
|
49
|
+
readonly StrictArray: bigint;
|
|
50
|
+
readonly StrictLogical: bigint;
|
|
51
|
+
readonly StrictConditional: bigint;
|
|
51
52
|
};
|
|
52
53
|
/**
|
|
53
54
|
* Default component detection hint
|
|
54
55
|
*/
|
|
55
56
|
declare const DEFAULT_COMPONENT_DETECTION_HINT: bigint;
|
|
56
|
-
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/component/component-phase.d.ts
|
|
57
59
|
type ComponentEffectPhaseKind = "cleanup" | "setup";
|
|
58
60
|
type ComponentLifecyclePhaseKind = "mount" | "unmount";
|
|
59
61
|
type ComponentPhaseKind = ComponentEffectPhaseKind | ComponentLifecyclePhaseKind;
|
|
60
|
-
declare const ComponentPhaseRelevance:
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
declare const ComponentPhaseRelevance: birecord0.BiRecord<{
|
|
63
|
+
readonly mount: "unmount";
|
|
64
|
+
readonly setup: "cleanup";
|
|
63
65
|
}>;
|
|
64
66
|
declare const isInversePhase: {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
(a: ComponentPhaseKind): (b: ComponentPhaseKind) => boolean;
|
|
68
|
+
(a: ComponentPhaseKind, b: ComponentPhaseKind): boolean;
|
|
67
69
|
};
|
|
68
|
-
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/semantic/semantic-entry.d.ts
|
|
69
72
|
interface SemanticEntry {
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
node: TSESTree.Node;
|
|
74
|
+
phase: ComponentPhaseKind;
|
|
72
75
|
}
|
|
73
|
-
|
|
76
|
+
//#endregion
|
|
77
|
+
//#region src/semantic/semantic-node.d.ts
|
|
74
78
|
interface SemanticNode {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
id: unit | TSESTree.Identifier | TSESTree.Identifier[];
|
|
80
|
+
key: string;
|
|
81
|
+
kind: string;
|
|
82
|
+
name: unit | string;
|
|
83
|
+
node: TSESTree.Node;
|
|
84
|
+
flag: bigint;
|
|
85
|
+
hint: bigint;
|
|
82
86
|
}
|
|
83
|
-
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/component/component-flag.d.ts
|
|
84
89
|
type ComponentFlag = bigint;
|
|
85
90
|
declare const ComponentFlag: {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
None: bigint;
|
|
92
|
+
PureComponent: bigint;
|
|
93
|
+
CreateElement: bigint;
|
|
94
|
+
Memo: bigint;
|
|
95
|
+
ForwardRef: bigint;
|
|
96
|
+
Async: bigint;
|
|
92
97
|
};
|
|
93
|
-
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/component/component-semantic-node.d.ts
|
|
94
100
|
interface FunctionComponent extends SemanticNode {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
id: unit | TSESTree.Identifier | TSESTree.Identifier[];
|
|
102
|
+
kind: "function";
|
|
103
|
+
node: AST.TSESTreeFunction;
|
|
104
|
+
flag: ComponentFlag;
|
|
105
|
+
hint: ComponentDetectionHint;
|
|
106
|
+
initPath: unit | AST.FunctionInitPath;
|
|
107
|
+
hookCalls: TSESTree.CallExpression[];
|
|
108
|
+
displayName: unit | TSESTree.Expression;
|
|
103
109
|
}
|
|
104
110
|
interface ClassComponent extends SemanticNode {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
id: unit | TSESTree.Identifier;
|
|
112
|
+
kind: "class";
|
|
113
|
+
node: AST.TSESTreeClass;
|
|
114
|
+
flag: ComponentFlag;
|
|
115
|
+
hint: ComponentDetectionHint;
|
|
116
|
+
methods: AST.TSESTreeMethodOrProperty[];
|
|
117
|
+
displayName: unit | TSESTree.Expression;
|
|
112
118
|
}
|
|
113
119
|
type Component = ClassComponent | FunctionComponent;
|
|
114
|
-
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region src/component/component-collector.d.ts
|
|
115
122
|
type FunctionEntry = {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
123
|
+
key: string;
|
|
124
|
+
node: AST.TSESTreeFunction;
|
|
125
|
+
hookCalls: TSESTree.CallExpression[];
|
|
126
|
+
isComponent: boolean;
|
|
120
127
|
};
|
|
121
128
|
declare namespace useComponentCollector {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
};
|
|
133
|
-
listeners: ESLintUtils.RuleListener;
|
|
129
|
+
type Options = {
|
|
130
|
+
collectDisplayName?: boolean;
|
|
131
|
+
collectHookCalls?: boolean;
|
|
132
|
+
hint?: ComponentDetectionHint;
|
|
133
|
+
};
|
|
134
|
+
type ReturnType = {
|
|
135
|
+
ctx: {
|
|
136
|
+
getAllComponents: (node: TSESTree.Program) => Map<string, FunctionComponent>;
|
|
137
|
+
getCurrentEntries: () => FunctionEntry[];
|
|
138
|
+
getCurrentEntry: () => FunctionEntry | unit;
|
|
134
139
|
};
|
|
140
|
+
listeners: ESLintUtils.RuleListener;
|
|
141
|
+
};
|
|
135
142
|
}
|
|
136
143
|
/**
|
|
137
144
|
* Get a ctx and listeners for the rule to collect function components
|
|
@@ -140,23 +147,26 @@ declare namespace useComponentCollector {
|
|
|
140
147
|
* @returns The component collector
|
|
141
148
|
*/
|
|
142
149
|
declare function useComponentCollector(context: RuleContext, options?: useComponentCollector.Options): useComponentCollector.ReturnType;
|
|
143
|
-
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/component/component-collector-legacy.d.ts
|
|
144
152
|
declare namespace useComponentCollectorLegacy {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
};
|
|
149
|
-
listeners: ESLintUtils.RuleListener;
|
|
153
|
+
type ReturnType = {
|
|
154
|
+
ctx: {
|
|
155
|
+
getAllComponents: (node: TSESTree$1.Program) => Map<string, ClassComponent>;
|
|
150
156
|
};
|
|
157
|
+
listeners: ESLintUtils.RuleListener;
|
|
158
|
+
};
|
|
151
159
|
}
|
|
152
160
|
/**
|
|
153
161
|
* Get a ctx and listeners object for the rule to collect class components
|
|
154
162
|
* @returns The context and listeners for the rule
|
|
155
163
|
*/
|
|
156
164
|
declare function useComponentCollectorLegacy(): useComponentCollectorLegacy.ReturnType;
|
|
157
|
-
|
|
165
|
+
//#endregion
|
|
166
|
+
//#region src/component/component-definition.d.ts
|
|
158
167
|
declare function isValidComponentDefinition(context: RuleContext, node: AST.TSESTreeFunction, hint: bigint): boolean;
|
|
159
|
-
|
|
168
|
+
//#endregion
|
|
169
|
+
//#region src/component/component-hierarchy.d.ts
|
|
160
170
|
/**
|
|
161
171
|
* Determines whether inside `createElement`'s children.
|
|
162
172
|
* @param context The rule context
|
|
@@ -195,11 +205,14 @@ declare function isFunctionOfComponentWillUnmount(node: TSESTree.Node): boolean;
|
|
|
195
205
|
* @returns `true` if node is a render function, `false` if not
|
|
196
206
|
*/
|
|
197
207
|
declare function isFunctionOfRenderMethod(node: AST.TSESTreeFunction): boolean;
|
|
198
|
-
|
|
208
|
+
//#endregion
|
|
209
|
+
//#region src/component/component-id.d.ts
|
|
199
210
|
declare function getFunctionComponentId(context: RuleContext, node: AST.TSESTreeFunction): TSESTree.Identifier | TSESTree.Identifier[] | unit;
|
|
200
|
-
|
|
211
|
+
//#endregion
|
|
212
|
+
//#region src/component/component-init-path.d.ts
|
|
201
213
|
declare function getComponentFlagFromInitPath(initPath: FunctionComponent["initPath"]): bigint;
|
|
202
|
-
|
|
214
|
+
//#endregion
|
|
215
|
+
//#region src/component/component-is.d.ts
|
|
203
216
|
/**
|
|
204
217
|
* Check if a node is a React class component
|
|
205
218
|
* @param node The AST node to check
|
|
@@ -212,9 +225,11 @@ declare function isClassComponent(node: TSESTree.Node): node is AST.TSESTreeClas
|
|
|
212
225
|
* @returns `true` if the node is a pure component, `false` otherwise
|
|
213
226
|
*/
|
|
214
227
|
declare function isPureComponent(node: TSESTree.Node): boolean;
|
|
215
|
-
|
|
228
|
+
//#endregion
|
|
229
|
+
//#region src/component/component-kind.d.ts
|
|
216
230
|
type ComponentKind = "classComponent" | "functionComponent";
|
|
217
|
-
|
|
231
|
+
//#endregion
|
|
232
|
+
//#region src/component/component-lifecycle.d.ts
|
|
218
233
|
declare function isComponentDidCatch(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
219
234
|
declare function isComponentDidMount(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
220
235
|
declare function isComponentDidUpdate(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
@@ -232,12 +247,14 @@ declare function isUnsafeComponentWillReceiveProps(node: TSESTree.Node): node is
|
|
|
232
247
|
declare function isUnsafeComponentWillUpdate(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
233
248
|
declare function isGetDerivedStateFromProps(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
234
249
|
declare function isGetDerivedStateFromError(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
235
|
-
|
|
250
|
+
//#endregion
|
|
251
|
+
//#region src/component/component-name.d.ts
|
|
236
252
|
declare function isComponentName(name: string): boolean;
|
|
237
253
|
declare function isComponentNameLoose(name: string): boolean;
|
|
238
254
|
declare function getComponentNameFromId(id: TSESTree.Identifier | TSESTree.Identifier[] | unit): string | undefined;
|
|
239
255
|
declare function hasNoneOrLooseComponentName(context: RuleContext, fn: AST.TSESTreeFunction): boolean;
|
|
240
|
-
|
|
256
|
+
//#endregion
|
|
257
|
+
//#region src/component/component-render.d.ts
|
|
241
258
|
/**
|
|
242
259
|
* Check whether given node is a render function of a class component
|
|
243
260
|
* @example
|
|
@@ -263,7 +280,8 @@ declare function isRenderLike(node: TSESTree.Node): node is AST.TSESTreeMethodOr
|
|
|
263
280
|
* @returns `true` if node is a render function, `false` if not
|
|
264
281
|
*/
|
|
265
282
|
declare function isFunctionOfRender(node: AST.TSESTreeFunction): boolean;
|
|
266
|
-
|
|
283
|
+
//#endregion
|
|
284
|
+
//#region src/component/component-render-method.d.ts
|
|
267
285
|
/**
|
|
268
286
|
* Check whether given node is a render method of a class component
|
|
269
287
|
* @example
|
|
@@ -277,7 +295,8 @@ declare function isFunctionOfRender(node: AST.TSESTreeFunction): boolean;
|
|
|
277
295
|
* @returns `true` if node is a render function, `false` if not
|
|
278
296
|
*/
|
|
279
297
|
declare function isRenderMethodLike(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
280
|
-
|
|
298
|
+
//#endregion
|
|
299
|
+
//#region src/component/component-render-prop.d.ts
|
|
281
300
|
/**
|
|
282
301
|
* Unsafe check whether given node is a render function
|
|
283
302
|
* ```tsx
|
|
@@ -327,11 +346,13 @@ declare function isDirectValueOfRenderPropertyLoose(node: TSESTree.Node): boolea
|
|
|
327
346
|
* @returns `true` if component is declared inside a render prop, `false` if not
|
|
328
347
|
*/
|
|
329
348
|
declare function isDeclaredInRenderPropLoose(node: TSESTree.Node): boolean;
|
|
330
|
-
|
|
349
|
+
//#endregion
|
|
350
|
+
//#region src/component/component-state.d.ts
|
|
331
351
|
type ComponentStateKind = "actionState" | "state";
|
|
332
352
|
declare function isThisSetState(node: TSESTree.CallExpression): boolean;
|
|
333
353
|
declare function isAssignmentToThisState(node: TSESTree.AssignmentExpression): boolean;
|
|
334
|
-
|
|
354
|
+
//#endregion
|
|
355
|
+
//#region src/component/component-wrapper.d.ts
|
|
335
356
|
/**
|
|
336
357
|
* Check if the node is a call expression for a component wrapper
|
|
337
358
|
* @param context The ESLint rule context
|
|
@@ -346,29 +367,34 @@ declare function isComponentWrapperCall(context: RuleContext, node: TSESTree.Nod
|
|
|
346
367
|
* @returns `true` if the node is a call expression for a component wrapper loosely
|
|
347
368
|
*/
|
|
348
369
|
declare function isComponentWrapperCallLoose(context: RuleContext, node: TSESTree.Node): boolean;
|
|
349
|
-
|
|
370
|
+
//#endregion
|
|
371
|
+
//#region src/effect/effect-kind.d.ts
|
|
350
372
|
type EffectKind = "useEffect" | "useLayoutEffect" | "useInsertionEffect";
|
|
351
|
-
|
|
373
|
+
//#endregion
|
|
374
|
+
//#region src/hook/hook-semantic-node.d.ts
|
|
352
375
|
interface Hook extends SemanticNode {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
376
|
+
id: TSESTree.Identifier | unit;
|
|
377
|
+
node: AST.TSESTreeFunction;
|
|
378
|
+
name: string;
|
|
379
|
+
hookCalls: TSESTree.CallExpression[];
|
|
357
380
|
}
|
|
358
|
-
|
|
381
|
+
//#endregion
|
|
382
|
+
//#region src/hook/hook-collector.d.ts
|
|
359
383
|
declare namespace useHookCollector {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
};
|
|
364
|
-
listeners: ESLintUtils.RuleListener;
|
|
384
|
+
type ReturnType = {
|
|
385
|
+
ctx: {
|
|
386
|
+
getAllHooks(node: TSESTree$1.Program): Map<string, Hook>;
|
|
365
387
|
};
|
|
388
|
+
listeners: ESLintUtils.RuleListener;
|
|
389
|
+
};
|
|
366
390
|
}
|
|
367
391
|
declare function useHookCollector(): useHookCollector.ReturnType;
|
|
368
|
-
|
|
392
|
+
//#endregion
|
|
393
|
+
//#region src/hook/hook-hierarchy.d.ts
|
|
369
394
|
declare function isFunctionOfUseEffectSetup(node: TSESTree.Node | unit): boolean;
|
|
370
395
|
declare function isFunctionOfUseEffectCleanup(node: TSESTree.Node | unit): boolean;
|
|
371
|
-
|
|
396
|
+
//#endregion
|
|
397
|
+
//#region src/hook/hook-is.d.ts
|
|
372
398
|
declare function isReactHook(node: AST.TSESTreeFunction | unit): boolean;
|
|
373
399
|
/**
|
|
374
400
|
* Check if the given node is a React Hook call by its name.
|
|
@@ -399,9 +425,11 @@ declare const isUseRefCall: (context: RuleContext, node: TSESTree.Node | undefin
|
|
|
399
425
|
declare const isUseStateCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
400
426
|
declare const isUseSyncExternalStoreCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
401
427
|
declare const isUseTransitionCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
402
|
-
|
|
428
|
+
//#endregion
|
|
429
|
+
//#region src/hook/hook-kind.d.ts
|
|
403
430
|
type HookKind = "custom" | "useActionState" | "useCallback" | "useContext" | "useDebugValue" | "useDeferredValue" | "useEffect" | "useId" | "useImperativeHandle" | "useInsertionEffect" | "useLayoutEffect" | "useMemo" | "useOptimistic" | "useReducer" | "useRef" | "useState" | "useSyncExternalStore" | "useTransition";
|
|
404
|
-
|
|
431
|
+
//#endregion
|
|
432
|
+
//#region src/hook/hook-name.d.ts
|
|
405
433
|
/**
|
|
406
434
|
* Catch all identifiers that begin with "use" followed by an uppercase Latin
|
|
407
435
|
* character to exclude identifiers like "user".
|
|
@@ -409,7 +437,8 @@ type HookKind = "custom" | "useActionState" | "useCallback" | "useContext" | "us
|
|
|
409
437
|
* @see https://github.com/facebook/react/blob/1d6c8168db1d82713202e842df3167787ffa00ed/packages/eslint-plugin-react-hooks/src/rules/RulesOfHooks.ts#L16
|
|
410
438
|
*/
|
|
411
439
|
declare function isReactHookName(name: string): boolean;
|
|
412
|
-
|
|
440
|
+
//#endregion
|
|
441
|
+
//#region src/jsx/jsx-attribute.d.ts
|
|
413
442
|
/**
|
|
414
443
|
* Get the JSX attribute node with the given name
|
|
415
444
|
* @param context The ESLint rule context
|
|
@@ -419,7 +448,8 @@ declare function isReactHookName(name: string): boolean;
|
|
|
419
448
|
* @returns The JSX attribute node or undefined
|
|
420
449
|
*/
|
|
421
450
|
declare function getAttribute(context: RuleContext, name: string, attributes: (TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute)[], initialScope?: Scope): TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute | unit;
|
|
422
|
-
|
|
451
|
+
//#endregion
|
|
452
|
+
//#region src/jsx/jsx-attribute-name.d.ts
|
|
423
453
|
/**
|
|
424
454
|
* Get the stringified name of a JSX attribute
|
|
425
455
|
* @param context The ESLint rule context
|
|
@@ -427,7 +457,8 @@ declare function getAttribute(context: RuleContext, name: string, attributes: (T
|
|
|
427
457
|
* @returns The name of the attribute
|
|
428
458
|
*/
|
|
429
459
|
declare function getAttributeName(context: RuleContext, node: TSESTree$1.JSXAttribute): string;
|
|
430
|
-
|
|
460
|
+
//#endregion
|
|
461
|
+
//#region src/jsx/jsx-attribute-value.d.ts
|
|
431
462
|
/**
|
|
432
463
|
* Get a StaticValue of the attribute value
|
|
433
464
|
* @param context The rule context
|
|
@@ -436,26 +467,28 @@ declare function getAttributeName(context: RuleContext, node: TSESTree$1.JSXAttr
|
|
|
436
467
|
* @returns The StaticValue of the attribute value
|
|
437
468
|
*/
|
|
438
469
|
declare function getAttributeValue(context: RuleContext, node: TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute, name: string): Exclude<VAR.LazyValue, {
|
|
439
|
-
|
|
470
|
+
kind: "lazy";
|
|
440
471
|
}>;
|
|
441
|
-
|
|
472
|
+
//#endregion
|
|
473
|
+
//#region src/jsx/jsx-detection-hint.d.ts
|
|
442
474
|
type JSXDetectionHint = bigint;
|
|
443
475
|
declare const JSXDetectionHint: {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
476
|
+
readonly None: 0n;
|
|
477
|
+
readonly SkipUndefined: bigint;
|
|
478
|
+
readonly SkipNullLiteral: bigint;
|
|
479
|
+
readonly SkipBooleanLiteral: bigint;
|
|
480
|
+
readonly SkipStringLiteral: bigint;
|
|
481
|
+
readonly SkipNumberLiteral: bigint;
|
|
482
|
+
readonly SkipBigIntLiteral: bigint;
|
|
483
|
+
readonly SkipEmptyArray: bigint;
|
|
484
|
+
readonly SkipCreateElement: bigint;
|
|
485
|
+
readonly StrictArray: bigint;
|
|
486
|
+
readonly StrictLogical: bigint;
|
|
487
|
+
readonly StrictConditional: bigint;
|
|
456
488
|
};
|
|
457
489
|
declare const DEFAULT_JSX_DETECTION_HINT: bigint;
|
|
458
|
-
|
|
490
|
+
//#endregion
|
|
491
|
+
//#region src/jsx/jsx-detection.d.ts
|
|
459
492
|
/**
|
|
460
493
|
* Check if a node is a `JSXText` or a `Literal` node
|
|
461
494
|
* @param node The AST node to check
|
|
@@ -471,9 +504,10 @@ declare function isJsxText(node: TSESTree$1.Node | null | unit): node is TSESTre
|
|
|
471
504
|
* @returns boolean
|
|
472
505
|
*/
|
|
473
506
|
declare function isJsxLike(code: {
|
|
474
|
-
|
|
507
|
+
getScope: (node: TSESTree$1.Node) => Scope;
|
|
475
508
|
}, node: TSESTree$1.Node | unit | null, hint?: JSXDetectionHint): boolean;
|
|
476
|
-
|
|
509
|
+
//#endregion
|
|
510
|
+
//#region src/jsx/jsx-element-type.d.ts
|
|
477
511
|
/**
|
|
478
512
|
* Get the stringified type of a JSX element
|
|
479
513
|
* @param context The ESLint rule context
|
|
@@ -481,11 +515,13 @@ declare function isJsxLike(code: {
|
|
|
481
515
|
* @returns The type of the element
|
|
482
516
|
*/
|
|
483
517
|
declare function getElementType(context: RuleContext, node: TSESTree.JSXElement | TSESTree.JSXFragment): string;
|
|
484
|
-
|
|
518
|
+
//#endregion
|
|
519
|
+
//#region src/jsx/jsx-has.d.ts
|
|
485
520
|
declare function hasAttribute(context: RuleContext, name: string, attributes: TSESTree.JSXOpeningElement["attributes"], initialScope?: Scope): boolean;
|
|
486
521
|
declare function hasAnyAttribute(context: RuleContext, names: string[], attributes: TSESTree.JSXOpeningElement["attributes"], initialScope?: Scope): boolean;
|
|
487
522
|
declare function hasEveryAttribute(context: RuleContext, names: string[], attributes: TSESTree.JSXOpeningElement["attributes"], initialScope?: Scope): boolean;
|
|
488
|
-
|
|
523
|
+
//#endregion
|
|
524
|
+
//#region src/jsx/jsx-hierarchy.d.ts
|
|
489
525
|
/**
|
|
490
526
|
* Find the parent JSX attribute node of a node
|
|
491
527
|
* @param node The node to find the parent attribute of
|
|
@@ -493,22 +529,26 @@ declare function hasEveryAttribute(context: RuleContext, names: string[], attrib
|
|
|
493
529
|
* @returns The parent attribute node or undefined
|
|
494
530
|
*/
|
|
495
531
|
declare function findParentAttribute(node: TSESTree.Node, test?: (node: TSESTree.JSXAttribute) => boolean): TSESTree.JSXAttribute | unit;
|
|
496
|
-
|
|
532
|
+
//#endregion
|
|
533
|
+
//#region src/jsx/jsx-is.d.ts
|
|
497
534
|
declare function isHostElement(context: RuleContext, node: TSESTree.Node): boolean;
|
|
498
535
|
declare function isKeyedElement(context: RuleContext, node: TSESTree.Node, initialScope?: Scope): boolean;
|
|
499
536
|
declare function isFragmentElement(context: RuleContext, node: TSESTree.Node | null | unit, allowJSXFragment?: false): node is TSESTree.JSXElement;
|
|
500
537
|
declare function isFragmentElement(context: RuleContext, node: TSESTree.Node | null | unit, allowJSXFragment?: true): node is TSESTree.JSXElement | TSESTree.JSXFragment;
|
|
501
|
-
|
|
538
|
+
//#endregion
|
|
539
|
+
//#region src/jsx/jsx-stringify.d.ts
|
|
502
540
|
/**
|
|
503
541
|
* Get the stringified representation of a JSX node
|
|
504
542
|
* @param node The JSX node
|
|
505
543
|
* @returns The stringified representation
|
|
506
544
|
*/
|
|
507
545
|
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;
|
|
508
|
-
|
|
546
|
+
//#endregion
|
|
547
|
+
//#region src/utils/get-instance-id.d.ts
|
|
509
548
|
/** @internal */
|
|
510
|
-
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.
|
|
511
|
-
|
|
549
|
+
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;
|
|
550
|
+
//#endregion
|
|
551
|
+
//#region src/utils/is-from-react.d.ts
|
|
512
552
|
/**
|
|
513
553
|
* Check if an identifier name is initialized from react
|
|
514
554
|
* @param name The top-level identifier's name
|
|
@@ -518,22 +558,24 @@ declare function getInstanceId(node: TSESTree.Node, prev?: TSESTree.Node): TSEST
|
|
|
518
558
|
* @internal
|
|
519
559
|
*/
|
|
520
560
|
declare function isInitializedFromReact(name: string, importSource: string, initialScope: Scope): boolean;
|
|
521
|
-
|
|
561
|
+
//#endregion
|
|
562
|
+
//#region src/utils/is-instance-id-equal.d.ts
|
|
522
563
|
/** @internal */
|
|
523
564
|
declare function isInstanceIdEqual(context: RuleContext, a: TSESTree.Node, b: TSESTree.Node): boolean;
|
|
524
|
-
|
|
565
|
+
//#endregion
|
|
566
|
+
//#region src/utils/is-react-api.d.ts
|
|
525
567
|
declare namespace isReactAPI {
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
568
|
+
type ReturnType = {
|
|
569
|
+
(context: RuleContext, node: unit | null | TSESTree.Node): node is TSESTree.Identifier | TSESTree.MemberExpression;
|
|
570
|
+
(context: RuleContext): (node: unit | null | TSESTree.Node) => node is TSESTree.MemberExpression | TSESTree.Identifier;
|
|
571
|
+
};
|
|
530
572
|
}
|
|
531
573
|
declare function isReactAPI(api: string): isReactAPI.ReturnType;
|
|
532
574
|
declare namespace isReactAPICall {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
575
|
+
type ReturnType = {
|
|
576
|
+
(context: RuleContext, node: unit | null | TSESTree.Node): node is TSESTree.CallExpression;
|
|
577
|
+
(context: RuleContext): (node: unit | null | TSESTree.Node) => node is TSESTree.CallExpression;
|
|
578
|
+
};
|
|
537
579
|
}
|
|
538
580
|
declare function isReactAPICall(api: string): isReactAPICall.ReturnType;
|
|
539
581
|
declare const isCaptureOwnerStack: isReactAPI.ReturnType;
|
|
@@ -562,5 +604,5 @@ declare const isCreateRefCall: isReactAPICall.ReturnType;
|
|
|
562
604
|
declare const isForwardRefCall: isReactAPICall.ReturnType;
|
|
563
605
|
declare const isMemoCall: isReactAPICall.ReturnType;
|
|
564
606
|
declare const isLazyCall: isReactAPICall.ReturnType;
|
|
565
|
-
|
|
566
|
-
export {
|
|
607
|
+
//#endregion
|
|
608
|
+
export { ClassComponent, Component, ComponentDetectionHint, ComponentEffectPhaseKind, ComponentFlag, ComponentKind, ComponentLifecyclePhaseKind, ComponentPhaseKind, ComponentPhaseRelevance, ComponentStateKind, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, EffectKind, FunctionComponent, Hook, HookKind, JSXDetectionHint, SemanticEntry, SemanticNode, findParentAttribute, getAttribute, getAttributeName, getAttributeValue, getComponentFlagFromInitPath, getComponentNameFromId, getElementType, getFunctionComponentId, getInstanceId, hasAnyAttribute, hasAttribute, hasEveryAttribute, hasNoneOrLooseComponentName, isAssignmentToThisState, 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, isForwardRef, isForwardRefCall, isFragmentElement, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRender, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isHostElement, isInitializedFromReact, isInsideRenderMethod, isInstanceIdEqual, isInversePhase, isJsxLike, isJsxText, isKeyedElement, isLazy, isLazyCall, isMemo, isMemoCall, isPureComponent, isReactAPI, isReactAPICall, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderLike, isRenderMethodLike, isRenderPropLoose, isShouldComponentUpdate, isThisSetState, 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 };
|