@eslint-react/core 5.16.0 → 5.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +130 -131
- package/dist/index.js +425 -130
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -13,9 +13,9 @@ declare namespace isAPI {
|
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
-
* Check if the node is a React API identifier or member expression
|
|
17
|
-
* @param api The React API name to check against (ex: "useState", "React.memo")
|
|
18
|
-
* @returns A predicate function to check if a node matches the API
|
|
16
|
+
* Check if the node is a React API identifier or member expression.
|
|
17
|
+
* @param api The React API name to check against (ex: "useState", "React.memo").
|
|
18
|
+
* @returns A predicate function to check if a node matches the API.
|
|
19
19
|
*/
|
|
20
20
|
declare function isAPI(api: string): isAPI.ReturnType;
|
|
21
21
|
declare namespace isAPICall {
|
|
@@ -25,9 +25,9 @@ declare namespace isAPICall {
|
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
|
-
* Check if the node is a call expression to a specific React API
|
|
29
|
-
* @param api The React API name to check against
|
|
30
|
-
* @returns A predicate function to check if a node is a call to the API
|
|
28
|
+
* Check if the node is a call expression to a specific React API.
|
|
29
|
+
* @param api The React API name to check against.
|
|
30
|
+
* @returns A predicate function to check if a node is a call to the API.
|
|
31
31
|
*/
|
|
32
32
|
declare function isAPICall(api: string): isAPICall.ReturnType;
|
|
33
33
|
declare const isCaptureOwnerStack: isAPI.ReturnType;
|
|
@@ -97,53 +97,53 @@ declare const isUseTransitionCall: isAPICall.ReturnType;
|
|
|
97
97
|
//#endregion
|
|
98
98
|
//#region src/class.d.ts
|
|
99
99
|
/**
|
|
100
|
-
* Get the class identifier of a class node
|
|
101
|
-
* @param node The class node to get the identifier from
|
|
102
|
-
* @returns The class identifier or null if not found
|
|
100
|
+
* Get the class identifier of a class node.
|
|
101
|
+
* @param node The class node to get the identifier from.
|
|
102
|
+
* @returns The class identifier or null if not found.
|
|
103
103
|
*/
|
|
104
104
|
declare function getClassId(node: TSESTreeClass): TSESTree.BindingName | null;
|
|
105
105
|
//#endregion
|
|
106
106
|
//#region src/semantic.d.ts
|
|
107
107
|
/**
|
|
108
|
-
* Represents a semantic node in the AST
|
|
109
|
-
* This is the base interface for all semantic nodes in the React semantic analysis
|
|
108
|
+
* Represents a semantic node in the AST.
|
|
109
|
+
* This is the base interface for all semantic nodes in the React semantic analysis.
|
|
110
110
|
*/
|
|
111
111
|
interface SemanticNode {
|
|
112
|
-
/** The identifier of the node */
|
|
112
|
+
/** The identifier of the node. */
|
|
113
113
|
id: null | TSESTree.Node;
|
|
114
|
-
/** The unique key of the node */
|
|
114
|
+
/** The unique key of the node. */
|
|
115
115
|
key: string;
|
|
116
|
-
/** The kind of the node */
|
|
116
|
+
/** The kind of the node. */
|
|
117
117
|
kind: string;
|
|
118
|
-
/** The name of the node */
|
|
118
|
+
/** The name of the node. */
|
|
119
119
|
name: null | string;
|
|
120
|
-
/** The flag of the node */
|
|
120
|
+
/** The flag of the node. */
|
|
121
121
|
flag: bigint;
|
|
122
|
-
/** The hint of the node */
|
|
122
|
+
/** The hint of the node. */
|
|
123
123
|
hint: bigint;
|
|
124
|
-
/** The AST node */
|
|
124
|
+
/** The AST node. */
|
|
125
125
|
node: TSESTree.Node;
|
|
126
126
|
}
|
|
127
127
|
/**
|
|
128
|
-
* Represents a semantic function node in the AST
|
|
129
|
-
* This interface extends SemanticNode and provides additional properties for function analysis
|
|
128
|
+
* Represents a semantic function node in the AST.
|
|
129
|
+
* This interface extends SemanticNode and provides additional properties for function analysis.
|
|
130
130
|
*/
|
|
131
131
|
interface SemanticFunc extends SemanticNode {
|
|
132
|
-
/** The identifier of the function */
|
|
132
|
+
/** The identifier of the function. */
|
|
133
133
|
id: null | TSESTree.Node;
|
|
134
|
-
/** The AST node of the function */
|
|
134
|
+
/** The AST node of the function. */
|
|
135
135
|
node: TSESTreeFunction;
|
|
136
|
-
/** The name of the function */
|
|
136
|
+
/** The name of the function. */
|
|
137
137
|
name: string | null;
|
|
138
|
-
/** The return type annotation of the function */
|
|
138
|
+
/** The return type annotation of the function. */
|
|
139
139
|
type: TSESTree.TSTypeAnnotation | null;
|
|
140
|
-
/** The body of the function */
|
|
140
|
+
/** The body of the function. */
|
|
141
141
|
body: TSESTree.BlockStatement | TSESTree.Expression;
|
|
142
|
-
/** The directives of the function (ex: "use strict", "use client", "use server", etc.) */
|
|
142
|
+
/** The directives of the function (ex: "use strict", "use client", "use server", etc.). */
|
|
143
143
|
directives: TSESTreeDirective[];
|
|
144
|
-
/** The parameters of the function */
|
|
144
|
+
/** The parameters of the function. */
|
|
145
145
|
parameters: TSESTree.Parameter[];
|
|
146
|
-
/** The type parameters of the function */
|
|
146
|
+
/** The type parameters of the function. */
|
|
147
147
|
typeParameters: TSESTree.TSTypeParameterDeclaration | null;
|
|
148
148
|
}
|
|
149
149
|
//#endregion
|
|
@@ -284,29 +284,29 @@ type FunctionSemanticNode = ClientFunctionSemanticNode | ServerFunctionSemanticN
|
|
|
284
284
|
*
|
|
285
285
|
* Ported from {@link https://github.com/facebook/react/blob/bb8a76c6cc77ea2976d690ea09f5a1b3d9b1792a/packages/eslint-plugin-react-hooks/src/rules/RulesOfHooks.ts#L860 | RulesOfHooks.ts}
|
|
286
286
|
*
|
|
287
|
-
* @param node
|
|
287
|
+
* @param node The function node to analyze.
|
|
288
288
|
* @returns The identifier node if found, `null` otherwise.
|
|
289
289
|
*/
|
|
290
290
|
declare function getFunctionId(node: TSESTree.Expression | TSESTreeFunction): TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpressionWithBlockBody | TSESTree.ArrowFunctionExpressionWithExpressionBody | TSESTree.AssignmentExpression | TSESTree.AwaitExpression | TSESTree.PrivateInExpression | TSESTree.SymmetricBinaryExpression | TSESTree.CallExpression | TSESTree.ChainExpression | TSESTree.ClassExpression | TSESTree.ConditionalExpression | TSESTree.FunctionExpression | TSESTree.Identifier | TSESTree.ImportExpression | TSESTree.JSXElement | TSESTree.JSXFragment | TSESTree.BigIntLiteral | TSESTree.BooleanLiteral | TSESTree.NullLiteral | TSESTree.NumberLiteral | TSESTree.RegExpLiteral | TSESTree.StringLiteral | TSESTree.TemplateLiteral | TSESTree.LogicalExpression | TSESTree.MemberExpressionComputedName | TSESTree.MemberExpressionNonComputedName | TSESTree.MetaProperty | TSESTree.NewExpression | TSESTree.ObjectExpression | TSESTree.ObjectPattern | TSESTree.SequenceExpression | TSESTree.Super | TSESTree.TaggedTemplateExpression | TSESTree.ThisExpression | TSESTree.TSAsExpression | TSESTree.TSInstantiationExpression | TSESTree.TSNonNullExpression | TSESTree.TSSatisfiesExpression | TSESTree.TSTypeAssertion | TSESTree.UnaryExpressionBitwiseNot | TSESTree.UnaryExpressionDelete | TSESTree.UnaryExpressionMinus | TSESTree.UnaryExpressionNot | TSESTree.UnaryExpressionPlus | TSESTree.UnaryExpressionTypeof | TSESTree.UnaryExpressionVoid | TSESTree.UpdateExpression | TSESTree.YieldNoStarExpression | TSESTree.YieldStarExpression | TSESTree.PrivateIdentifier | null;
|
|
291
291
|
/**
|
|
292
292
|
* Identifies the initialization path of a function node in the AST.
|
|
293
293
|
*
|
|
294
|
-
* @param node
|
|
294
|
+
* @param node The function node to analyze.
|
|
295
295
|
* @returns The function initialization path or `null` if not identifiable.
|
|
296
296
|
*/
|
|
297
297
|
declare function getFunctionInitPath(node: TSESTreeFunction): null | FunctionInitPath;
|
|
298
298
|
/**
|
|
299
299
|
* Checks if a specific function call exists in the function initialization path.
|
|
300
300
|
*
|
|
301
|
-
* @param callName
|
|
302
|
-
* @param initPath
|
|
301
|
+
* @param callName The name of the call to check for (e.g., "memo", "forwardRef").
|
|
302
|
+
* @param initPath The function initialization path to search in.
|
|
303
303
|
* @returns `true` if the call exists in the path, `false` otherwise.
|
|
304
304
|
*/
|
|
305
305
|
declare function isFunctionHasCallInInitPath(callName: string, initPath: FunctionInitPath): boolean;
|
|
306
306
|
/**
|
|
307
307
|
* Checks if a function is empty.
|
|
308
308
|
*
|
|
309
|
-
* @param node
|
|
309
|
+
* @param node The function node to check.
|
|
310
310
|
* @returns `true` if the function is empty, `false` otherwise.
|
|
311
311
|
*/
|
|
312
312
|
declare function isFunctionEmpty(node: TSESTreeFunction): boolean;
|
|
@@ -314,8 +314,8 @@ declare function getFunctionDirectives(node: TSESTreeFunction): TSESTreeDirectiv
|
|
|
314
314
|
/**
|
|
315
315
|
* Checks if a directive with the given name exists in the function directives.
|
|
316
316
|
*
|
|
317
|
-
* @param node
|
|
318
|
-
* @param name
|
|
317
|
+
* @param node The function AST node.
|
|
318
|
+
* @param name The directive name to check (e.g., "use memo", "use no memo").
|
|
319
319
|
* @returns `true` if the directive exists, `false` otherwise.
|
|
320
320
|
*/
|
|
321
321
|
declare function isFunctionHasDirective(node: TSESTreeFunction, name: string): boolean;
|
|
@@ -332,20 +332,20 @@ declare const SEL_FUNCTION_DISPLAY_NAME_ASSIGNMENT: string;
|
|
|
332
332
|
//#endregion
|
|
333
333
|
//#region src/hook.d.ts
|
|
334
334
|
/**
|
|
335
|
-
* Represents a semantic hook node in the AST
|
|
335
|
+
* Represents a semantic hook node in the AST.
|
|
336
336
|
*/
|
|
337
337
|
interface HookSemanticNode extends SemanticNode {
|
|
338
|
-
/** The identifier of the hook */
|
|
338
|
+
/** The identifier of the hook. */
|
|
339
339
|
id: FunctionID;
|
|
340
|
-
/** The AST node of the hook */
|
|
340
|
+
/** The AST node of the hook. */
|
|
341
341
|
node: TSESTreeFunction;
|
|
342
|
-
/** The kind of hook */
|
|
342
|
+
/** The kind of hook. */
|
|
343
343
|
kind: "hook";
|
|
344
|
-
/** List of expressions returned by the hook */
|
|
344
|
+
/** List of expressions returned by the hook. */
|
|
345
345
|
rets: TSESTree.ReturnStatement["argument"][];
|
|
346
|
-
/** The other hooks called by the hook */
|
|
346
|
+
/** The other hooks called by the hook. */
|
|
347
347
|
hookCalls: HookCall[];
|
|
348
|
-
/** The directives used in the function (ex: "use strict", "use client", etc.) */
|
|
348
|
+
/** The directives used in the function (ex: "use strict", "use client", etc.). */
|
|
349
349
|
directives: TSESTreeDirective[];
|
|
350
350
|
}
|
|
351
351
|
type HookCall = TSESTree.CallExpression | TSESTree.TaggedTemplateExpression;
|
|
@@ -358,21 +358,21 @@ declare const REACT_BUILTIN_HOOK_NAMES: readonly ["use", "useActionState", "useC
|
|
|
358
358
|
*/
|
|
359
359
|
declare function isHookName(name: string): boolean;
|
|
360
360
|
/**
|
|
361
|
-
* Checks if the given node is a hook identifier
|
|
362
|
-
* @param id The AST node to check
|
|
363
|
-
* @returns `true` if the node is a hook identifier or member expression with hook name, `false` otherwise
|
|
361
|
+
* Checks if the given node is a hook identifier.
|
|
362
|
+
* @param id The AST node to check.
|
|
363
|
+
* @returns `true` if the node is a hook identifier or member expression with hook name, `false` otherwise.
|
|
364
364
|
*/
|
|
365
365
|
declare function isHookId(id: TSESTree.Node): id is TSESTree.Identifier | TSESTree.MemberExpression;
|
|
366
366
|
/**
|
|
367
367
|
* Checks if the given expression is a hook tag (callee / tagged template tag).
|
|
368
|
-
* @param tag The expression node to check
|
|
369
|
-
* @returns `true` if the expression is a hook identifier or member expression with hook name, `false` otherwise
|
|
368
|
+
* @param tag The expression node to check.
|
|
369
|
+
* @returns `true` if the expression is a hook identifier or member expression with hook name, `false` otherwise.
|
|
370
370
|
*/
|
|
371
371
|
declare function isHookTag(tag: TSESTree.Node | null): boolean;
|
|
372
372
|
/**
|
|
373
373
|
* Determine if a function node is a React Hook based on its name.
|
|
374
|
-
* @param node The function node to check
|
|
375
|
-
* @returns True if the function is a React Hook, false otherwise
|
|
374
|
+
* @param node The function node to check.
|
|
375
|
+
* @returns True if the function is a React Hook, false otherwise.
|
|
376
376
|
*/
|
|
377
377
|
declare function isHookDefinition(node: TSESTreeFunction | null): boolean;
|
|
378
378
|
/**
|
|
@@ -382,148 +382,148 @@ declare function isHookDefinition(node: TSESTreeFunction | null): boolean;
|
|
|
382
382
|
*/
|
|
383
383
|
declare function isHookCall(node: TSESTree.Node | null): node is TSESTree.CallExpression;
|
|
384
384
|
/**
|
|
385
|
-
* Detect useEffect calls and variations (useLayoutEffect, etc.) using a regex pattern
|
|
386
|
-
* @param node The AST node to check
|
|
387
|
-
* @param additionalEffectHooks Regex pattern matching custom hooks that should be treated as effect hooks
|
|
388
|
-
* @returns True if the node is a useEffect-like call
|
|
385
|
+
* Detect useEffect calls and variations (useLayoutEffect, etc.) using a regex pattern.
|
|
386
|
+
* @param node The AST node to check.
|
|
387
|
+
* @param additionalEffectHooks Regex pattern matching custom hooks that should be treated as effect hooks.
|
|
388
|
+
* @returns True if the node is a useEffect-like call.
|
|
389
389
|
*/
|
|
390
390
|
declare function isUseEffectLikeCall(node: TSESTree.Node | null, additionalEffectHooks?: RegExpLike): node is TSESTree.CallExpression;
|
|
391
391
|
/**
|
|
392
|
-
* Detect useState calls and variations using a regex pattern
|
|
393
|
-
* @param node The AST node to check
|
|
394
|
-
* @param additionalStateHooks Regex pattern matching custom hooks that should be treated as state hooks
|
|
395
|
-
* @returns True if the node is a useState-like call
|
|
392
|
+
* Detect useState calls and variations using a regex pattern.
|
|
393
|
+
* @param node The AST node to check.
|
|
394
|
+
* @param additionalStateHooks Regex pattern matching custom hooks that should be treated as state hooks.
|
|
395
|
+
* @returns True if the node is a useState-like call.
|
|
396
396
|
*/
|
|
397
397
|
declare function isUseStateLikeCall(node: TSESTree.Node | null, additionalStateHooks?: RegExpLike): node is TSESTree.CallExpression;
|
|
398
398
|
/**
|
|
399
|
-
* Determine if a node is the setup function passed to a useEffect-like hook
|
|
400
|
-
* @param node The AST node to check
|
|
399
|
+
* Determine if a node is the setup function passed to a useEffect-like hook.
|
|
400
|
+
* @param node The AST node to check.
|
|
401
401
|
*/
|
|
402
402
|
declare function isUseEffectSetupCallback(node: TSESTree.Node | null): boolean;
|
|
403
403
|
/**
|
|
404
|
-
* Determine if a node is the cleanup function returned by a useEffect-like hook's setup function
|
|
405
|
-
* @param node The AST node to check
|
|
404
|
+
* Determine if a node is the cleanup function returned by a useEffect-like hook's setup function.
|
|
405
|
+
* @param node The AST node to check.
|
|
406
406
|
*/
|
|
407
407
|
declare function isUseEffectCleanupCallback(node: TSESTree.Node | null): boolean;
|
|
408
408
|
//#endregion
|
|
409
409
|
//#region src/function-component.d.ts
|
|
410
410
|
/**
|
|
411
|
-
* Represents a React Function Component
|
|
411
|
+
* Represents a React Function Component.
|
|
412
412
|
*/
|
|
413
413
|
interface FunctionComponentSemanticNode extends SemanticNode {
|
|
414
414
|
/**
|
|
415
|
-
* The identifier or identifier sequence of the component
|
|
415
|
+
* The identifier or identifier sequence of the component.
|
|
416
416
|
*/
|
|
417
417
|
id: FunctionID;
|
|
418
418
|
/**
|
|
419
|
-
* The kind of component
|
|
419
|
+
* The kind of component.
|
|
420
420
|
*/
|
|
421
421
|
kind: "component";
|
|
422
422
|
/**
|
|
423
|
-
* The AST node of the function
|
|
423
|
+
* The AST node of the function.
|
|
424
424
|
*/
|
|
425
425
|
node: TSESTreeFunction;
|
|
426
426
|
/**
|
|
427
|
-
* Flags describing the component's characteristics
|
|
427
|
+
* Flags describing the component's characteristics.
|
|
428
428
|
*/
|
|
429
429
|
flag: bigint;
|
|
430
430
|
/**
|
|
431
|
-
* Hint for how the component was detected
|
|
431
|
+
* Hint for how the component was detected.
|
|
432
432
|
*/
|
|
433
433
|
hint: bigint;
|
|
434
434
|
/**
|
|
435
|
-
* List of expressions returned by the component
|
|
435
|
+
* List of expressions returned by the component.
|
|
436
436
|
*/
|
|
437
437
|
rets: TSESTree.ReturnStatement["argument"][];
|
|
438
438
|
/**
|
|
439
|
-
* The initialization path of the function
|
|
439
|
+
* The initialization path of the function.
|
|
440
440
|
*/
|
|
441
441
|
initPath: null | FunctionInitPath;
|
|
442
442
|
/**
|
|
443
|
-
* Indicates if the component is inside an export default declaration
|
|
443
|
+
* Indicates if the component is inside an export default declaration.
|
|
444
444
|
*/
|
|
445
445
|
isExportDefault: boolean;
|
|
446
446
|
/**
|
|
447
|
-
* Indicates if the component is itself an export default declaration
|
|
447
|
+
* Indicates if the component is itself an export default declaration.
|
|
448
448
|
*/
|
|
449
449
|
isExportDefaultDeclaration: boolean;
|
|
450
450
|
/**
|
|
451
|
-
* List of hook calls within the component
|
|
451
|
+
* List of hook calls within the component.
|
|
452
452
|
*/
|
|
453
453
|
hookCalls: HookCall[];
|
|
454
454
|
/**
|
|
455
|
-
* The display name of the component
|
|
455
|
+
* The display name of the component.
|
|
456
456
|
*/
|
|
457
457
|
displayName: null | TSESTree.Expression;
|
|
458
458
|
/**
|
|
459
|
-
* The directives used in the function (ex: "use strict", "use client", etc.)
|
|
459
|
+
* The directives used in the function (ex: "use strict", "use client", etc.).
|
|
460
460
|
*/
|
|
461
461
|
directives: TSESTreeDirective[];
|
|
462
462
|
}
|
|
463
463
|
/**
|
|
464
|
-
* Component flag constants
|
|
464
|
+
* Component flag constants.
|
|
465
465
|
*/
|
|
466
466
|
declare const FunctionComponentFlag: {
|
|
467
|
-
/** No flags set */
|
|
467
|
+
/** No flags set. */
|
|
468
468
|
None: bigint;
|
|
469
|
-
/** Indicates the component is a pure component (ex: extends PureComponent) */
|
|
469
|
+
/** Indicates the component is a pure component (ex: extends PureComponent). */
|
|
470
470
|
PureComponent: bigint;
|
|
471
|
-
/** Indicates the component creates elements using `createElement` instead of JSX */
|
|
471
|
+
/** Indicates the component creates elements using `createElement` instead of JSX. */
|
|
472
472
|
CreateElement: bigint;
|
|
473
|
-
/** Indicates the component is memoized (ex: React.memo) */
|
|
473
|
+
/** Indicates the component is memoized (ex: React.memo). */
|
|
474
474
|
Memo: bigint;
|
|
475
|
-
/** Indicates the component forwards a ref (ex: React.forwardRef) */
|
|
475
|
+
/** Indicates the component forwards a ref (ex: React.forwardRef). */
|
|
476
476
|
ForwardRef: bigint;
|
|
477
477
|
};
|
|
478
478
|
/**
|
|
479
|
-
* Get component flag from init path
|
|
480
|
-
* @param initPath The init path of the function component
|
|
481
|
-
* @returns The component flag
|
|
479
|
+
* Get component flag from init path.
|
|
480
|
+
* @param initPath The init path of the function component.
|
|
481
|
+
* @returns The component flag.
|
|
482
482
|
* @internal
|
|
483
483
|
*/
|
|
484
484
|
declare function getFunctionComponentFlagFromInitPath(initPath: FunctionComponentSemanticNode["initPath"]): bigint;
|
|
485
485
|
/**
|
|
486
|
-
* Check if the node is a call expression for a component wrapper
|
|
487
|
-
* @param context The ESLint rule context
|
|
488
|
-
* @param node The node to check
|
|
489
|
-
* @returns `true` if the node is a call expression for a component wrapper
|
|
486
|
+
* Check if the node is a call expression for a component wrapper.
|
|
487
|
+
* @param context The ESLint rule context.
|
|
488
|
+
* @param node The node to check.
|
|
489
|
+
* @returns `true` if the node is a call expression for a component wrapper.
|
|
490
490
|
*/
|
|
491
491
|
declare function isFunctionComponentWrapperCall(context: RuleContext, node: TSESTree.Node): boolean;
|
|
492
492
|
/**
|
|
493
|
-
* Check if the node is a callback function passed to a component wrapper
|
|
494
|
-
* @param context The ESLint rule context
|
|
495
|
-
* @param node The node to check
|
|
496
|
-
* @returns `true` if the node is a callback function passed to a component wrapper
|
|
493
|
+
* Check if the node is a callback function passed to a component wrapper.
|
|
494
|
+
* @param context The ESLint rule context.
|
|
495
|
+
* @param node The node to check.
|
|
496
|
+
* @returns `true` if the node is a callback function passed to a component wrapper.
|
|
497
497
|
*/
|
|
498
498
|
declare function isFunctionComponentWrapperCallback(context: RuleContext, node: TSESTree.Node): boolean;
|
|
499
499
|
/**
|
|
500
|
-
* Get function component identifier from `const Component = memo(() => {})
|
|
501
|
-
* @param context The rule context
|
|
502
|
-
* @param node The AST node to get the function component identifier from
|
|
500
|
+
* Get function component identifier from `const Component = memo(() => {});`.
|
|
501
|
+
* @param context The rule context.
|
|
502
|
+
* @param node The AST node to get the function component identifier from.
|
|
503
503
|
* @internal
|
|
504
504
|
*/
|
|
505
505
|
declare function getFunctionComponentId(context: RuleContext, node: TSESTreeFunction): FunctionID;
|
|
506
506
|
/**
|
|
507
|
-
* Check if a string matches the strict component name pattern
|
|
508
|
-
* @param name The name to check
|
|
507
|
+
* Check if a string matches the strict component name pattern.
|
|
508
|
+
* @param name The name to check.
|
|
509
509
|
*/
|
|
510
510
|
declare function isFunctionComponentName(name: string): boolean;
|
|
511
511
|
/**
|
|
512
|
-
* Check if a string matches the loose component name pattern
|
|
513
|
-
* @param name The name to check
|
|
512
|
+
* Check if a string matches the loose component name pattern.
|
|
513
|
+
* @param name The name to check.
|
|
514
514
|
*/
|
|
515
515
|
declare function isFunctionComponentNameLoose(name: string): boolean;
|
|
516
516
|
/**
|
|
517
|
-
* Check if a function has a loose component name
|
|
518
|
-
* @param context The rule context
|
|
519
|
-
* @param fn The function to check
|
|
520
|
-
* @param allowNone Whether to allow no name
|
|
521
|
-
* @returns Whether the function has a loose component name
|
|
517
|
+
* Check if a function has a loose component name.
|
|
518
|
+
* @param context The rule context.
|
|
519
|
+
* @param fn The function to check.
|
|
520
|
+
* @param allowNone Whether to allow no name.
|
|
521
|
+
* @returns Whether the function has a loose component name.
|
|
522
522
|
*/
|
|
523
523
|
declare function isFunctionWithLooseComponentName(context: RuleContext, fn: TSESTreeFunction, allowNone?: boolean): boolean;
|
|
524
524
|
type FunctionComponentDetectionHint = bigint;
|
|
525
525
|
/**
|
|
526
|
-
* Hints for component collector
|
|
526
|
+
* Hints for component collector.
|
|
527
527
|
*/
|
|
528
528
|
declare const FunctionComponentDetectionHint: {
|
|
529
529
|
readonly DoNotIncludeFunctionDefinedAsClassMethod: bigint;
|
|
@@ -548,16 +548,16 @@ declare const FunctionComponentDetectionHint: {
|
|
|
548
548
|
readonly RequireBothBranchesOfConditionalExpressionToBeJsx: bigint;
|
|
549
549
|
};
|
|
550
550
|
/**
|
|
551
|
-
* Default component detection hint
|
|
551
|
+
* Default component detection hint.
|
|
552
552
|
*/
|
|
553
553
|
declare const DEFAULT_COMPONENT_DETECTION_HINT: bigint;
|
|
554
554
|
/**
|
|
555
|
-
* Determine if a function node represents a valid React component definition
|
|
555
|
+
* Determine if a function node represents a valid React component definition.
|
|
556
556
|
*
|
|
557
|
-
* @param context The rule context
|
|
558
|
-
* @param node The function node to analyze
|
|
559
|
-
* @param hint Component detection hints (bit flags) to customize detection logic
|
|
560
|
-
* @returns `true` if the node is considered a component definition
|
|
557
|
+
* @param context The rule context.
|
|
558
|
+
* @param node The function node to analyze.
|
|
559
|
+
* @param hint Component detection hints (bit flags) to customize detection logic.
|
|
560
|
+
* @returns `true` if the node is considered a component definition.
|
|
561
561
|
*/
|
|
562
562
|
declare function isFunctionComponentDefinition(context: RuleContext, node: TSESTreeFunction, hint: bigint): boolean;
|
|
563
563
|
//#endregion
|
|
@@ -575,10 +575,10 @@ declare namespace getFunctionComponentCollector {
|
|
|
575
575
|
};
|
|
576
576
|
}
|
|
577
577
|
/**
|
|
578
|
-
* Get an api and visitor object for the rule to collect function components
|
|
579
|
-
* @param context The ESLint rule context
|
|
580
|
-
* @param options The options to use
|
|
581
|
-
* @returns The api and visitor of the collector
|
|
578
|
+
* Get an api and visitor object for the rule to collect function components.
|
|
579
|
+
* @param context The ESLint rule context.
|
|
580
|
+
* @param options The options to use.
|
|
581
|
+
* @returns The api and visitor of the collector.
|
|
582
582
|
*/
|
|
583
583
|
declare function getFunctionComponentCollector(context: RuleContext, options?: getFunctionComponentCollector.Options): getFunctionComponentCollector.ReturnType;
|
|
584
584
|
//#endregion
|
|
@@ -592,9 +592,9 @@ declare namespace getHookCollector {
|
|
|
592
592
|
};
|
|
593
593
|
}
|
|
594
594
|
/**
|
|
595
|
-
* Get an api and visitor object for the rule to collect hooks
|
|
596
|
-
* @param context The ESLint rule context
|
|
597
|
-
* @returns The api and visitor of the collector
|
|
595
|
+
* Get an api and visitor object for the rule to collect hooks.
|
|
596
|
+
* @param context The ESLint rule context.
|
|
597
|
+
* @returns The api and visitor of the collector.
|
|
598
598
|
*/
|
|
599
599
|
declare function getHookCollector(context: RuleContext): getHookCollector.ReturnType;
|
|
600
600
|
//#endregion
|
|
@@ -609,10 +609,9 @@ declare function getHookCollector(context: RuleContext): getHookCollector.Return
|
|
|
609
609
|
* circular definitions (e.g. `var a = b; var b = a;`) are detected and
|
|
610
610
|
* treated as not JSX-like instead of recursing indefinitely.
|
|
611
611
|
*
|
|
612
|
-
* @param context
|
|
613
|
-
* @param node
|
|
614
|
-
* @param hint
|
|
615
|
-
* Defaults to {@link DEFAULT_JSX_DETECTION_HINT}.
|
|
612
|
+
* @param context The ESLint rule context (needed for variable resolution).
|
|
613
|
+
* @param node The AST node to analyse.
|
|
614
|
+
* @param hint Optional bit-flags to adjust detection behaviour. Defaults to {@link DEFAULT_JSX_DETECTION_HINT}.
|
|
616
615
|
* @returns Whether the node is considered JSX-like.
|
|
617
616
|
*
|
|
618
617
|
* @example
|
|
@@ -644,7 +643,7 @@ interface JsxConfig {
|
|
|
644
643
|
* Falls back to sensible React defaults when no compiler options are
|
|
645
644
|
* available (e.g. when the file is parsed without type information).
|
|
646
645
|
*
|
|
647
|
-
* @param context
|
|
646
|
+
* @param context The ESLint rule context.
|
|
648
647
|
* @returns Fully‑populated `JsxConfig` derived from compiler options.
|
|
649
648
|
*/
|
|
650
649
|
declare function getJsxConfigFromCompilerOptions(context: RuleContext): Required<JsxConfig>;
|
|
@@ -655,7 +654,7 @@ declare function getJsxConfigFromCompilerOptions(context: RuleContext): Required
|
|
|
655
654
|
* The result is cached per `sourceCode` instance via a `WeakMap` so that
|
|
656
655
|
* repeated calls from different rules analysing the same file are free.
|
|
657
656
|
*
|
|
658
|
-
* @param context
|
|
657
|
+
* @param context The ESLint rule context.
|
|
659
658
|
* @returns Partial `JsxConfig` containing only the values found in pragmas.
|
|
660
659
|
*/
|
|
661
660
|
declare function getJsxConfigFromAnnotation(context: RuleContext): JsxConfig;
|
|
@@ -667,7 +666,7 @@ declare function getJsxConfigFromAnnotation(context: RuleContext): JsxConfig;
|
|
|
667
666
|
*
|
|
668
667
|
* This is the main entry‑point most consumers should use.
|
|
669
668
|
*
|
|
670
|
-
* @param context
|
|
669
|
+
* @param context The ESLint rule context.
|
|
671
670
|
* @returns Fully‑populated, merged `JsxConfig`.
|
|
672
671
|
*/
|
|
673
672
|
declare function getJsxConfig(context: RuleContext): Required<JsxConfig>;
|
|
@@ -782,20 +781,20 @@ declare const isUnknownType: (type: ts.Type) => boolean;
|
|
|
782
781
|
//#endregion
|
|
783
782
|
//#region src/type-name.d.ts
|
|
784
783
|
/**
|
|
785
|
-
* An enhanced version of getFullyQualifiedName that handles cases that original function does not handle
|
|
786
|
-
* @param checker TypeScript type checker
|
|
787
|
-
* @param symbol
|
|
788
|
-
* @returns
|
|
784
|
+
* An enhanced version of getFullyQualifiedName that handles cases that original function does not handle.
|
|
785
|
+
* @param checker The TypeScript type checker.
|
|
786
|
+
* @param symbol The symbol to get fully qualified name for.
|
|
787
|
+
* @returns The fully qualified name of the symbol.
|
|
789
788
|
*/
|
|
790
789
|
declare function getFullyQualifiedNameEx(checker: ts.TypeChecker, symbol: ts.Symbol): string;
|
|
791
790
|
//#endregion
|
|
792
791
|
//#region src/type-variant.d.ts
|
|
793
792
|
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";
|
|
794
793
|
/**
|
|
795
|
-
* Ported from https://github.com/typescript-eslint/typescript-eslint/blob/eb736bbfc22554694400e6a4f97051d845d32e0b/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts#L826 with some enhancements
|
|
794
|
+
* Ported from https://github.com/typescript-eslint/typescript-eslint/blob/eb736bbfc22554694400e6a4f97051d845d32e0b/packages/eslint-plugin/src/rules/strict-boolean-expressions.ts#L826 with some enhancements.
|
|
796
795
|
* Get the variants of an array of types.
|
|
797
|
-
* @param types The types to get the variants of
|
|
798
|
-
* @returns The variants of the types
|
|
796
|
+
* @param types The types to get the variants of.
|
|
797
|
+
* @returns The variants of the types.
|
|
799
798
|
* @internal
|
|
800
799
|
*/
|
|
801
800
|
declare function getTypeVariants(types: ts.Type[]): Set<TypeVariant>;
|