@eslint-react/core 2.0.0-next.0 → 2.0.0-next.2
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.js +195 -340
- package/package.json +9 -17
- package/dist/index.d.mts +0 -544
- package/dist/index.mjs +0 -927
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.2",
|
|
4
4
|
"description": "ESLint React's ESLint utility module for static analysis of React core APIs and patterns.",
|
|
5
5
|
"homepage": "https://github.com/Rel1cx/eslint-react",
|
|
6
6
|
"bugs": {
|
|
@@ -14,22 +14,14 @@
|
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"author": "Rel1cx<rel1cx@proton.me>",
|
|
16
16
|
"sideEffects": false,
|
|
17
|
+
"type": "module",
|
|
17
18
|
"exports": {
|
|
18
19
|
".": {
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
"default": "./dist/index.mjs"
|
|
22
|
-
},
|
|
23
|
-
"require": {
|
|
24
|
-
"types": "./dist/index.d.ts",
|
|
25
|
-
"default": "./dist/index.js"
|
|
26
|
-
}
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
27
22
|
},
|
|
28
23
|
"./package.json": "./package.json"
|
|
29
24
|
},
|
|
30
|
-
"main": "dist/index.js",
|
|
31
|
-
"module": "dist/index.mjs",
|
|
32
|
-
"types": "dist/index.d.ts",
|
|
33
25
|
"files": [
|
|
34
26
|
"dist",
|
|
35
27
|
"./package.json"
|
|
@@ -41,11 +33,11 @@
|
|
|
41
33
|
"@typescript-eslint/utils": "^8.30.1",
|
|
42
34
|
"birecord": "^0.1.1",
|
|
43
35
|
"ts-pattern": "^5.7.0",
|
|
44
|
-
"@eslint-react/ast": "2.0.0-next.
|
|
45
|
-
"@eslint-react/
|
|
46
|
-
"@eslint-react/
|
|
47
|
-
"@eslint-react/
|
|
48
|
-
"@eslint-react/
|
|
36
|
+
"@eslint-react/ast": "2.0.0-next.2",
|
|
37
|
+
"@eslint-react/eff": "2.0.0-next.2",
|
|
38
|
+
"@eslint-react/kit": "2.0.0-next.2",
|
|
39
|
+
"@eslint-react/var": "2.0.0-next.2",
|
|
40
|
+
"@eslint-react/shared": "2.0.0-next.2"
|
|
49
41
|
},
|
|
50
42
|
"devDependencies": {
|
|
51
43
|
"tsup": "^8.4.0",
|
package/dist/index.d.mts
DELETED
|
@@ -1,544 +0,0 @@
|
|
|
1
|
-
import { RuleContext } from '@eslint-react/kit';
|
|
2
|
-
import { TSESTree } from '@typescript-eslint/types';
|
|
3
|
-
import { ESLintUtils, TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
|
|
4
|
-
import * as AST from '@eslint-react/ast';
|
|
5
|
-
import { _ } from '@eslint-react/eff';
|
|
6
|
-
import * as birecord from 'birecord';
|
|
7
|
-
import { Scope } from '@typescript-eslint/scope-manager';
|
|
8
|
-
import * as VAR from '@eslint-react/var';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Determines whether inside `createElement`'s children.
|
|
12
|
-
* @param context The rule context
|
|
13
|
-
* @param node The AST node to check
|
|
14
|
-
* @returns `true` if the node is inside createElement's children
|
|
15
|
-
*/
|
|
16
|
-
declare function isChildrenOfCreateElement(context: RuleContext, node: TSESTree.Node): boolean;
|
|
17
|
-
|
|
18
|
-
type ComponentDetectionHint = bigint;
|
|
19
|
-
/**
|
|
20
|
-
* Hints for component collector
|
|
21
|
-
*/
|
|
22
|
-
declare const ComponentDetectionHint: {
|
|
23
|
-
/**
|
|
24
|
-
* Skip function component created by React.memo
|
|
25
|
-
*/
|
|
26
|
-
readonly SkipMemo: bigint;
|
|
27
|
-
/**
|
|
28
|
-
* Skip function component created by React.forwardRef
|
|
29
|
-
*/
|
|
30
|
-
readonly SkipForwardRef: bigint;
|
|
31
|
-
/**
|
|
32
|
-
* Skip function component defined as array map argument
|
|
33
|
-
*/
|
|
34
|
-
readonly SkipArrayMapArgument: bigint;
|
|
35
|
-
/**
|
|
36
|
-
* Skip function component defined on object method
|
|
37
|
-
*/
|
|
38
|
-
readonly SkipObjectMethod: bigint;
|
|
39
|
-
/**
|
|
40
|
-
* Skip function component defined on class method
|
|
41
|
-
*/
|
|
42
|
-
readonly SkipClassMethod: bigint;
|
|
43
|
-
/**
|
|
44
|
-
* Skip function component defined on class property
|
|
45
|
-
*/
|
|
46
|
-
readonly SkipClassProperty: bigint;
|
|
47
|
-
readonly None: 0n;
|
|
48
|
-
readonly SkipUndefined: bigint;
|
|
49
|
-
readonly SkipNullLiteral: bigint;
|
|
50
|
-
readonly SkipBooleanLiteral: bigint;
|
|
51
|
-
readonly SkipStringLiteral: bigint;
|
|
52
|
-
readonly SkipNumberLiteral: bigint;
|
|
53
|
-
readonly SkipBigIntLiteral: bigint;
|
|
54
|
-
readonly SkipEmptyArray: bigint;
|
|
55
|
-
readonly SkipCreateElement: bigint;
|
|
56
|
-
readonly StrictArray: bigint;
|
|
57
|
-
readonly StrictLogical: bigint;
|
|
58
|
-
readonly StrictConditional: bigint;
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Default component detection hint
|
|
62
|
-
*/
|
|
63
|
-
declare const DEFAULT_COMPONENT_DETECTION_HINT: bigint;
|
|
64
|
-
|
|
65
|
-
type ComponentEffectPhaseKind = "cleanup" | "setup";
|
|
66
|
-
type ComponentLifecyclePhaseKind = "mount" | "unmount";
|
|
67
|
-
type ComponentPhaseKind = ComponentEffectPhaseKind | ComponentLifecyclePhaseKind;
|
|
68
|
-
declare const ComponentPhaseRelevance: birecord.BiRecord<{
|
|
69
|
-
readonly mount: "unmount";
|
|
70
|
-
readonly setup: "cleanup";
|
|
71
|
-
}>;
|
|
72
|
-
declare const isInversePhase: {
|
|
73
|
-
(a: ComponentPhaseKind): (b: ComponentPhaseKind) => boolean;
|
|
74
|
-
(a: ComponentPhaseKind, b: ComponentPhaseKind): boolean;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
interface SemanticEntry {
|
|
78
|
-
node: TSESTree.Node;
|
|
79
|
-
phase: ComponentPhaseKind;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
interface SemanticNode {
|
|
83
|
-
id: _ | TSESTree.Identifier | TSESTree.Identifier[];
|
|
84
|
-
key: string;
|
|
85
|
-
kind: string;
|
|
86
|
-
name: _ | string;
|
|
87
|
-
node: TSESTree.Node;
|
|
88
|
-
flag: bigint;
|
|
89
|
-
hint: bigint;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
type ComponentFlag = bigint;
|
|
93
|
-
declare const ComponentFlag: {
|
|
94
|
-
None: bigint;
|
|
95
|
-
PureComponent: bigint;
|
|
96
|
-
CreateElement: bigint;
|
|
97
|
-
Memo: bigint;
|
|
98
|
-
ForwardRef: bigint;
|
|
99
|
-
Async: bigint;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
interface FunctionComponent extends SemanticNode {
|
|
103
|
-
id: _ | TSESTree.Identifier | TSESTree.Identifier[];
|
|
104
|
-
kind: "function";
|
|
105
|
-
node: AST.TSESTreeFunction;
|
|
106
|
-
flag: ComponentFlag;
|
|
107
|
-
hint: ComponentDetectionHint;
|
|
108
|
-
initPath: _ | AST.FunctionInitPath;
|
|
109
|
-
hookCalls: TSESTree.CallExpression[];
|
|
110
|
-
displayName: _ | TSESTree.Expression;
|
|
111
|
-
}
|
|
112
|
-
interface ClassComponent extends SemanticNode {
|
|
113
|
-
id: _ | TSESTree.Identifier;
|
|
114
|
-
kind: "class";
|
|
115
|
-
node: AST.TSESTreeClass;
|
|
116
|
-
flag: ComponentFlag;
|
|
117
|
-
hint: ComponentDetectionHint;
|
|
118
|
-
methods: AST.TSESTreeMethodOrProperty[];
|
|
119
|
-
displayName: _ | TSESTree.Expression;
|
|
120
|
-
}
|
|
121
|
-
type Component = ClassComponent | FunctionComponent;
|
|
122
|
-
|
|
123
|
-
type FunctionEntry = {
|
|
124
|
-
key: string;
|
|
125
|
-
node: AST.TSESTreeFunction;
|
|
126
|
-
hookCalls: TSESTree.CallExpression[];
|
|
127
|
-
isComponent: boolean;
|
|
128
|
-
};
|
|
129
|
-
declare namespace useComponentCollector {
|
|
130
|
-
type Options = {
|
|
131
|
-
collectDisplayName?: boolean;
|
|
132
|
-
collectHookCalls?: boolean;
|
|
133
|
-
hint?: ComponentDetectionHint;
|
|
134
|
-
};
|
|
135
|
-
type ReturnType = {
|
|
136
|
-
ctx: {
|
|
137
|
-
getAllComponents: (node: TSESTree.Program) => Map<string, FunctionComponent>;
|
|
138
|
-
getCurrentEntries: () => FunctionEntry[];
|
|
139
|
-
getCurrentEntry: () => FunctionEntry | _;
|
|
140
|
-
};
|
|
141
|
-
listeners: ESLintUtils.RuleListener;
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Get a ctx and listeners for the rule to collect function components
|
|
146
|
-
* @param context The ESLint rule context
|
|
147
|
-
* @param options The options to use
|
|
148
|
-
* @returns The component collector
|
|
149
|
-
*/
|
|
150
|
-
declare function useComponentCollector(context: RuleContext, options?: useComponentCollector.Options): useComponentCollector.ReturnType;
|
|
151
|
-
|
|
152
|
-
declare namespace useComponentCollectorLegacy {
|
|
153
|
-
type ReturnType = {
|
|
154
|
-
ctx: {
|
|
155
|
-
getAllComponents: (node: TSESTree$1.Program) => Map<string, ClassComponent>;
|
|
156
|
-
};
|
|
157
|
-
listeners: ESLintUtils.RuleListener;
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Get a ctx and listeners object for the rule to collect class components
|
|
162
|
-
* @returns The context and listeners for the rule
|
|
163
|
-
*/
|
|
164
|
-
declare function useComponentCollectorLegacy(): useComponentCollectorLegacy.ReturnType;
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Check whether given node is a function of a render method of a class component
|
|
168
|
-
* @example
|
|
169
|
-
* ```tsx
|
|
170
|
-
* class Component extends React.Component {
|
|
171
|
-
* renderHeader = () => <div />;
|
|
172
|
-
* renderFooter = () => <div />;
|
|
173
|
-
* }
|
|
174
|
-
* ```
|
|
175
|
-
* @param node The AST node to check
|
|
176
|
-
* @returns `true` if node is a render function, `false` if not
|
|
177
|
-
*/
|
|
178
|
-
declare function isFunctionOfRenderMethod(node: AST.TSESTreeFunction): boolean;
|
|
179
|
-
declare function isValidComponentDefinition(context: RuleContext, node: AST.TSESTreeFunction, hint: bigint): boolean;
|
|
180
|
-
|
|
181
|
-
declare function getFunctionComponentId(context: RuleContext, node: AST.TSESTreeFunction): TSESTree.Identifier | TSESTree.Identifier[] | _;
|
|
182
|
-
|
|
183
|
-
declare function getComponentFlagFromInitPath(initPath: FunctionComponent["initPath"]): bigint;
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Check if a node is a React class component
|
|
187
|
-
* @param node The AST node to check
|
|
188
|
-
* @returns `true` if the node is a class component, `false` otherwise
|
|
189
|
-
*/
|
|
190
|
-
declare function isClassComponent(node: TSESTree.Node): node is AST.TSESTreeClass;
|
|
191
|
-
/**
|
|
192
|
-
* Check if a node is a React PureComponent
|
|
193
|
-
* @param node The AST node to check
|
|
194
|
-
* @returns `true` if the node is a pure component, `false` otherwise
|
|
195
|
-
*/
|
|
196
|
-
declare function isPureComponent(node: TSESTree.Node): boolean;
|
|
197
|
-
|
|
198
|
-
type ComponentKind = "classComponent" | "functionComponent";
|
|
199
|
-
|
|
200
|
-
declare function isComponentDidCatch(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
201
|
-
declare function isComponentDidMount(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
202
|
-
declare function isComponentDidUpdate(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
203
|
-
declare function isComponentWillMount(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
204
|
-
declare function isComponentWillReceiveProps(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
205
|
-
declare function isComponentWillUnmount(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
206
|
-
declare function isComponentWillUpdate(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
207
|
-
declare function isGetChildContext(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
208
|
-
declare function isGetDefaultProps(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
209
|
-
declare function isGetInitialState(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
210
|
-
declare function isGetSnapshotBeforeUpdate(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
211
|
-
declare function isShouldComponentUpdate(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
212
|
-
declare function isUnsafeComponentWillMount(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
213
|
-
declare function isUnsafeComponentWillReceiveProps(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
214
|
-
declare function isUnsafeComponentWillUpdate(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
215
|
-
declare function isGetDerivedStateFromProps(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
216
|
-
declare function isGetDerivedStateFromError(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
217
|
-
|
|
218
|
-
declare function isComponentName(name: string): boolean;
|
|
219
|
-
declare function isComponentNameLoose(name: string): boolean;
|
|
220
|
-
declare function getComponentNameFromId(id: TSESTree.Identifier | TSESTree.Identifier[] | _): string | undefined;
|
|
221
|
-
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
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Check whether given node is a render method of a class component
|
|
251
|
-
* @example
|
|
252
|
-
* ```tsx
|
|
253
|
-
* class Component extends React.Component {
|
|
254
|
-
* renderHeader = () => <div />;
|
|
255
|
-
* renderFooter = () => <div />;
|
|
256
|
-
* }
|
|
257
|
-
* ```
|
|
258
|
-
* @param node The AST node to check
|
|
259
|
-
* @returns `true` if node is a render function, `false` if not
|
|
260
|
-
*/
|
|
261
|
-
declare function isRenderMethodLike(node: TSESTree.Node): node is AST.TSESTreeMethodOrProperty;
|
|
262
|
-
|
|
263
|
-
/**
|
|
264
|
-
* Unsafe check whether given node is a render function
|
|
265
|
-
* ```tsx
|
|
266
|
-
* const renderRow = () => <div />
|
|
267
|
-
* ` ^^^^^^^^^^^^`
|
|
268
|
-
* _ = <Component renderRow={() => <div />} />
|
|
269
|
-
* ` ^^^^^^^^^^^^^ `
|
|
270
|
-
* ```
|
|
271
|
-
* @param context The rule context
|
|
272
|
-
* @param node The AST node to check
|
|
273
|
-
* @returns `true` if node is a render function, `false` if not
|
|
274
|
-
*/
|
|
275
|
-
declare function isRenderFunctionLoose(context: RuleContext, node: AST.TSESTreeFunction): boolean;
|
|
276
|
-
/**
|
|
277
|
-
* Unsafe check whether given JSXAttribute is a render prop
|
|
278
|
-
* ```tsx
|
|
279
|
-
* _ = <Component renderRow={() => <div />} />
|
|
280
|
-
* ` ^^^^^^^^^^^^^^^^^^^^^^^^^ `
|
|
281
|
-
* ```
|
|
282
|
-
* @param context The rule context
|
|
283
|
-
* @param node The AST node to check
|
|
284
|
-
* @returns `true` if node is a render prop, `false` if not
|
|
285
|
-
*/
|
|
286
|
-
declare function isRenderPropLoose(context: RuleContext, node: TSESTree.JSXAttribute): boolean;
|
|
287
|
-
/**
|
|
288
|
-
* Unsafe check whether given node is declared directly inside a render property
|
|
289
|
-
* ```tsx
|
|
290
|
-
* const rows = { render: () => <div /> }
|
|
291
|
-
* ` ^^^^^^^^^^^^^ `
|
|
292
|
-
* _ = <Component rows={ [{ render: () => <div /> }] } />
|
|
293
|
-
* ` ^^^^^^^^^^^^^ `
|
|
294
|
-
* ```
|
|
295
|
-
* @internal
|
|
296
|
-
* @param node The AST node to check
|
|
297
|
-
* @returns `true` if component is declared inside a render property, `false` if not
|
|
298
|
-
*/
|
|
299
|
-
declare function isDirectValueOfRenderPropertyLoose(node: TSESTree.Node): boolean;
|
|
300
|
-
/**
|
|
301
|
-
* Unsafe check whether given node is declared inside a render prop
|
|
302
|
-
* ```tsx
|
|
303
|
-
* _ = <Component renderRow={"node"} />
|
|
304
|
-
* ` ^^^^^^ `
|
|
305
|
-
* _ = <Component rows={ [{ render: "node" }] } />
|
|
306
|
-
* ` ^^^^^^ `
|
|
307
|
-
* ```
|
|
308
|
-
* @param node The AST node to check
|
|
309
|
-
* @returns `true` if component is declared inside a render prop, `false` if not
|
|
310
|
-
*/
|
|
311
|
-
declare function isDeclaredInRenderPropLoose(node: TSESTree.Node): boolean;
|
|
312
|
-
|
|
313
|
-
type ComponentStateKind = "actionState" | "state";
|
|
314
|
-
declare function isThisSetState(node: TSESTree.CallExpression): boolean;
|
|
315
|
-
declare function isAssignmentToThisState(node: TSESTree.AssignmentExpression): boolean;
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* Check if the node is a call expression for a component wrapper
|
|
319
|
-
* @param context The ESLint rule context
|
|
320
|
-
* @param node The node to check
|
|
321
|
-
* @returns `true` if the node is a call expression for a component wrapper
|
|
322
|
-
*/
|
|
323
|
-
declare function isComponentWrapperCall(context: RuleContext, node: TSESTree.Node): boolean;
|
|
324
|
-
/**
|
|
325
|
-
* Check if the node is a call expression for a component wrapper loosely
|
|
326
|
-
* @param context The ESLint rule context
|
|
327
|
-
* @param node The node to check
|
|
328
|
-
* @returns `true` if the node is a call expression for a component wrapper loosely
|
|
329
|
-
*/
|
|
330
|
-
declare function isComponentWrapperCallLoose(context: RuleContext, node: TSESTree.Node): boolean;
|
|
331
|
-
|
|
332
|
-
type EffectKind = "useEffect" | "useLayoutEffect" | "useInsertionEffect";
|
|
333
|
-
|
|
334
|
-
interface Hook extends SemanticNode {
|
|
335
|
-
id: TSESTree.Identifier | _;
|
|
336
|
-
node: AST.TSESTreeFunction;
|
|
337
|
-
name: string;
|
|
338
|
-
hookCalls: TSESTree.CallExpression[];
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
declare namespace useHookCollector {
|
|
342
|
-
type ReturnType = {
|
|
343
|
-
ctx: {
|
|
344
|
-
getAllHooks(node: TSESTree$1.Program): Map<string, Hook>;
|
|
345
|
-
};
|
|
346
|
-
listeners: ESLintUtils.RuleListener;
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
declare function useHookCollector(): useHookCollector.ReturnType;
|
|
350
|
-
|
|
351
|
-
declare function isReactHook(node: AST.TSESTreeFunction | _): boolean;
|
|
352
|
-
/**
|
|
353
|
-
* Check if the given node is a React Hook call by its name.
|
|
354
|
-
* @param node The node to check.
|
|
355
|
-
* @returns `true` if the node is a React Hook call, `false` otherwise.
|
|
356
|
-
*/
|
|
357
|
-
declare function isReactHookCall(node: TSESTree.Node | _): boolean;
|
|
358
|
-
declare function isReactHookCallWithName(context: RuleContext, node: TSESTree.Node | _): (name: string) => boolean;
|
|
359
|
-
declare function isReactHookCallWithNameLoose(node: TSESTree.Node | _): (name: string) => boolean;
|
|
360
|
-
declare function isReactHookCallWithNameAlias(context: RuleContext, name: string, alias?: _ | string[]): (node: TSESTree.CallExpression) => boolean;
|
|
361
|
-
declare function isUseEffectCallLoose(node: TSESTree.Node | _): boolean;
|
|
362
|
-
declare const isUseCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
363
|
-
declare const isUseActionStateCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
364
|
-
declare const isUseCallbackCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
365
|
-
declare const isUseContextCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
366
|
-
declare const isUseDebugValueCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
367
|
-
declare const isUseDeferredValueCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
368
|
-
declare const isUseEffectCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
369
|
-
declare const isUseFormStatusCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
370
|
-
declare const isUseIdCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
371
|
-
declare const isUseImperativeHandleCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
372
|
-
declare const isUseInsertionEffectCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
373
|
-
declare const isUseLayoutEffectCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
374
|
-
declare const isUseMemoCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
375
|
-
declare const isUseOptimisticCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
376
|
-
declare const isUseReducerCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
377
|
-
declare const isUseRefCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
378
|
-
declare const isUseStateCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
379
|
-
declare const isUseSyncExternalStoreCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
380
|
-
declare const isUseTransitionCall: (context: RuleContext, node: TSESTree.Node | undefined) => boolean;
|
|
381
|
-
|
|
382
|
-
type HookKind = "custom" | "useActionState" | "useCallback" | "useContext" | "useDebugValue" | "useDeferredValue" | "useEffect" | "useId" | "useImperativeHandle" | "useInsertionEffect" | "useLayoutEffect" | "useMemo" | "useOptimistic" | "useReducer" | "useRef" | "useState" | "useSyncExternalStore" | "useTransition";
|
|
383
|
-
|
|
384
|
-
/**
|
|
385
|
-
* Catch all identifiers that begin with "use" followed by an uppercase Latin
|
|
386
|
-
* character to exclude identifiers like "user".
|
|
387
|
-
* @param name The name of the identifier to check.
|
|
388
|
-
* @see https://github.com/facebook/react/blob/1d6c8168db1d82713202e842df3167787ffa00ed/packages/eslint-plugin-react-hooks/src/rules/RulesOfHooks.ts#L16
|
|
389
|
-
*/
|
|
390
|
-
declare function isReactHookName(name: string): boolean;
|
|
391
|
-
|
|
392
|
-
/**
|
|
393
|
-
* Get the JSX attribute node with the given name
|
|
394
|
-
* @param context The ESLint rule context
|
|
395
|
-
* @param name The name of the attribute
|
|
396
|
-
* @param attributes The attributes to search
|
|
397
|
-
* @param initialScope The initial scope to use for variable resolution
|
|
398
|
-
* @returns The JSX attribute node or undefined
|
|
399
|
-
*/
|
|
400
|
-
declare function getAttribute(context: RuleContext, name: string, attributes: (TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute)[], initialScope?: Scope): TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute | _;
|
|
401
|
-
|
|
402
|
-
/**
|
|
403
|
-
* Get the stringified name of a JSX attribute
|
|
404
|
-
* @param context The ESLint rule context
|
|
405
|
-
* @param node The JSX attribute node
|
|
406
|
-
* @returns The name of the attribute
|
|
407
|
-
*/
|
|
408
|
-
declare function getAttributeName(context: RuleContext, node: TSESTree$1.JSXAttribute): string;
|
|
409
|
-
|
|
410
|
-
/**
|
|
411
|
-
* Get a StaticValue of the attribute value
|
|
412
|
-
* @param context The rule context
|
|
413
|
-
* @param node The JSX attribute node
|
|
414
|
-
* @param name The name of the attribute
|
|
415
|
-
* @returns The StaticValue of the attribute value
|
|
416
|
-
*/
|
|
417
|
-
declare function getAttributeValue(context: RuleContext, node: TSESTree$1.JSXAttribute | TSESTree$1.JSXSpreadAttribute, name: string): Exclude<VAR.LazyValue, {
|
|
418
|
-
kind: "lazy";
|
|
419
|
-
}>;
|
|
420
|
-
|
|
421
|
-
type JSXDetectionHint = bigint;
|
|
422
|
-
declare const JSXDetectionHint: {
|
|
423
|
-
readonly None: 0n;
|
|
424
|
-
readonly SkipUndefined: bigint;
|
|
425
|
-
readonly SkipNullLiteral: bigint;
|
|
426
|
-
readonly SkipBooleanLiteral: bigint;
|
|
427
|
-
readonly SkipStringLiteral: bigint;
|
|
428
|
-
readonly SkipNumberLiteral: bigint;
|
|
429
|
-
readonly SkipBigIntLiteral: bigint;
|
|
430
|
-
readonly SkipEmptyArray: bigint;
|
|
431
|
-
readonly SkipCreateElement: bigint;
|
|
432
|
-
readonly StrictArray: bigint;
|
|
433
|
-
readonly StrictLogical: bigint;
|
|
434
|
-
readonly StrictConditional: bigint;
|
|
435
|
-
};
|
|
436
|
-
declare const DEFAULT_JSX_DETECTION_HINT: bigint;
|
|
437
|
-
|
|
438
|
-
/**
|
|
439
|
-
* Check if a node is a `JSXText` or a `Literal` node
|
|
440
|
-
* @param node The AST node to check
|
|
441
|
-
* @returns `true` if the node is a `JSXText` or a `Literal` node
|
|
442
|
-
*/
|
|
443
|
-
declare function isJsxText(node: TSESTree$1.Node | null | _): node is TSESTree$1.JSXText | TSESTree$1.Literal;
|
|
444
|
-
/**
|
|
445
|
-
* Heuristic decision to determine if a node is a JSX-like node.
|
|
446
|
-
* @param code The sourceCode object
|
|
447
|
-
* @param code.getScope The function to get the scope of a node
|
|
448
|
-
* @param node The AST node to check
|
|
449
|
-
* @param hint The `JSXDetectionHint` to use
|
|
450
|
-
* @returns boolean
|
|
451
|
-
*/
|
|
452
|
-
declare function isJsxLike(code: {
|
|
453
|
-
getScope: (node: TSESTree$1.Node) => Scope;
|
|
454
|
-
}, node: TSESTree$1.Node | _ | null, hint?: JSXDetectionHint): boolean;
|
|
455
|
-
|
|
456
|
-
/**
|
|
457
|
-
* Get the stringified type of a JSX element
|
|
458
|
-
* @param context The ESLint rule context
|
|
459
|
-
* @param node The JSX element node
|
|
460
|
-
* @returns The type of the element
|
|
461
|
-
*/
|
|
462
|
-
declare function getElementType(context: RuleContext, node: TSESTree.JSXElement | TSESTree.JSXFragment): string;
|
|
463
|
-
|
|
464
|
-
declare function hasAttribute(context: RuleContext, name: string, attributes: TSESTree.JSXOpeningElement["attributes"], initialScope?: Scope): boolean;
|
|
465
|
-
declare function hasAnyAttribute(context: RuleContext, names: string[], attributes: TSESTree.JSXOpeningElement["attributes"], initialScope?: Scope): boolean;
|
|
466
|
-
declare function hasEveryAttribute(context: RuleContext, names: string[], attributes: TSESTree.JSXOpeningElement["attributes"], initialScope?: Scope): boolean;
|
|
467
|
-
|
|
468
|
-
/**
|
|
469
|
-
* Find the parent JSX attribute node of a node
|
|
470
|
-
* @param node The node to find the parent attribute of
|
|
471
|
-
* @param test The test to apply to the parent attribute
|
|
472
|
-
* @returns The parent attribute node or undefined
|
|
473
|
-
*/
|
|
474
|
-
declare function findParentAttribute(node: TSESTree.Node, test?: (node: TSESTree.JSXAttribute) => boolean): TSESTree.JSXAttribute | _;
|
|
475
|
-
|
|
476
|
-
declare function isHostElement(context: RuleContext, node: TSESTree.Node): boolean;
|
|
477
|
-
declare function isKeyedElement(context: RuleContext, node: TSESTree.Node, initialScope?: Scope): boolean;
|
|
478
|
-
declare function isFragmentElement(context: RuleContext, node: TSESTree.Node | null | _, allowJSXFragment?: false): node is TSESTree.JSXElement;
|
|
479
|
-
declare function isFragmentElement(context: RuleContext, node: TSESTree.Node | null | _, allowJSXFragment?: true): node is TSESTree.JSXElement | TSESTree.JSXFragment;
|
|
480
|
-
|
|
481
|
-
/**
|
|
482
|
-
* Get the stringified representation of a JSX node
|
|
483
|
-
* @param node The JSX node
|
|
484
|
-
* @returns The stringified representation
|
|
485
|
-
*/
|
|
486
|
-
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;
|
|
487
|
-
|
|
488
|
-
/** @internal */
|
|
489
|
-
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;
|
|
490
|
-
|
|
491
|
-
/**
|
|
492
|
-
* Check if an identifier is initialized from react
|
|
493
|
-
* @param name The top-level identifier's name
|
|
494
|
-
* @param importSource The import source to check against
|
|
495
|
-
* @param initialScope Initial scope to search for the identifier
|
|
496
|
-
* @returns Whether the identifier is initialized from react
|
|
497
|
-
*/
|
|
498
|
-
declare function isInitializedFromReact(name: string, importSource: string, initialScope: Scope): boolean;
|
|
499
|
-
|
|
500
|
-
/** @internal */
|
|
501
|
-
declare function isInstanceIdEqual(context: RuleContext, a: TSESTree.Node, b: TSESTree.Node): boolean;
|
|
502
|
-
|
|
503
|
-
declare namespace isReactAPI {
|
|
504
|
-
type ReturnType = {
|
|
505
|
-
(context: RuleContext, node: _ | null | TSESTree.Node): node is TSESTree.Identifier | TSESTree.MemberExpression;
|
|
506
|
-
(context: RuleContext): (node: _ | null | TSESTree.Node) => node is TSESTree.MemberExpression | TSESTree.Identifier;
|
|
507
|
-
};
|
|
508
|
-
}
|
|
509
|
-
declare function isReactAPI(api: string): isReactAPI.ReturnType;
|
|
510
|
-
declare namespace isReactAPICall {
|
|
511
|
-
type ReturnType = {
|
|
512
|
-
(context: RuleContext, node: _ | null | TSESTree.Node): node is TSESTree.CallExpression;
|
|
513
|
-
(context: RuleContext): (node: _ | null | TSESTree.Node) => node is TSESTree.CallExpression;
|
|
514
|
-
};
|
|
515
|
-
}
|
|
516
|
-
declare function isReactAPICall(api: string): isReactAPICall.ReturnType;
|
|
517
|
-
declare const isCaptureOwnerStack: isReactAPI.ReturnType;
|
|
518
|
-
declare const isChildrenCount: isReactAPI.ReturnType;
|
|
519
|
-
declare const isChildrenForEach: isReactAPI.ReturnType;
|
|
520
|
-
declare const isChildrenMap: isReactAPI.ReturnType;
|
|
521
|
-
declare const isChildrenOnly: isReactAPI.ReturnType;
|
|
522
|
-
declare const isChildrenToArray: isReactAPI.ReturnType;
|
|
523
|
-
declare const isCloneElement: isReactAPI.ReturnType;
|
|
524
|
-
declare const isCreateContext: isReactAPI.ReturnType;
|
|
525
|
-
declare const isCreateElement: isReactAPI.ReturnType;
|
|
526
|
-
declare const isCreateRef: isReactAPI.ReturnType;
|
|
527
|
-
declare const isForwardRef: isReactAPI.ReturnType;
|
|
528
|
-
declare const isMemo: isReactAPI.ReturnType;
|
|
529
|
-
declare const isLazy: isReactAPI.ReturnType;
|
|
530
|
-
declare const isCaptureOwnerStackCall: isReactAPICall.ReturnType;
|
|
531
|
-
declare const isChildrenCountCall: isReactAPICall.ReturnType;
|
|
532
|
-
declare const isChildrenForEachCall: isReactAPICall.ReturnType;
|
|
533
|
-
declare const isChildrenMapCall: isReactAPICall.ReturnType;
|
|
534
|
-
declare const isChildrenOnlyCall: isReactAPICall.ReturnType;
|
|
535
|
-
declare const isChildrenToArrayCall: isReactAPICall.ReturnType;
|
|
536
|
-
declare const isCloneElementCall: isReactAPICall.ReturnType;
|
|
537
|
-
declare const isCreateContextCall: isReactAPICall.ReturnType;
|
|
538
|
-
declare const isCreateElementCall: isReactAPICall.ReturnType;
|
|
539
|
-
declare const isCreateRefCall: isReactAPICall.ReturnType;
|
|
540
|
-
declare const isForwardRefCall: isReactAPICall.ReturnType;
|
|
541
|
-
declare const isMemoCall: isReactAPICall.ReturnType;
|
|
542
|
-
declare const isLazyCall: isReactAPICall.ReturnType;
|
|
543
|
-
|
|
544
|
-
export { type ClassComponent, type Component, ComponentDetectionHint, type ComponentEffectPhaseKind, ComponentFlag, type ComponentKind, type ComponentLifecyclePhaseKind, type ComponentPhaseKind, ComponentPhaseRelevance, type ComponentStateKind, DEFAULT_COMPONENT_DETECTION_HINT, DEFAULT_JSX_DETECTION_HINT, type EffectKind, type FunctionComponent, type Hook, type HookKind, JSXDetectionHint, type SemanticEntry, type 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, isFunctionOfRender, isFunctionOfRenderMethod, isGetChildContext, isGetDefaultProps, isGetDerivedStateFromError, isGetDerivedStateFromProps, isGetInitialState, isGetSnapshotBeforeUpdate, isHostElement, isInitializedFromReact, 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 };
|