@eslint-react/core 2.3.13-next.1 → 2.3.13-next.3
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 +55 -22
- package/dist/index.js +62 -24
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -220,13 +220,15 @@ declare namespace useComponentCollectorLegacy {
|
|
|
220
220
|
declare function useComponentCollectorLegacy(): useComponentCollectorLegacy.ReturnType;
|
|
221
221
|
/**
|
|
222
222
|
* Check whether the given node is a this.setState() call
|
|
223
|
-
* @param node
|
|
223
|
+
* @param node The node to check
|
|
224
|
+
* @param node
|
|
224
225
|
* @internal
|
|
225
226
|
*/
|
|
226
227
|
declare function isThisSetState(node: TSESTree$1.CallExpression): boolean;
|
|
227
228
|
/**
|
|
228
229
|
* Check whether the given node is an assignment to this.state
|
|
229
|
-
* @param node
|
|
230
|
+
* @param node The node to check
|
|
231
|
+
* @param node
|
|
230
232
|
* @internal
|
|
231
233
|
*/
|
|
232
234
|
declare function isAssignmentToThisState(node: TSESTree$1.AssignmentExpression): boolean;
|
|
@@ -235,9 +237,12 @@ declare function isAssignmentToThisState(node: TSESTree$1.AssignmentExpression):
|
|
|
235
237
|
/**
|
|
236
238
|
* Determines if a function node represents a valid React component definition
|
|
237
239
|
*
|
|
238
|
-
* @param context
|
|
239
|
-
* @param node
|
|
240
|
-
* @param hint
|
|
240
|
+
* @param context The rule context
|
|
241
|
+
* @param node The function node to analyze
|
|
242
|
+
* @param hint Component detection hints (bit flags) to customize detection logic
|
|
243
|
+
* @param context
|
|
244
|
+
* @param node
|
|
245
|
+
* @param hint
|
|
241
246
|
* @returns `true` if the node is considered a component definition
|
|
242
247
|
*/
|
|
243
248
|
declare function isComponentDefinition(context: RuleContext, node: AST.TSESTreeFunction, hint: bigint): boolean;
|
|
@@ -286,29 +291,39 @@ declare const isGetDerivedStateFromProps: (node: TSESTree.Node) => node is AST.T
|
|
|
286
291
|
declare const isGetDerivedStateFromError: (node: TSESTree.Node) => node is AST.TSESTreeMethodOrProperty;
|
|
287
292
|
//#endregion
|
|
288
293
|
//#region src/component/component-method-parts.d.ts
|
|
294
|
+
/**
|
|
295
|
+
* Checks if the node is a function of `componentDidMount`
|
|
296
|
+
* @param node The AST node to check
|
|
297
|
+
* @returns `true` if the node is a function of `componentDidMount`
|
|
298
|
+
*/
|
|
289
299
|
declare function isFunctionOfComponentDidMount(node: TSESTree.Node): boolean;
|
|
300
|
+
/**
|
|
301
|
+
* Checks if the node is a function of `componentWillUnmount`
|
|
302
|
+
* @param node The AST node to check
|
|
303
|
+
* @returns `true` if the node is a function of `componentWillUnmount`
|
|
304
|
+
*/
|
|
290
305
|
declare function isFunctionOfComponentWillUnmount(node: TSESTree.Node): boolean;
|
|
291
306
|
//#endregion
|
|
292
307
|
//#region src/component/component-name.d.ts
|
|
293
308
|
/**
|
|
294
309
|
* Check if a string matches the strict component name pattern
|
|
295
|
-
* @param name
|
|
310
|
+
* @param name The name to check
|
|
296
311
|
*/
|
|
297
312
|
declare function isComponentName(name: string): boolean;
|
|
298
313
|
/**
|
|
299
314
|
* Check if a string matches the loose component name pattern
|
|
300
|
-
* @param name
|
|
315
|
+
* @param name The name to check
|
|
301
316
|
*/
|
|
302
317
|
declare function isComponentNameLoose(name: string): boolean;
|
|
303
318
|
/**
|
|
304
319
|
* Get component name from an identifier or identifier sequence (e.g., MemberExpression)
|
|
305
|
-
* @param id
|
|
320
|
+
* @param id The identifier or identifier sequence
|
|
306
321
|
*/
|
|
307
322
|
declare function getComponentNameFromId(id: TSESTree.Identifier | TSESTree.Identifier[] | unit): string | undefined;
|
|
308
323
|
/**
|
|
309
324
|
* Check if the function has no name or a loose component name
|
|
310
|
-
* @param context
|
|
311
|
-
* @param fn
|
|
325
|
+
* @param context The rule context
|
|
326
|
+
* @param fn The function node
|
|
312
327
|
*/
|
|
313
328
|
declare function hasNoneOrLooseComponentName(context: RuleContext, fn: AST.TSESTreeFunction): boolean;
|
|
314
329
|
//#endregion
|
|
@@ -487,7 +502,15 @@ declare const REACT_BUILTIN_HOOK_NAMES: readonly ["use", "useActionState", "useC
|
|
|
487
502
|
declare function isReactHookName(name: string): boolean;
|
|
488
503
|
//#endregion
|
|
489
504
|
//#region src/hook/hook-parts.d.ts
|
|
505
|
+
/**
|
|
506
|
+
* Determines if a node is the setup function passed to a useEffect-like hook
|
|
507
|
+
* @param node The AST node to check
|
|
508
|
+
*/
|
|
490
509
|
declare function isFunctionOfUseEffectSetup(node: TSESTree.Node | unit): boolean;
|
|
510
|
+
/**
|
|
511
|
+
* Determines if a node is the cleanup function returned by a useEffect-like hook's setup function.
|
|
512
|
+
* @param node The AST node to check
|
|
513
|
+
*/
|
|
491
514
|
declare function isFunctionOfUseEffectCleanup(node: TSESTree.Node | unit): boolean;
|
|
492
515
|
//#endregion
|
|
493
516
|
//#region src/jsx/jsx-attribute.d.ts
|
|
@@ -547,7 +570,7 @@ declare function resolveJsxAttributeValue(context: RuleContext, attribute: AST.T
|
|
|
547
570
|
readonly toStatic: () => string | number | bigint | boolean | RegExp | null;
|
|
548
571
|
} | {
|
|
549
572
|
readonly kind: "expression";
|
|
550
|
-
readonly node: TSESTree.
|
|
573
|
+
readonly node: TSESTree.JSXEmptyExpression | TSESTree.Expression;
|
|
551
574
|
readonly toStatic: () => unknown;
|
|
552
575
|
} | {
|
|
553
576
|
readonly kind: "element";
|
|
@@ -555,7 +578,7 @@ declare function resolveJsxAttributeValue(context: RuleContext, attribute: AST.T
|
|
|
555
578
|
readonly toStatic: () => undefined;
|
|
556
579
|
} | {
|
|
557
580
|
readonly kind: "spreadChild";
|
|
558
|
-
readonly node: TSESTree.
|
|
581
|
+
readonly node: TSESTree.JSXEmptyExpression | TSESTree.Expression;
|
|
559
582
|
readonly toStatic: () => undefined;
|
|
560
583
|
} | {
|
|
561
584
|
readonly kind: "spreadProps";
|
|
@@ -645,8 +668,8 @@ declare function isJsxLike(code: {
|
|
|
645
668
|
* Determines if a JSX element is a host element
|
|
646
669
|
* Host elements in React start with lowercase letters (e.g., div, span)
|
|
647
670
|
*
|
|
648
|
-
* @param context
|
|
649
|
-
* @param node
|
|
671
|
+
* @param context ESLint rule context
|
|
672
|
+
* @param node AST node to check
|
|
650
673
|
* @returns boolean indicating if the element is a host element
|
|
651
674
|
*/
|
|
652
675
|
declare function isJsxHostElement(context: RuleContext, node: TSESTree.Node): boolean;
|
|
@@ -654,8 +677,8 @@ declare function isJsxHostElement(context: RuleContext, node: TSESTree.Node): bo
|
|
|
654
677
|
* Determines if a JSX element is a React Fragment
|
|
655
678
|
* Fragments can be imported from React and used like <Fragment> or <React.Fragment>
|
|
656
679
|
*
|
|
657
|
-
* @param context
|
|
658
|
-
* @param node
|
|
680
|
+
* @param context ESLint rule context
|
|
681
|
+
* @param node AST node to check
|
|
659
682
|
* @returns boolean indicating if the element is a Fragment with type narrowing
|
|
660
683
|
*/
|
|
661
684
|
declare function isJsxFragmentElement(context: RuleContext, node: TSESTree.Node): node is TSESTree.JSXElement;
|
|
@@ -666,8 +689,8 @@ declare function isJsxFragmentElement(context: RuleContext, node: TSESTree.Node)
|
|
|
666
689
|
* For JSX elements, returns the stringified name (e.g., "div", "Button", "React.Fragment")
|
|
667
690
|
* For JSX fragments, returns an empty string
|
|
668
691
|
*
|
|
669
|
-
* @param context
|
|
670
|
-
* @param node
|
|
692
|
+
* @param context ESLint rule context
|
|
693
|
+
* @param node JSX element or fragment node
|
|
671
694
|
* @returns String representation of the element type
|
|
672
695
|
*/
|
|
673
696
|
declare function getJsxElementType(context: RuleContext, node: TSESTree.JSXElement | TSESTree.JSXFragment): string;
|
|
@@ -676,8 +699,8 @@ declare function getJsxElementType(context: RuleContext, node: TSESTree.JSXEleme
|
|
|
676
699
|
/**
|
|
677
700
|
* Traverses up the AST to find a parent JSX attribute node that matches a given test
|
|
678
701
|
*
|
|
679
|
-
* @param node
|
|
680
|
-
* @param test
|
|
702
|
+
* @param node The starting AST node
|
|
703
|
+
* @param test Optional predicate function to test if the attribute meets criteria
|
|
681
704
|
* Defaults to always returning true (matches any attribute)
|
|
682
705
|
* @returns The first matching JSX attribute node found when traversing upwards, or undefined
|
|
683
706
|
*/
|
|
@@ -687,7 +710,7 @@ declare function findParentJsxAttribute(node: TSESTree.Node, test?: (node: TSEST
|
|
|
687
710
|
/**
|
|
688
711
|
* Incomplete but sufficient stringification of JSX nodes for common use cases
|
|
689
712
|
*
|
|
690
|
-
* @param node
|
|
713
|
+
* @param node JSX node from TypeScript ESTree
|
|
691
714
|
* @returns String representation of the JSX node
|
|
692
715
|
*/
|
|
693
716
|
declare function stringifyJsx(node: TSESTree$1.JSXIdentifier | TSESTree$1.JSXNamespacedName | TSESTree$1.JSXMemberExpression | TSESTree$1.JSXOpeningElement | TSESTree$1.JSXClosingElement | TSESTree$1.JSXOpeningFragment | TSESTree$1.JSXClosingFragment | TSESTree$1.JSXText): string;
|
|
@@ -700,7 +723,7 @@ declare function stringifyJsx(node: TSESTree$1.JSXIdentifier | TSESTree$1.JSXNam
|
|
|
700
723
|
* @param prev The previous AST node in the traversal (used for context)
|
|
701
724
|
* @internal
|
|
702
725
|
*/
|
|
703
|
-
declare function getInstanceId(node: TSESTree.Node, prev?: TSESTree.Node): TSESTree.
|
|
726
|
+
declare function getInstanceId(node: TSESTree.Node, prev?: TSESTree.Node): TSESTree.ArrayExpression | TSESTree.ArrayPattern | TSESTree.ArrowFunctionExpression | 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.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.UnaryExpressionBitwiseNot | TSESTree.UnaryExpressionDelete | TSESTree.UnaryExpressionMinus | TSESTree.UnaryExpressionNot | TSESTree.UnaryExpressionPlus | TSESTree.UnaryExpressionTypeof | TSESTree.UnaryExpressionVoid | TSESTree.UpdateExpression | TSESTree.YieldExpression | undefined;
|
|
704
727
|
//#endregion
|
|
705
728
|
//#region src/utils/is-from-react.d.ts
|
|
706
729
|
/**
|
|
@@ -734,6 +757,11 @@ declare namespace isReactAPI {
|
|
|
734
757
|
(context: RuleContext): (node: unit | null | TSESTree.Node) => node is TSESTree.MemberExpression | TSESTree.Identifier;
|
|
735
758
|
};
|
|
736
759
|
}
|
|
760
|
+
/**
|
|
761
|
+
* Checks if the node is a React API identifier or member expression
|
|
762
|
+
* @param api The React API name to check against (e.g., "useState", "React.memo")
|
|
763
|
+
* @returns A predicate function to check if a node matches the API
|
|
764
|
+
*/
|
|
737
765
|
declare function isReactAPI(api: string): isReactAPI.ReturnType;
|
|
738
766
|
declare namespace isReactAPICall {
|
|
739
767
|
type ReturnType = {
|
|
@@ -741,6 +769,11 @@ declare namespace isReactAPICall {
|
|
|
741
769
|
(context: RuleContext): (node: unit | null | TSESTree.Node) => node is TSESTree.CallExpression;
|
|
742
770
|
};
|
|
743
771
|
}
|
|
772
|
+
/**
|
|
773
|
+
* Checks if the node is a call expression to a specific React API
|
|
774
|
+
* @param api The React API name to check against
|
|
775
|
+
* @returns A predicate function to check if a node is a call to the API
|
|
776
|
+
*/
|
|
744
777
|
declare function isReactAPICall(api: string): isReactAPICall.ReturnType;
|
|
745
778
|
declare const isCaptureOwnerStack: isReactAPI.ReturnType;
|
|
746
779
|
declare const isChildrenCount: isReactAPI.ReturnType;
|
package/dist/index.js
CHANGED
|
@@ -197,10 +197,18 @@ function isReactHookId(id) {
|
|
|
197
197
|
|
|
198
198
|
//#endregion
|
|
199
199
|
//#region src/hook/hook-parts.ts
|
|
200
|
+
/**
|
|
201
|
+
* Determines if a node is the setup function passed to a useEffect-like hook
|
|
202
|
+
* @param node The AST node to check
|
|
203
|
+
*/
|
|
200
204
|
function isFunctionOfUseEffectSetup(node) {
|
|
201
205
|
if (node == null) return false;
|
|
202
206
|
return node.parent?.type === AST_NODE_TYPES.CallExpression && node.parent.arguments.at(0) === node && isUseEffectLikeCall(node.parent);
|
|
203
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Determines if a node is the cleanup function returned by a useEffect-like hook's setup function.
|
|
210
|
+
* @param node The AST node to check
|
|
211
|
+
*/
|
|
204
212
|
function isFunctionOfUseEffectCleanup(node) {
|
|
205
213
|
if (node == null) return false;
|
|
206
214
|
const pReturn = AST.findParentNode(node, AST.is(AST_NODE_TYPES.ReturnStatement));
|
|
@@ -214,7 +222,7 @@ function isFunctionOfUseEffectCleanup(node) {
|
|
|
214
222
|
/**
|
|
215
223
|
* Incomplete but sufficient stringification of JSX nodes for common use cases
|
|
216
224
|
*
|
|
217
|
-
* @param node
|
|
225
|
+
* @param node JSX node from TypeScript ESTree
|
|
218
226
|
* @returns String representation of the JSX node
|
|
219
227
|
*/
|
|
220
228
|
function stringifyJsx(node) {
|
|
@@ -492,8 +500,8 @@ function isJsxLike(code, node, hint = DEFAULT_JSX_DETECTION_HINT) {
|
|
|
492
500
|
* For JSX elements, returns the stringified name (e.g., "div", "Button", "React.Fragment")
|
|
493
501
|
* For JSX fragments, returns an empty string
|
|
494
502
|
*
|
|
495
|
-
* @param context
|
|
496
|
-
* @param node
|
|
503
|
+
* @param context ESLint rule context
|
|
504
|
+
* @param node JSX element or fragment node
|
|
497
505
|
* @returns String representation of the element type
|
|
498
506
|
*/
|
|
499
507
|
function getJsxElementType(context, node) {
|
|
@@ -507,8 +515,8 @@ function getJsxElementType(context, node) {
|
|
|
507
515
|
* Determines if a JSX element is a host element
|
|
508
516
|
* Host elements in React start with lowercase letters (e.g., div, span)
|
|
509
517
|
*
|
|
510
|
-
* @param context
|
|
511
|
-
* @param node
|
|
518
|
+
* @param context ESLint rule context
|
|
519
|
+
* @param node AST node to check
|
|
512
520
|
* @returns boolean indicating if the element is a host element
|
|
513
521
|
*/
|
|
514
522
|
function isJsxHostElement(context, node) {
|
|
@@ -518,8 +526,8 @@ function isJsxHostElement(context, node) {
|
|
|
518
526
|
* Determines if a JSX element is a React Fragment
|
|
519
527
|
* Fragments can be imported from React and used like <Fragment> or <React.Fragment>
|
|
520
528
|
*
|
|
521
|
-
* @param context
|
|
522
|
-
* @param node
|
|
529
|
+
* @param context ESLint rule context
|
|
530
|
+
* @param node AST node to check
|
|
523
531
|
* @returns boolean indicating if the element is a Fragment with type narrowing
|
|
524
532
|
*/
|
|
525
533
|
function isJsxFragmentElement(context, node) {
|
|
@@ -532,8 +540,8 @@ function isJsxFragmentElement(context, node) {
|
|
|
532
540
|
/**
|
|
533
541
|
* Traverses up the AST to find a parent JSX attribute node that matches a given test
|
|
534
542
|
*
|
|
535
|
-
* @param node
|
|
536
|
-
* @param test
|
|
543
|
+
* @param node The starting AST node
|
|
544
|
+
* @param test Optional predicate function to test if the attribute meets criteria
|
|
537
545
|
* Defaults to always returning true (matches any attribute)
|
|
538
546
|
* @returns The first matching JSX attribute node found when traversing upwards, or undefined
|
|
539
547
|
*/
|
|
@@ -629,6 +637,11 @@ function isInstanceIdEqual(context, a, b) {
|
|
|
629
637
|
|
|
630
638
|
//#endregion
|
|
631
639
|
//#region src/utils/is-react-api.ts
|
|
640
|
+
/**
|
|
641
|
+
* Checks if the node is a React API identifier or member expression
|
|
642
|
+
* @param api The React API name to check against (e.g., "useState", "React.memo")
|
|
643
|
+
* @returns A predicate function to check if a node matches the API
|
|
644
|
+
*/
|
|
632
645
|
function isReactAPI(api) {
|
|
633
646
|
const func = (context, node) => {
|
|
634
647
|
if (node == null) return false;
|
|
@@ -640,6 +653,11 @@ function isReactAPI(api) {
|
|
|
640
653
|
};
|
|
641
654
|
return dual(2, func);
|
|
642
655
|
}
|
|
656
|
+
/**
|
|
657
|
+
* Checks if the node is a call expression to a specific React API
|
|
658
|
+
* @param api The React API name to check against
|
|
659
|
+
* @returns A predicate function to check if a node is a call to the API
|
|
660
|
+
*/
|
|
643
661
|
function isReactAPICall(api) {
|
|
644
662
|
const func = (context, node) => {
|
|
645
663
|
if (node == null) return false;
|
|
@@ -771,7 +789,8 @@ const FUNCTION_PATTERNS = {
|
|
|
771
789
|
/**
|
|
772
790
|
* Checks if the given node is a function within a render method of a class component.
|
|
773
791
|
*
|
|
774
|
-
* @param node
|
|
792
|
+
* @param node The AST node to check
|
|
793
|
+
* @param node
|
|
775
794
|
* @returns `true` if the node is a render function inside a class component
|
|
776
795
|
*
|
|
777
796
|
* @example
|
|
@@ -789,8 +808,10 @@ function isFunctionOfRenderMethod(node) {
|
|
|
789
808
|
/**
|
|
790
809
|
* Checks if a function node should be excluded based on provided detection hints
|
|
791
810
|
*
|
|
792
|
-
* @param node
|
|
793
|
-
* @param hint
|
|
811
|
+
* @param node The function node to check
|
|
812
|
+
* @param hint Component detection hints as bit flags
|
|
813
|
+
* @param node
|
|
814
|
+
* @param hint
|
|
794
815
|
* @returns `true` if the function matches an exclusion hint
|
|
795
816
|
*/
|
|
796
817
|
function shouldExcludeBasedOnHint(node, hint) {
|
|
@@ -803,8 +824,10 @@ function shouldExcludeBasedOnHint(node, hint) {
|
|
|
803
824
|
/**
|
|
804
825
|
* Determines if the node is an argument within `createElement`'s children list (3rd argument onwards)
|
|
805
826
|
*
|
|
806
|
-
* @param context
|
|
807
|
-
* @param node
|
|
827
|
+
* @param context The rule context
|
|
828
|
+
* @param node The AST node to check
|
|
829
|
+
* @param context
|
|
830
|
+
* @param node
|
|
808
831
|
* @returns `true` if the node is passed as a child to `createElement`
|
|
809
832
|
*/
|
|
810
833
|
function isChildrenOfCreateElement(context, node) {
|
|
@@ -816,9 +839,12 @@ function isChildrenOfCreateElement(context, node) {
|
|
|
816
839
|
/**
|
|
817
840
|
* Determines if a function node represents a valid React component definition
|
|
818
841
|
*
|
|
819
|
-
* @param context
|
|
820
|
-
* @param node
|
|
821
|
-
* @param hint
|
|
842
|
+
* @param context The rule context
|
|
843
|
+
* @param node The function node to analyze
|
|
844
|
+
* @param hint Component detection hints (bit flags) to customize detection logic
|
|
845
|
+
* @param context
|
|
846
|
+
* @param node
|
|
847
|
+
* @param hint
|
|
822
848
|
* @returns `true` if the node is considered a component definition
|
|
823
849
|
*/
|
|
824
850
|
function isComponentDefinition(context, node, hint) {
|
|
@@ -892,21 +918,21 @@ function getComponentFlagFromInitPath(initPath) {
|
|
|
892
918
|
//#region src/component/component-name.ts
|
|
893
919
|
/**
|
|
894
920
|
* Check if a string matches the strict component name pattern
|
|
895
|
-
* @param name
|
|
921
|
+
* @param name The name to check
|
|
896
922
|
*/
|
|
897
923
|
function isComponentName(name) {
|
|
898
924
|
return RE_COMPONENT_NAME.test(name);
|
|
899
925
|
}
|
|
900
926
|
/**
|
|
901
927
|
* Check if a string matches the loose component name pattern
|
|
902
|
-
* @param name
|
|
928
|
+
* @param name The name to check
|
|
903
929
|
*/
|
|
904
930
|
function isComponentNameLoose(name) {
|
|
905
931
|
return RE_COMPONENT_NAME_LOOSE.test(name);
|
|
906
932
|
}
|
|
907
933
|
/**
|
|
908
934
|
* Get component name from an identifier or identifier sequence (e.g., MemberExpression)
|
|
909
|
-
* @param id
|
|
935
|
+
* @param id The identifier or identifier sequence
|
|
910
936
|
*/
|
|
911
937
|
function getComponentNameFromId(id) {
|
|
912
938
|
if (id == null) return unit;
|
|
@@ -914,8 +940,8 @@ function getComponentNameFromId(id) {
|
|
|
914
940
|
}
|
|
915
941
|
/**
|
|
916
942
|
* Check if the function has no name or a loose component name
|
|
917
|
-
* @param context
|
|
918
|
-
* @param fn
|
|
943
|
+
* @param context The rule context
|
|
944
|
+
* @param fn The function node
|
|
919
945
|
*/
|
|
920
946
|
function hasNoneOrLooseComponentName(context, fn) {
|
|
921
947
|
const id = getFunctionComponentId(context, fn);
|
|
@@ -1064,7 +1090,8 @@ function useComponentCollectorLegacy() {
|
|
|
1064
1090
|
}
|
|
1065
1091
|
/**
|
|
1066
1092
|
* Check whether the given node is a this.setState() call
|
|
1067
|
-
* @param node
|
|
1093
|
+
* @param node The node to check
|
|
1094
|
+
* @param node
|
|
1068
1095
|
* @internal
|
|
1069
1096
|
*/
|
|
1070
1097
|
function isThisSetState(node) {
|
|
@@ -1073,7 +1100,8 @@ function isThisSetState(node) {
|
|
|
1073
1100
|
}
|
|
1074
1101
|
/**
|
|
1075
1102
|
* Check whether the given node is an assignment to this.state
|
|
1076
|
-
* @param node
|
|
1103
|
+
* @param node The node to check
|
|
1104
|
+
* @param node
|
|
1077
1105
|
* @internal
|
|
1078
1106
|
*/
|
|
1079
1107
|
function isAssignmentToThisState(node) {
|
|
@@ -1114,9 +1142,19 @@ const isGetDerivedStateFromError = createLifecycleChecker("getDerivedStateFromEr
|
|
|
1114
1142
|
|
|
1115
1143
|
//#endregion
|
|
1116
1144
|
//#region src/component/component-method-parts.ts
|
|
1145
|
+
/**
|
|
1146
|
+
* Checks if the node is a function of `componentDidMount`
|
|
1147
|
+
* @param node The AST node to check
|
|
1148
|
+
* @returns `true` if the node is a function of `componentDidMount`
|
|
1149
|
+
*/
|
|
1117
1150
|
function isFunctionOfComponentDidMount(node) {
|
|
1118
1151
|
return AST.isFunction(node) && isComponentDidMount(node.parent) && node.parent.value === node;
|
|
1119
1152
|
}
|
|
1153
|
+
/**
|
|
1154
|
+
* Checks if the node is a function of `componentWillUnmount`
|
|
1155
|
+
* @param node The AST node to check
|
|
1156
|
+
* @returns `true` if the node is a function of `componentWillUnmount`
|
|
1157
|
+
*/
|
|
1120
1158
|
function isFunctionOfComponentWillUnmount(node) {
|
|
1121
1159
|
return AST.isFunction(node) && isComponentWillUnmount(node.parent) && node.parent.value === node;
|
|
1122
1160
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "2.3.13-next.
|
|
3
|
+
"version": "2.3.13-next.3",
|
|
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": {
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"@typescript-eslint/utils": "^8.48.1",
|
|
36
36
|
"birecord": "^0.1.1",
|
|
37
37
|
"ts-pattern": "^5.9.0",
|
|
38
|
-
"@eslint-react/ast": "2.3.13-next.
|
|
39
|
-
"@eslint-react/eff": "2.3.13-next.
|
|
40
|
-
"@eslint-react/
|
|
41
|
-
"@eslint-react/
|
|
38
|
+
"@eslint-react/ast": "2.3.13-next.3",
|
|
39
|
+
"@eslint-react/eff": "2.3.13-next.3",
|
|
40
|
+
"@eslint-react/shared": "2.3.13-next.3",
|
|
41
|
+
"@eslint-react/var": "2.3.13-next.3"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"eslint": "^8.57.0 || ^9.0.0",
|