@eslint-react/core 1.24.2-next.0 → 1.24.2-next.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 CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as AST from '@eslint-react/ast';
2
+ import { _ } from '@eslint-react/eff';
2
3
  import * as _eslint_react_shared from '@eslint-react/shared';
3
4
  import { RuleContext } from '@eslint-react/shared';
4
5
  import { TSESTree } from '@typescript-eslint/types';
5
- import { _ } from '@eslint-react/eff';
6
- import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
6
+ import { ESLintUtils, TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
7
7
  import * as birecord from 'birecord';
8
8
  import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
9
9
  import { Scope } from '@typescript-eslint/scope-manager';
@@ -76,10 +76,6 @@ interface ERClassComponent extends ERSemanticNode {
76
76
  }
77
77
  type ERComponent = ERClassComponent | ERFunctionComponent;
78
78
 
79
- interface ComponentCollectorOptions {
80
- collectDisplayName?: boolean;
81
- collectHookCalls?: boolean;
82
- }
83
79
  /**
84
80
  * Get a ctx and listeners for the rule to collect function components
85
81
  * @param context The ESLint rule context
@@ -87,49 +83,43 @@ interface ComponentCollectorOptions {
87
83
  * @param options The options to use
88
84
  * @returns The component collector
89
85
  */
90
- declare function useComponentCollector(context: RuleContext, hint?: bigint, options?: ComponentCollectorOptions): {
91
- readonly ctx: {
92
- readonly getAllComponents: (node: TSESTree.Program) => Map<string, ERFunctionComponent>;
93
- readonly getCurrentEntries: () => {
94
- key: string;
95
- node: AST.TSESTreeFunction;
96
- hookCalls: TSESTree.CallExpression[];
97
- isComponent: boolean;
98
- }[];
99
- readonly getCurrentEntry: () => {
100
- key: string;
101
- node: AST.TSESTreeFunction;
102
- hookCalls: TSESTree.CallExpression[];
103
- isComponent: boolean;
104
- } | undefined;
86
+ declare function useComponentCollector(context: RuleContext, hint?: bigint, options?: useComponentCollector.Options): useComponentCollector.ReturnType;
87
+ declare namespace useComponentCollector {
88
+ type Options = {
89
+ collectDisplayName?: boolean;
90
+ collectHookCalls?: boolean;
105
91
  };
106
- readonly listeners: {
107
- readonly "ReturnStatement[type]": (node: TSESTree.ReturnStatement) => void;
108
- readonly "CallExpression[type]:exit"?: (node: TSESTree.CallExpression) => void;
109
- readonly ":function[type]": (node: AST.TSESTreeFunction) => void;
110
- readonly ":function[type]:exit": () => {
111
- key: string;
112
- node: AST.TSESTreeFunction;
113
- hookCalls: TSESTree.CallExpression[];
114
- isComponent: boolean;
115
- } | undefined;
116
- readonly "ArrowFunctionExpression[type][body.type!='BlockStatement']": () => void;
92
+ type Entry = {
93
+ key: string;
94
+ node: AST.TSESTreeFunction;
95
+ hookCalls: TSESTree.CallExpression[];
96
+ isComponent: boolean;
117
97
  };
118
- };
98
+ type Ctx = {
99
+ getAllComponents: (node: TSESTree.Program) => Map<string, ERFunctionComponent>;
100
+ getCurrentEntries: () => Entry[];
101
+ getCurrentEntry: () => Entry | _;
102
+ };
103
+ type ReturnType = {
104
+ ctx: Ctx;
105
+ listeners: ESLintUtils.RuleListener;
106
+ };
107
+ }
119
108
 
120
109
  /**
121
110
  * Get a ctx and listeners for the rule to collect class components
122
111
  * @returns The context and listeners for the rule
123
112
  */
124
- declare function useComponentCollectorLegacy(): {
125
- readonly ctx: {
126
- readonly getAllComponents: (node: TSESTree$1.Program) => Map<string, ERClassComponent>;
113
+ declare function useComponentCollectorLegacy(): useComponentCollectorLegacy.ReturnType;
114
+ declare namespace useComponentCollectorLegacy {
115
+ type Ctx = {
116
+ getAllComponents: (node: TSESTree$1.Program) => Map<string, ERClassComponent>;
127
117
  };
128
- readonly listeners: {
129
- readonly "ClassDeclaration[type]": (node: AST.TSESTreeClass) => void;
130
- readonly "ClassExpression[type]": (node: AST.TSESTreeClass) => void;
118
+ type ReturnType = {
119
+ ctx: Ctx;
120
+ listeners: ESLintUtils.RuleListener;
131
121
  };
132
- };
122
+ }
133
123
 
134
124
  /**
135
125
  * The ESQuery selector for a component display name assignment expression
@@ -284,17 +274,21 @@ interface ERHook extends ERSemanticNode {
284
274
  hookCalls: TSESTree.CallExpression[];
285
275
  }
286
276
 
287
- declare function useHookCollector(): {
288
- readonly ctx: {
289
- readonly getAllHooks: (node: TSESTree$1.Program) => Map<string, ERHook>;
290
- readonly getCurrentHooks: () => Map<string, ERHook>;
277
+ declare function useHookCollector(): useHookCollector.ReturnType;
278
+ declare namespace useHookCollector {
279
+ type Entry = {
280
+ key: string;
281
+ node: AST.TSESTreeFunction;
282
+ isHook: boolean;
291
283
  };
292
- readonly listeners: {
293
- readonly ":function[type]": (node: AST.TSESTreeFunction) => void;
294
- readonly ":function[type]:exit": () => void;
295
- readonly "CallExpression[type]": (node: never) => void;
284
+ type Ctx = {
285
+ getAllHooks(node: TSESTree$1.Program): Map<string, ERHook>;
296
286
  };
297
- };
287
+ type ReturnType = {
288
+ ctx: Ctx;
289
+ listeners: ESLintUtils.RuleListener;
290
+ };
291
+ }
298
292
 
299
293
  type ERHookKind = "custom" | "useActionState" | "useCallback" | "useContext" | "useDebugValue" | "useDeferredValue" | "useEffect" | "useId" | "useImperativeHandle" | "useInsertionEffect" | "useLayoutEffect" | "useMemo" | "useOptimistic" | "useReducer" | "useRef" | "useState" | "useSyncExternalStore" | "useTransition";
300
294
 
@@ -346,20 +340,24 @@ declare function isFromReact(name: string): (node: TSESTree.Identifier | TSESTre
346
340
  * @returns A function that checks if a given node is a member expression of a Pragma member.
347
341
  */
348
342
  declare function isFromReactMember(memberName: string, name: string): (node: TSESTree.MemberExpression, context: RuleContext) => boolean;
349
- type IsCallFromReact = {
350
- (context: RuleContext): (node: TSESTree.Node) => node is TSESTree.CallExpression;
351
- (node: TSESTree.Node, context: RuleContext): node is TSESTree.CallExpression;
352
- };
353
- declare function isCallFromReact(name: string): IsCallFromReact;
354
- type IsCallFromReactMember = {
355
- (context: RuleContext): (node: TSESTree.Node) => node is TSESTree.CallExpression & {
356
- callee: TSESTree.MemberExpression;
343
+ declare function isCallFromReact(name: string): isCallFromReact.ReturnType;
344
+ declare namespace isCallFromReact {
345
+ type ReturnType = {
346
+ (context: RuleContext): (node: TSESTree.Node) => node is TSESTree.CallExpression;
347
+ (node: TSESTree.Node, context: RuleContext): node is TSESTree.CallExpression;
357
348
  };
358
- (node: TSESTree.Node, context: RuleContext): node is TSESTree.CallExpression & {
359
- callee: TSESTree.MemberExpression;
349
+ }
350
+ declare function isCallFromReactMember(pragmaMemberName: string, name: string): isCallFromReactMember.ReturnType;
351
+ declare namespace isCallFromReactMember {
352
+ type ReturnType = {
353
+ (context: RuleContext): (node: TSESTree.Node) => node is TSESTree.CallExpression & {
354
+ callee: TSESTree.MemberExpression;
355
+ };
356
+ (node: TSESTree.Node, context: RuleContext): node is TSESTree.CallExpression & {
357
+ callee: TSESTree.MemberExpression;
358
+ };
360
359
  };
361
- };
362
- declare function isCallFromReactMember(pragmaMemberName: string, name: string): IsCallFromReactMember;
360
+ }
363
361
 
364
362
  declare function isInitializedFromReact(name: string, importSource: string, initialScope: Scope): boolean;
365
363
 
@@ -608,21 +606,6 @@ declare enum AST_NODE_TYPES {
608
606
  TSUnknownKeyword = "TSUnknownKeyword",
609
607
  TSVoidKeyword = "TSVoidKeyword"
610
608
  }
611
- declare enum AST_TOKEN_TYPES {
612
- Boolean = "Boolean",
613
- Identifier = "Identifier",
614
- JSXIdentifier = "JSXIdentifier",
615
- JSXText = "JSXText",
616
- Keyword = "Keyword",
617
- Null = "Null",
618
- Numeric = "Numeric",
619
- Punctuator = "Punctuator",
620
- RegularExpression = "RegularExpression",
621
- String = "String",
622
- Template = "Template",
623
- Block = "Block",
624
- Line = "Line"
625
- }
626
609
  declare interface AwaitExpression extends BaseNode {
627
610
  type: AST_NODE_TYPES.AwaitExpression;
628
611
  argument: Expression;
@@ -630,10 +613,6 @@ declare interface AwaitExpression extends BaseNode {
630
613
  declare interface BaseNode extends NodeOrTokenData {
631
614
  type: AST_NODE_TYPES;
632
615
  }
633
- declare interface BaseToken extends NodeOrTokenData {
634
- type: AST_TOKEN_TYPES;
635
- value: string;
636
- }
637
616
  declare interface BigIntLiteral extends LiteralBase {
638
617
  bigint: string;
639
618
  value: bigint | null;
@@ -672,9 +651,6 @@ declare interface BinaryOperatorToText {
672
651
  }
673
652
  declare type BindingName = BindingPattern | Identifier;
674
653
  declare type BindingPattern = ArrayPattern | ObjectPattern;
675
- declare interface BlockComment extends BaseToken {
676
- type: AST_TOKEN_TYPES.Block;
677
- }
678
654
  declare interface BlockStatement extends BaseNode {
679
655
  type: AST_NODE_TYPES.BlockStatement;
680
656
  body: Statement[];
@@ -683,9 +659,6 @@ declare interface BooleanLiteral extends LiteralBase {
683
659
  raw: 'false' | 'true';
684
660
  value: boolean;
685
661
  }
686
- declare interface BooleanToken extends BaseToken {
687
- type: AST_TOKEN_TYPES.Boolean;
688
- }
689
662
  declare interface BreakStatement extends BaseNode {
690
663
  type: AST_NODE_TYPES.BreakStatement;
691
664
  label: Identifier | null;
@@ -766,7 +739,6 @@ declare interface ClassBody extends BaseNode {
766
739
  type: AST_NODE_TYPES.ClassBody;
767
740
  body: ClassElement[];
768
741
  }
769
- declare type ClassDeclaration = ClassDeclarationWithName | ClassDeclarationWithOptionalName;
770
742
  declare interface ClassDeclarationBase extends ClassBase {
771
743
  type: AST_NODE_TYPES.ClassDeclaration;
772
744
  }
@@ -803,7 +775,6 @@ declare interface ClassPropertyDefinitionNonComputedNameBase extends PropertyDef
803
775
  key: ClassPropertyNameNonComputed;
804
776
  }
805
777
  declare type ClassPropertyNameNonComputed = PrivateIdentifier | PropertyNameNonComputed;
806
- declare type Comment = BlockComment | LineComment;
807
778
  declare interface ConditionalExpression extends BaseNode {
808
779
  type: AST_NODE_TYPES.ConditionalExpression;
809
780
  alternate: Expression;
@@ -1096,7 +1067,6 @@ declare interface FunctionBase extends BaseNode {
1096
1067
  */
1097
1068
  typeParameters: TSTypeParameterDeclaration | undefined;
1098
1069
  }
1099
- declare type FunctionDeclaration = FunctionDeclarationWithName | FunctionDeclarationWithOptionalName;
1100
1070
  declare interface FunctionDeclarationBase extends FunctionBase {
1101
1071
  type: AST_NODE_TYPES.FunctionDeclaration;
1102
1072
  body: BlockStatement;
@@ -1133,9 +1103,6 @@ declare interface Identifier extends BaseNode {
1133
1103
  optional: boolean;
1134
1104
  typeAnnotation: TSTypeAnnotation | undefined;
1135
1105
  }
1136
- declare interface IdentifierToken extends BaseToken {
1137
- type: AST_TOKEN_TYPES.Identifier;
1138
- }
1139
1106
  declare interface IfStatement extends BaseNode {
1140
1107
  type: AST_NODE_TYPES.IfStatement;
1141
1108
  alternate: Statement | null;
@@ -1261,9 +1228,6 @@ declare interface JSXIdentifier extends BaseNode {
1261
1228
  type: AST_NODE_TYPES.JSXIdentifier;
1262
1229
  name: string;
1263
1230
  }
1264
- declare interface JSXIdentifierToken extends BaseToken {
1265
- type: AST_TOKEN_TYPES.JSXIdentifier;
1266
- }
1267
1231
  declare interface JSXMemberExpression extends BaseNode {
1268
1232
  type: AST_NODE_TYPES.JSXMemberExpression;
1269
1233
  object: JSXTagNameExpression;
@@ -1298,12 +1262,6 @@ declare interface JSXText extends BaseNode {
1298
1262
  raw: string;
1299
1263
  value: string;
1300
1264
  }
1301
- declare interface JSXTextToken extends BaseToken {
1302
- type: AST_TOKEN_TYPES.JSXText;
1303
- }
1304
- declare interface KeywordToken extends BaseToken {
1305
- type: AST_TOKEN_TYPES.Keyword;
1306
- }
1307
1265
  declare interface LabeledStatement extends BaseNode {
1308
1266
  type: AST_NODE_TYPES.LabeledStatement;
1309
1267
  body: Statement;
@@ -1367,9 +1325,6 @@ declare interface LetOrVarNonDeclaredDeclaration extends LetOrConstOrVarDeclarat
1367
1325
  declare: false;
1368
1326
  kind: 'let' | 'var';
1369
1327
  }
1370
- declare interface LineComment extends BaseToken {
1371
- type: AST_TOKEN_TYPES.Line;
1372
- }
1373
1328
  declare type Literal = BigIntLiteral | BooleanLiteral | NullLiteral | NumberLiteral | RegExpLiteral | StringLiteral;
1374
1329
  declare interface LiteralBase extends BaseNode {
1375
1330
  type: AST_NODE_TYPES.Literal;
@@ -1439,7 +1394,6 @@ declare interface NewExpression extends BaseNode {
1439
1394
  callee: Expression;
1440
1395
  typeArguments: TSTypeParameterInstantiation | undefined;
1441
1396
  }
1442
- declare type Node = AccessorProperty | ArrayExpression | ArrayPattern | ArrowFunctionExpression | AssignmentExpression | AssignmentPattern | AwaitExpression | BinaryExpression | BlockStatement | BreakStatement | CallExpression | CatchClause | ChainExpression | ClassBody | ClassDeclaration | ClassExpression | ConditionalExpression | ContinueStatement | DebuggerStatement | Decorator | DoWhileStatement | EmptyStatement | ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | ExportSpecifier | ExpressionStatement | ForInStatement | ForOfStatement | ForStatement | FunctionDeclaration | FunctionExpression | Identifier | IfStatement | ImportAttribute | ImportDeclaration | ImportDefaultSpecifier | ImportExpression | ImportNamespaceSpecifier | ImportSpecifier | JSXAttribute | JSXClosingElement | JSXClosingFragment | JSXElement | JSXEmptyExpression | JSXExpressionContainer | JSXFragment | JSXIdentifier | JSXMemberExpression | JSXNamespacedName | JSXOpeningElement | JSXOpeningFragment | JSXSpreadAttribute | JSXSpreadChild | JSXText | LabeledStatement | Literal | LogicalExpression | MemberExpression | MetaProperty | MethodDefinition | NewExpression | ObjectExpression | ObjectPattern | PrivateIdentifier | Program | Property | PropertyDefinition | RestElement | ReturnStatement | SequenceExpression | SpreadElement | StaticBlock | Super | SwitchCase | SwitchStatement | TaggedTemplateExpression | TemplateElement | TemplateLiteral | ThisExpression | ThrowStatement | TryStatement | TSAbstractAccessorProperty | TSAbstractKeyword | TSAbstractMethodDefinition | TSAbstractPropertyDefinition | TSAnyKeyword | TSArrayType | TSAsExpression | TSAsyncKeyword | TSBigIntKeyword | TSBooleanKeyword | TSCallSignatureDeclaration | TSClassImplements | TSConditionalType | TSConstructorType | TSConstructSignatureDeclaration | TSDeclareFunction | TSDeclareKeyword | TSEmptyBodyFunctionExpression | TSEnumBody | TSEnumDeclaration | TSEnumMember | TSExportAssignment | TSExportKeyword | TSExternalModuleReference | TSFunctionType | TSImportEqualsDeclaration | TSImportType | TSIndexedAccessType | TSIndexSignature | TSInferType | TSInstantiationExpression | TSInterfaceBody | TSInterfaceDeclaration | TSInterfaceHeritage | TSIntersectionType | TSIntrinsicKeyword | TSLiteralType | TSMappedType | TSMethodSignature | TSModuleBlock | TSModuleDeclaration | TSNamedTupleMember | TSNamespaceExportDeclaration | TSNeverKeyword | TSNonNullExpression | TSNullKeyword | TSNumberKeyword | TSObjectKeyword | TSOptionalType | TSParameterProperty | TSPrivateKeyword | TSPropertySignature | TSProtectedKeyword | TSPublicKeyword | TSQualifiedName | TSReadonlyKeyword | TSRestType | TSSatisfiesExpression | TSStaticKeyword | TSStringKeyword | TSSymbolKeyword | TSTemplateLiteralType | TSThisType | TSTupleType | TSTypeAliasDeclaration | TSTypeAnnotation | TSTypeAssertion | TSTypeLiteral | TSTypeOperator | TSTypeParameter | TSTypeParameterDeclaration | TSTypeParameterInstantiation | TSTypePredicate | TSTypeQuery | TSTypeReference | TSUndefinedKeyword | TSUnionType | TSUnknownKeyword | TSVoidKeyword | UnaryExpression | UpdateExpression | VariableDeclaration | VariableDeclarator | WhileStatement | WithStatement | YieldExpression;
1443
1397
  declare interface NodeOrTokenData {
1444
1398
  type: string;
1445
1399
  /**
@@ -1454,15 +1408,9 @@ declare interface NullLiteral extends LiteralBase {
1454
1408
  raw: 'null';
1455
1409
  value: null;
1456
1410
  }
1457
- declare interface NullToken extends BaseToken {
1458
- type: AST_TOKEN_TYPES.Null;
1459
- }
1460
1411
  declare interface NumberLiteral extends LiteralBase {
1461
1412
  value: number;
1462
1413
  }
1463
- declare interface NumericToken extends BaseToken {
1464
- type: AST_TOKEN_TYPES.Numeric;
1465
- }
1466
1414
  declare interface ObjectExpression extends BaseNode {
1467
1415
  type: AST_NODE_TYPES.ObjectExpression;
1468
1416
  properties: ObjectLiteralElement[];
@@ -1490,13 +1438,6 @@ declare interface PrivateIdentifier extends BaseNode {
1490
1438
  type: AST_NODE_TYPES.PrivateIdentifier;
1491
1439
  name: string;
1492
1440
  }
1493
- declare interface Program extends NodeOrTokenData {
1494
- type: AST_NODE_TYPES.Program;
1495
- body: ProgramStatement[];
1496
- comments: Comment[] | undefined;
1497
- sourceType: 'module' | 'script';
1498
- tokens: Token[] | undefined;
1499
- }
1500
1441
  declare type ProgramStatement = ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | ImportDeclaration | Statement | TSImportEqualsDeclaration | TSNamespaceExportDeclaration;
1501
1442
  declare type Property = PropertyComputedName | PropertyNonComputedName;
1502
1443
  declare interface PropertyBase extends BaseNode {
@@ -1549,57 +1490,6 @@ declare interface PropertyNonComputedName extends PropertyBase {
1549
1490
  computed: false;
1550
1491
  key: PropertyNameNonComputed;
1551
1492
  }
1552
- declare interface PunctuatorToken extends BaseToken {
1553
- type: AST_TOKEN_TYPES.Punctuator;
1554
- value: ValueOf<PunctuatorTokenToText>;
1555
- }
1556
- declare interface PunctuatorTokenToText extends AssignmentOperatorToText {
1557
- [SyntaxKind.AmpersandAmpersandToken]: '&&';
1558
- [SyntaxKind.AmpersandToken]: '&';
1559
- [SyntaxKind.AsteriskAsteriskToken]: '**';
1560
- [SyntaxKind.AsteriskToken]: '*';
1561
- [SyntaxKind.AtToken]: '@';
1562
- [SyntaxKind.BacktickToken]: '`';
1563
- [SyntaxKind.BarBarToken]: '||';
1564
- [SyntaxKind.BarToken]: '|';
1565
- [SyntaxKind.CaretToken]: '^';
1566
- [SyntaxKind.CloseBraceToken]: '}';
1567
- [SyntaxKind.CloseBracketToken]: ']';
1568
- [SyntaxKind.CloseParenToken]: ')';
1569
- [SyntaxKind.ColonToken]: ':';
1570
- [SyntaxKind.CommaToken]: ',';
1571
- [SyntaxKind.DotDotDotToken]: '...';
1572
- [SyntaxKind.DotToken]: '.';
1573
- [SyntaxKind.EqualsEqualsEqualsToken]: '===';
1574
- [SyntaxKind.EqualsEqualsToken]: '==';
1575
- [SyntaxKind.EqualsGreaterThanToken]: '=>';
1576
- [SyntaxKind.ExclamationEqualsEqualsToken]: '!==';
1577
- [SyntaxKind.ExclamationEqualsToken]: '!=';
1578
- [SyntaxKind.ExclamationToken]: '!';
1579
- [SyntaxKind.GreaterThanEqualsToken]: '>=';
1580
- [SyntaxKind.GreaterThanGreaterThanGreaterThanToken]: '>>>';
1581
- [SyntaxKind.GreaterThanGreaterThanToken]: '>>';
1582
- [SyntaxKind.GreaterThanToken]: '>';
1583
- [SyntaxKind.HashToken]: '#';
1584
- [SyntaxKind.LessThanEqualsToken]: '<=';
1585
- [SyntaxKind.LessThanLessThanToken]: '<<';
1586
- [SyntaxKind.LessThanSlashToken]: '</';
1587
- [SyntaxKind.LessThanToken]: '<';
1588
- [SyntaxKind.MinusMinusToken]: '--';
1589
- [SyntaxKind.MinusToken]: '-';
1590
- [SyntaxKind.OpenBraceToken]: '{';
1591
- [SyntaxKind.OpenBracketToken]: '[';
1592
- [SyntaxKind.OpenParenToken]: '(';
1593
- [SyntaxKind.PercentToken]: '%';
1594
- [SyntaxKind.PlusPlusToken]: '++';
1595
- [SyntaxKind.PlusToken]: '+';
1596
- [SyntaxKind.QuestionDotToken]: '?.';
1597
- [SyntaxKind.QuestionQuestionToken]: '??';
1598
- [SyntaxKind.QuestionToken]: '?';
1599
- [SyntaxKind.SemicolonToken]: ';';
1600
- [SyntaxKind.SlashToken]: '/';
1601
- [SyntaxKind.TildeToken]: '~';
1602
- }
1603
1493
  /**
1604
1494
  * An array of two numbers.
1605
1495
  * Both numbers are a 0-based index which is the position in the array of source code characters.
@@ -1613,13 +1503,6 @@ declare interface RegExpLiteral extends LiteralBase {
1613
1503
  };
1614
1504
  value: RegExp | null;
1615
1505
  }
1616
- declare interface RegularExpressionToken extends BaseToken {
1617
- type: AST_TOKEN_TYPES.RegularExpression;
1618
- regex: {
1619
- flags: string;
1620
- pattern: string;
1621
- };
1622
- }
1623
1506
  declare interface RestElement extends BaseNode {
1624
1507
  type: AST_NODE_TYPES.RestElement;
1625
1508
  argument: DestructuringPattern;
@@ -1658,9 +1541,6 @@ declare interface StaticBlock extends BaseNode {
1658
1541
  declare interface StringLiteral extends LiteralBase {
1659
1542
  value: string;
1660
1543
  }
1661
- declare interface StringToken extends BaseToken {
1662
- type: AST_TOKEN_TYPES.String;
1663
- }
1664
1544
  declare interface Super extends BaseNode {
1665
1545
  type: AST_NODE_TYPES.Super;
1666
1546
  }
@@ -1693,9 +1573,6 @@ declare interface TemplateLiteral extends BaseNode {
1693
1573
  expressions: Expression[];
1694
1574
  quasis: TemplateElement[];
1695
1575
  }
1696
- declare interface TemplateToken extends BaseToken {
1697
- type: AST_TOKEN_TYPES.Template;
1698
- }
1699
1576
  declare interface ThisExpression extends BaseNode {
1700
1577
  type: AST_NODE_TYPES.ThisExpression;
1701
1578
  }
@@ -1703,7 +1580,6 @@ declare interface ThrowStatement extends BaseNode {
1703
1580
  type: AST_NODE_TYPES.ThrowStatement;
1704
1581
  argument: Expression;
1705
1582
  }
1706
- declare type Token = BooleanToken | Comment | IdentifierToken | JSXIdentifierToken | JSXTextToken | KeywordToken | NullToken | NumericToken | PunctuatorToken | RegularExpressionToken | StringToken | TemplateToken;
1707
1583
  declare interface TryStatement extends BaseNode {
1708
1584
  type: AST_NODE_TYPES.TryStatement;
1709
1585
  block: BlockStatement;
@@ -2420,7 +2296,6 @@ declare interface UsingDeclarationBase extends BaseNode {
2420
2296
  */
2421
2297
  kind: 'await using' | 'using';
2422
2298
  }
2423
- declare type UsingDeclarator = UsingInForOfDeclarator | UsingInNormalContextDeclarator;
2424
2299
  declare interface UsingInForOfDeclaration extends UsingDeclarationBase {
2425
2300
  /**
2426
2301
  * The variables declared by this declaration.
@@ -2456,7 +2331,6 @@ declare interface UsingInNormalContextDeclarator extends VariableDeclaratorBase
2456
2331
  }
2457
2332
  declare type ValueOf<T> = T[keyof T];
2458
2333
  declare type VariableDeclaration = LetOrConstOrVarDeclaration | UsingDeclaration;
2459
- declare type VariableDeclarator = LetOrConstOrVarDeclarator | UsingDeclarator;
2460
2334
  declare interface VariableDeclaratorBase extends BaseNode {
2461
2335
  type: AST_NODE_TYPES.VariableDeclarator;
2462
2336
  /**
@@ -2521,69 +2395,16 @@ declare const isCreateElement: (node: Identifier | MemberExpression, context: _e
2521
2395
  declare const isCreateRef: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2522
2396
  declare const isForwardRef: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2523
2397
  declare const isMemo: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2524
- declare const isChildrenCountCall: {
2525
- (context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression & {
2526
- callee: MemberExpression;
2527
- };
2528
- (node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression & {
2529
- callee: MemberExpression;
2530
- };
2531
- };
2532
- declare const isChildrenForEachCall: {
2533
- (context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression & {
2534
- callee: MemberExpression;
2535
- };
2536
- (node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression & {
2537
- callee: MemberExpression;
2538
- };
2539
- };
2540
- declare const isChildrenMapCall: {
2541
- (context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression & {
2542
- callee: MemberExpression;
2543
- };
2544
- (node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression & {
2545
- callee: MemberExpression;
2546
- };
2547
- };
2548
- declare const isChildrenOnlyCall: {
2549
- (context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression & {
2550
- callee: MemberExpression;
2551
- };
2552
- (node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression & {
2553
- callee: MemberExpression;
2554
- };
2555
- };
2556
- declare const isChildrenToArrayCall: {
2557
- (context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression & {
2558
- callee: MemberExpression;
2559
- };
2560
- (node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression & {
2561
- callee: MemberExpression;
2562
- };
2563
- };
2564
- declare const isCloneElementCall: {
2565
- (context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression;
2566
- (node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
2567
- };
2568
- declare const isCreateContextCall: {
2569
- (context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression;
2570
- (node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
2571
- };
2572
- declare const isCreateElementCall: {
2573
- (context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression;
2574
- (node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
2575
- };
2576
- declare const isCreateRefCall: {
2577
- (context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression;
2578
- (node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
2579
- };
2580
- declare const isForwardRefCall: {
2581
- (context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression;
2582
- (node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
2583
- };
2584
- declare const isMemoCall: {
2585
- (context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression;
2586
- (node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
2587
- };
2398
+ declare const isChildrenCountCall: isCallFromReactMember.ReturnType;
2399
+ declare const isChildrenForEachCall: isCallFromReactMember.ReturnType;
2400
+ declare const isChildrenMapCall: isCallFromReactMember.ReturnType;
2401
+ declare const isChildrenOnlyCall: isCallFromReactMember.ReturnType;
2402
+ declare const isChildrenToArrayCall: isCallFromReactMember.ReturnType;
2403
+ declare const isCloneElementCall: isCallFromReact.ReturnType;
2404
+ declare const isCreateContextCall: isCallFromReact.ReturnType;
2405
+ declare const isCreateElementCall: isCallFromReact.ReturnType;
2406
+ declare const isCreateRefCall: isCallFromReact.ReturnType;
2407
+ declare const isForwardRefCall: isCallFromReact.ReturnType;
2408
+ declare const isMemoCall: isCallFromReact.ReturnType;
2588
2409
 
2589
- export { COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR, type ComponentCollectorOptions, DEFAULT_COMPONENT_HINT, type ERClassComponent, type ERComponent, ERComponentFlag, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectPhaseKind, type ERFunctionComponent, type ERHook, type ERHookKind, type ERLifecyclePhaseKind, type ERPhaseKind, ERPhaseRelevance, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDisplayNameAssignment, isComponentName, isComponentWillUnmount, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactMember, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
2410
+ export { COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR, DEFAULT_COMPONENT_HINT, type ERClassComponent, type ERComponent, ERComponentFlag, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectPhaseKind, type ERFunctionComponent, type ERHook, type ERHookKind, type ERLifecyclePhaseKind, type ERPhaseKind, ERPhaseRelevance, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDisplayNameAssignment, isComponentName, isComponentWillUnmount, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactMember, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as AST from '@eslint-react/ast';
2
+ import { _ } from '@eslint-react/eff';
2
3
  import * as _eslint_react_shared from '@eslint-react/shared';
3
4
  import { RuleContext } from '@eslint-react/shared';
4
5
  import { TSESTree } from '@typescript-eslint/types';
5
- import { _ } from '@eslint-react/eff';
6
- import { TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
6
+ import { ESLintUtils, TSESTree as TSESTree$1 } from '@typescript-eslint/utils';
7
7
  import * as birecord from 'birecord';
8
8
  import * as _typescript_eslint_utils_ts_eslint from '@typescript-eslint/utils/ts-eslint';
9
9
  import { Scope } from '@typescript-eslint/scope-manager';
@@ -76,10 +76,6 @@ interface ERClassComponent extends ERSemanticNode {
76
76
  }
77
77
  type ERComponent = ERClassComponent | ERFunctionComponent;
78
78
 
79
- interface ComponentCollectorOptions {
80
- collectDisplayName?: boolean;
81
- collectHookCalls?: boolean;
82
- }
83
79
  /**
84
80
  * Get a ctx and listeners for the rule to collect function components
85
81
  * @param context The ESLint rule context
@@ -87,49 +83,43 @@ interface ComponentCollectorOptions {
87
83
  * @param options The options to use
88
84
  * @returns The component collector
89
85
  */
90
- declare function useComponentCollector(context: RuleContext, hint?: bigint, options?: ComponentCollectorOptions): {
91
- readonly ctx: {
92
- readonly getAllComponents: (node: TSESTree.Program) => Map<string, ERFunctionComponent>;
93
- readonly getCurrentEntries: () => {
94
- key: string;
95
- node: AST.TSESTreeFunction;
96
- hookCalls: TSESTree.CallExpression[];
97
- isComponent: boolean;
98
- }[];
99
- readonly getCurrentEntry: () => {
100
- key: string;
101
- node: AST.TSESTreeFunction;
102
- hookCalls: TSESTree.CallExpression[];
103
- isComponent: boolean;
104
- } | undefined;
86
+ declare function useComponentCollector(context: RuleContext, hint?: bigint, options?: useComponentCollector.Options): useComponentCollector.ReturnType;
87
+ declare namespace useComponentCollector {
88
+ type Options = {
89
+ collectDisplayName?: boolean;
90
+ collectHookCalls?: boolean;
105
91
  };
106
- readonly listeners: {
107
- readonly "ReturnStatement[type]": (node: TSESTree.ReturnStatement) => void;
108
- readonly "CallExpression[type]:exit"?: (node: TSESTree.CallExpression) => void;
109
- readonly ":function[type]": (node: AST.TSESTreeFunction) => void;
110
- readonly ":function[type]:exit": () => {
111
- key: string;
112
- node: AST.TSESTreeFunction;
113
- hookCalls: TSESTree.CallExpression[];
114
- isComponent: boolean;
115
- } | undefined;
116
- readonly "ArrowFunctionExpression[type][body.type!='BlockStatement']": () => void;
92
+ type Entry = {
93
+ key: string;
94
+ node: AST.TSESTreeFunction;
95
+ hookCalls: TSESTree.CallExpression[];
96
+ isComponent: boolean;
117
97
  };
118
- };
98
+ type Ctx = {
99
+ getAllComponents: (node: TSESTree.Program) => Map<string, ERFunctionComponent>;
100
+ getCurrentEntries: () => Entry[];
101
+ getCurrentEntry: () => Entry | _;
102
+ };
103
+ type ReturnType = {
104
+ ctx: Ctx;
105
+ listeners: ESLintUtils.RuleListener;
106
+ };
107
+ }
119
108
 
120
109
  /**
121
110
  * Get a ctx and listeners for the rule to collect class components
122
111
  * @returns The context and listeners for the rule
123
112
  */
124
- declare function useComponentCollectorLegacy(): {
125
- readonly ctx: {
126
- readonly getAllComponents: (node: TSESTree$1.Program) => Map<string, ERClassComponent>;
113
+ declare function useComponentCollectorLegacy(): useComponentCollectorLegacy.ReturnType;
114
+ declare namespace useComponentCollectorLegacy {
115
+ type Ctx = {
116
+ getAllComponents: (node: TSESTree$1.Program) => Map<string, ERClassComponent>;
127
117
  };
128
- readonly listeners: {
129
- readonly "ClassDeclaration[type]": (node: AST.TSESTreeClass) => void;
130
- readonly "ClassExpression[type]": (node: AST.TSESTreeClass) => void;
118
+ type ReturnType = {
119
+ ctx: Ctx;
120
+ listeners: ESLintUtils.RuleListener;
131
121
  };
132
- };
122
+ }
133
123
 
134
124
  /**
135
125
  * The ESQuery selector for a component display name assignment expression
@@ -284,17 +274,21 @@ interface ERHook extends ERSemanticNode {
284
274
  hookCalls: TSESTree.CallExpression[];
285
275
  }
286
276
 
287
- declare function useHookCollector(): {
288
- readonly ctx: {
289
- readonly getAllHooks: (node: TSESTree$1.Program) => Map<string, ERHook>;
290
- readonly getCurrentHooks: () => Map<string, ERHook>;
277
+ declare function useHookCollector(): useHookCollector.ReturnType;
278
+ declare namespace useHookCollector {
279
+ type Entry = {
280
+ key: string;
281
+ node: AST.TSESTreeFunction;
282
+ isHook: boolean;
291
283
  };
292
- readonly listeners: {
293
- readonly ":function[type]": (node: AST.TSESTreeFunction) => void;
294
- readonly ":function[type]:exit": () => void;
295
- readonly "CallExpression[type]": (node: never) => void;
284
+ type Ctx = {
285
+ getAllHooks(node: TSESTree$1.Program): Map<string, ERHook>;
296
286
  };
297
- };
287
+ type ReturnType = {
288
+ ctx: Ctx;
289
+ listeners: ESLintUtils.RuleListener;
290
+ };
291
+ }
298
292
 
299
293
  type ERHookKind = "custom" | "useActionState" | "useCallback" | "useContext" | "useDebugValue" | "useDeferredValue" | "useEffect" | "useId" | "useImperativeHandle" | "useInsertionEffect" | "useLayoutEffect" | "useMemo" | "useOptimistic" | "useReducer" | "useRef" | "useState" | "useSyncExternalStore" | "useTransition";
300
294
 
@@ -346,20 +340,24 @@ declare function isFromReact(name: string): (node: TSESTree.Identifier | TSESTre
346
340
  * @returns A function that checks if a given node is a member expression of a Pragma member.
347
341
  */
348
342
  declare function isFromReactMember(memberName: string, name: string): (node: TSESTree.MemberExpression, context: RuleContext) => boolean;
349
- type IsCallFromReact = {
350
- (context: RuleContext): (node: TSESTree.Node) => node is TSESTree.CallExpression;
351
- (node: TSESTree.Node, context: RuleContext): node is TSESTree.CallExpression;
352
- };
353
- declare function isCallFromReact(name: string): IsCallFromReact;
354
- type IsCallFromReactMember = {
355
- (context: RuleContext): (node: TSESTree.Node) => node is TSESTree.CallExpression & {
356
- callee: TSESTree.MemberExpression;
343
+ declare function isCallFromReact(name: string): isCallFromReact.ReturnType;
344
+ declare namespace isCallFromReact {
345
+ type ReturnType = {
346
+ (context: RuleContext): (node: TSESTree.Node) => node is TSESTree.CallExpression;
347
+ (node: TSESTree.Node, context: RuleContext): node is TSESTree.CallExpression;
357
348
  };
358
- (node: TSESTree.Node, context: RuleContext): node is TSESTree.CallExpression & {
359
- callee: TSESTree.MemberExpression;
349
+ }
350
+ declare function isCallFromReactMember(pragmaMemberName: string, name: string): isCallFromReactMember.ReturnType;
351
+ declare namespace isCallFromReactMember {
352
+ type ReturnType = {
353
+ (context: RuleContext): (node: TSESTree.Node) => node is TSESTree.CallExpression & {
354
+ callee: TSESTree.MemberExpression;
355
+ };
356
+ (node: TSESTree.Node, context: RuleContext): node is TSESTree.CallExpression & {
357
+ callee: TSESTree.MemberExpression;
358
+ };
360
359
  };
361
- };
362
- declare function isCallFromReactMember(pragmaMemberName: string, name: string): IsCallFromReactMember;
360
+ }
363
361
 
364
362
  declare function isInitializedFromReact(name: string, importSource: string, initialScope: Scope): boolean;
365
363
 
@@ -608,21 +606,6 @@ declare enum AST_NODE_TYPES {
608
606
  TSUnknownKeyword = "TSUnknownKeyword",
609
607
  TSVoidKeyword = "TSVoidKeyword"
610
608
  }
611
- declare enum AST_TOKEN_TYPES {
612
- Boolean = "Boolean",
613
- Identifier = "Identifier",
614
- JSXIdentifier = "JSXIdentifier",
615
- JSXText = "JSXText",
616
- Keyword = "Keyword",
617
- Null = "Null",
618
- Numeric = "Numeric",
619
- Punctuator = "Punctuator",
620
- RegularExpression = "RegularExpression",
621
- String = "String",
622
- Template = "Template",
623
- Block = "Block",
624
- Line = "Line"
625
- }
626
609
  declare interface AwaitExpression extends BaseNode {
627
610
  type: AST_NODE_TYPES.AwaitExpression;
628
611
  argument: Expression;
@@ -630,10 +613,6 @@ declare interface AwaitExpression extends BaseNode {
630
613
  declare interface BaseNode extends NodeOrTokenData {
631
614
  type: AST_NODE_TYPES;
632
615
  }
633
- declare interface BaseToken extends NodeOrTokenData {
634
- type: AST_TOKEN_TYPES;
635
- value: string;
636
- }
637
616
  declare interface BigIntLiteral extends LiteralBase {
638
617
  bigint: string;
639
618
  value: bigint | null;
@@ -672,9 +651,6 @@ declare interface BinaryOperatorToText {
672
651
  }
673
652
  declare type BindingName = BindingPattern | Identifier;
674
653
  declare type BindingPattern = ArrayPattern | ObjectPattern;
675
- declare interface BlockComment extends BaseToken {
676
- type: AST_TOKEN_TYPES.Block;
677
- }
678
654
  declare interface BlockStatement extends BaseNode {
679
655
  type: AST_NODE_TYPES.BlockStatement;
680
656
  body: Statement[];
@@ -683,9 +659,6 @@ declare interface BooleanLiteral extends LiteralBase {
683
659
  raw: 'false' | 'true';
684
660
  value: boolean;
685
661
  }
686
- declare interface BooleanToken extends BaseToken {
687
- type: AST_TOKEN_TYPES.Boolean;
688
- }
689
662
  declare interface BreakStatement extends BaseNode {
690
663
  type: AST_NODE_TYPES.BreakStatement;
691
664
  label: Identifier | null;
@@ -766,7 +739,6 @@ declare interface ClassBody extends BaseNode {
766
739
  type: AST_NODE_TYPES.ClassBody;
767
740
  body: ClassElement[];
768
741
  }
769
- declare type ClassDeclaration = ClassDeclarationWithName | ClassDeclarationWithOptionalName;
770
742
  declare interface ClassDeclarationBase extends ClassBase {
771
743
  type: AST_NODE_TYPES.ClassDeclaration;
772
744
  }
@@ -803,7 +775,6 @@ declare interface ClassPropertyDefinitionNonComputedNameBase extends PropertyDef
803
775
  key: ClassPropertyNameNonComputed;
804
776
  }
805
777
  declare type ClassPropertyNameNonComputed = PrivateIdentifier | PropertyNameNonComputed;
806
- declare type Comment = BlockComment | LineComment;
807
778
  declare interface ConditionalExpression extends BaseNode {
808
779
  type: AST_NODE_TYPES.ConditionalExpression;
809
780
  alternate: Expression;
@@ -1096,7 +1067,6 @@ declare interface FunctionBase extends BaseNode {
1096
1067
  */
1097
1068
  typeParameters: TSTypeParameterDeclaration | undefined;
1098
1069
  }
1099
- declare type FunctionDeclaration = FunctionDeclarationWithName | FunctionDeclarationWithOptionalName;
1100
1070
  declare interface FunctionDeclarationBase extends FunctionBase {
1101
1071
  type: AST_NODE_TYPES.FunctionDeclaration;
1102
1072
  body: BlockStatement;
@@ -1133,9 +1103,6 @@ declare interface Identifier extends BaseNode {
1133
1103
  optional: boolean;
1134
1104
  typeAnnotation: TSTypeAnnotation | undefined;
1135
1105
  }
1136
- declare interface IdentifierToken extends BaseToken {
1137
- type: AST_TOKEN_TYPES.Identifier;
1138
- }
1139
1106
  declare interface IfStatement extends BaseNode {
1140
1107
  type: AST_NODE_TYPES.IfStatement;
1141
1108
  alternate: Statement | null;
@@ -1261,9 +1228,6 @@ declare interface JSXIdentifier extends BaseNode {
1261
1228
  type: AST_NODE_TYPES.JSXIdentifier;
1262
1229
  name: string;
1263
1230
  }
1264
- declare interface JSXIdentifierToken extends BaseToken {
1265
- type: AST_TOKEN_TYPES.JSXIdentifier;
1266
- }
1267
1231
  declare interface JSXMemberExpression extends BaseNode {
1268
1232
  type: AST_NODE_TYPES.JSXMemberExpression;
1269
1233
  object: JSXTagNameExpression;
@@ -1298,12 +1262,6 @@ declare interface JSXText extends BaseNode {
1298
1262
  raw: string;
1299
1263
  value: string;
1300
1264
  }
1301
- declare interface JSXTextToken extends BaseToken {
1302
- type: AST_TOKEN_TYPES.JSXText;
1303
- }
1304
- declare interface KeywordToken extends BaseToken {
1305
- type: AST_TOKEN_TYPES.Keyword;
1306
- }
1307
1265
  declare interface LabeledStatement extends BaseNode {
1308
1266
  type: AST_NODE_TYPES.LabeledStatement;
1309
1267
  body: Statement;
@@ -1367,9 +1325,6 @@ declare interface LetOrVarNonDeclaredDeclaration extends LetOrConstOrVarDeclarat
1367
1325
  declare: false;
1368
1326
  kind: 'let' | 'var';
1369
1327
  }
1370
- declare interface LineComment extends BaseToken {
1371
- type: AST_TOKEN_TYPES.Line;
1372
- }
1373
1328
  declare type Literal = BigIntLiteral | BooleanLiteral | NullLiteral | NumberLiteral | RegExpLiteral | StringLiteral;
1374
1329
  declare interface LiteralBase extends BaseNode {
1375
1330
  type: AST_NODE_TYPES.Literal;
@@ -1439,7 +1394,6 @@ declare interface NewExpression extends BaseNode {
1439
1394
  callee: Expression;
1440
1395
  typeArguments: TSTypeParameterInstantiation | undefined;
1441
1396
  }
1442
- declare type Node = AccessorProperty | ArrayExpression | ArrayPattern | ArrowFunctionExpression | AssignmentExpression | AssignmentPattern | AwaitExpression | BinaryExpression | BlockStatement | BreakStatement | CallExpression | CatchClause | ChainExpression | ClassBody | ClassDeclaration | ClassExpression | ConditionalExpression | ContinueStatement | DebuggerStatement | Decorator | DoWhileStatement | EmptyStatement | ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | ExportSpecifier | ExpressionStatement | ForInStatement | ForOfStatement | ForStatement | FunctionDeclaration | FunctionExpression | Identifier | IfStatement | ImportAttribute | ImportDeclaration | ImportDefaultSpecifier | ImportExpression | ImportNamespaceSpecifier | ImportSpecifier | JSXAttribute | JSXClosingElement | JSXClosingFragment | JSXElement | JSXEmptyExpression | JSXExpressionContainer | JSXFragment | JSXIdentifier | JSXMemberExpression | JSXNamespacedName | JSXOpeningElement | JSXOpeningFragment | JSXSpreadAttribute | JSXSpreadChild | JSXText | LabeledStatement | Literal | LogicalExpression | MemberExpression | MetaProperty | MethodDefinition | NewExpression | ObjectExpression | ObjectPattern | PrivateIdentifier | Program | Property | PropertyDefinition | RestElement | ReturnStatement | SequenceExpression | SpreadElement | StaticBlock | Super | SwitchCase | SwitchStatement | TaggedTemplateExpression | TemplateElement | TemplateLiteral | ThisExpression | ThrowStatement | TryStatement | TSAbstractAccessorProperty | TSAbstractKeyword | TSAbstractMethodDefinition | TSAbstractPropertyDefinition | TSAnyKeyword | TSArrayType | TSAsExpression | TSAsyncKeyword | TSBigIntKeyword | TSBooleanKeyword | TSCallSignatureDeclaration | TSClassImplements | TSConditionalType | TSConstructorType | TSConstructSignatureDeclaration | TSDeclareFunction | TSDeclareKeyword | TSEmptyBodyFunctionExpression | TSEnumBody | TSEnumDeclaration | TSEnumMember | TSExportAssignment | TSExportKeyword | TSExternalModuleReference | TSFunctionType | TSImportEqualsDeclaration | TSImportType | TSIndexedAccessType | TSIndexSignature | TSInferType | TSInstantiationExpression | TSInterfaceBody | TSInterfaceDeclaration | TSInterfaceHeritage | TSIntersectionType | TSIntrinsicKeyword | TSLiteralType | TSMappedType | TSMethodSignature | TSModuleBlock | TSModuleDeclaration | TSNamedTupleMember | TSNamespaceExportDeclaration | TSNeverKeyword | TSNonNullExpression | TSNullKeyword | TSNumberKeyword | TSObjectKeyword | TSOptionalType | TSParameterProperty | TSPrivateKeyword | TSPropertySignature | TSProtectedKeyword | TSPublicKeyword | TSQualifiedName | TSReadonlyKeyword | TSRestType | TSSatisfiesExpression | TSStaticKeyword | TSStringKeyword | TSSymbolKeyword | TSTemplateLiteralType | TSThisType | TSTupleType | TSTypeAliasDeclaration | TSTypeAnnotation | TSTypeAssertion | TSTypeLiteral | TSTypeOperator | TSTypeParameter | TSTypeParameterDeclaration | TSTypeParameterInstantiation | TSTypePredicate | TSTypeQuery | TSTypeReference | TSUndefinedKeyword | TSUnionType | TSUnknownKeyword | TSVoidKeyword | UnaryExpression | UpdateExpression | VariableDeclaration | VariableDeclarator | WhileStatement | WithStatement | YieldExpression;
1443
1397
  declare interface NodeOrTokenData {
1444
1398
  type: string;
1445
1399
  /**
@@ -1454,15 +1408,9 @@ declare interface NullLiteral extends LiteralBase {
1454
1408
  raw: 'null';
1455
1409
  value: null;
1456
1410
  }
1457
- declare interface NullToken extends BaseToken {
1458
- type: AST_TOKEN_TYPES.Null;
1459
- }
1460
1411
  declare interface NumberLiteral extends LiteralBase {
1461
1412
  value: number;
1462
1413
  }
1463
- declare interface NumericToken extends BaseToken {
1464
- type: AST_TOKEN_TYPES.Numeric;
1465
- }
1466
1414
  declare interface ObjectExpression extends BaseNode {
1467
1415
  type: AST_NODE_TYPES.ObjectExpression;
1468
1416
  properties: ObjectLiteralElement[];
@@ -1490,13 +1438,6 @@ declare interface PrivateIdentifier extends BaseNode {
1490
1438
  type: AST_NODE_TYPES.PrivateIdentifier;
1491
1439
  name: string;
1492
1440
  }
1493
- declare interface Program extends NodeOrTokenData {
1494
- type: AST_NODE_TYPES.Program;
1495
- body: ProgramStatement[];
1496
- comments: Comment[] | undefined;
1497
- sourceType: 'module' | 'script';
1498
- tokens: Token[] | undefined;
1499
- }
1500
1441
  declare type ProgramStatement = ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | ImportDeclaration | Statement | TSImportEqualsDeclaration | TSNamespaceExportDeclaration;
1501
1442
  declare type Property = PropertyComputedName | PropertyNonComputedName;
1502
1443
  declare interface PropertyBase extends BaseNode {
@@ -1549,57 +1490,6 @@ declare interface PropertyNonComputedName extends PropertyBase {
1549
1490
  computed: false;
1550
1491
  key: PropertyNameNonComputed;
1551
1492
  }
1552
- declare interface PunctuatorToken extends BaseToken {
1553
- type: AST_TOKEN_TYPES.Punctuator;
1554
- value: ValueOf<PunctuatorTokenToText>;
1555
- }
1556
- declare interface PunctuatorTokenToText extends AssignmentOperatorToText {
1557
- [SyntaxKind.AmpersandAmpersandToken]: '&&';
1558
- [SyntaxKind.AmpersandToken]: '&';
1559
- [SyntaxKind.AsteriskAsteriskToken]: '**';
1560
- [SyntaxKind.AsteriskToken]: '*';
1561
- [SyntaxKind.AtToken]: '@';
1562
- [SyntaxKind.BacktickToken]: '`';
1563
- [SyntaxKind.BarBarToken]: '||';
1564
- [SyntaxKind.BarToken]: '|';
1565
- [SyntaxKind.CaretToken]: '^';
1566
- [SyntaxKind.CloseBraceToken]: '}';
1567
- [SyntaxKind.CloseBracketToken]: ']';
1568
- [SyntaxKind.CloseParenToken]: ')';
1569
- [SyntaxKind.ColonToken]: ':';
1570
- [SyntaxKind.CommaToken]: ',';
1571
- [SyntaxKind.DotDotDotToken]: '...';
1572
- [SyntaxKind.DotToken]: '.';
1573
- [SyntaxKind.EqualsEqualsEqualsToken]: '===';
1574
- [SyntaxKind.EqualsEqualsToken]: '==';
1575
- [SyntaxKind.EqualsGreaterThanToken]: '=>';
1576
- [SyntaxKind.ExclamationEqualsEqualsToken]: '!==';
1577
- [SyntaxKind.ExclamationEqualsToken]: '!=';
1578
- [SyntaxKind.ExclamationToken]: '!';
1579
- [SyntaxKind.GreaterThanEqualsToken]: '>=';
1580
- [SyntaxKind.GreaterThanGreaterThanGreaterThanToken]: '>>>';
1581
- [SyntaxKind.GreaterThanGreaterThanToken]: '>>';
1582
- [SyntaxKind.GreaterThanToken]: '>';
1583
- [SyntaxKind.HashToken]: '#';
1584
- [SyntaxKind.LessThanEqualsToken]: '<=';
1585
- [SyntaxKind.LessThanLessThanToken]: '<<';
1586
- [SyntaxKind.LessThanSlashToken]: '</';
1587
- [SyntaxKind.LessThanToken]: '<';
1588
- [SyntaxKind.MinusMinusToken]: '--';
1589
- [SyntaxKind.MinusToken]: '-';
1590
- [SyntaxKind.OpenBraceToken]: '{';
1591
- [SyntaxKind.OpenBracketToken]: '[';
1592
- [SyntaxKind.OpenParenToken]: '(';
1593
- [SyntaxKind.PercentToken]: '%';
1594
- [SyntaxKind.PlusPlusToken]: '++';
1595
- [SyntaxKind.PlusToken]: '+';
1596
- [SyntaxKind.QuestionDotToken]: '?.';
1597
- [SyntaxKind.QuestionQuestionToken]: '??';
1598
- [SyntaxKind.QuestionToken]: '?';
1599
- [SyntaxKind.SemicolonToken]: ';';
1600
- [SyntaxKind.SlashToken]: '/';
1601
- [SyntaxKind.TildeToken]: '~';
1602
- }
1603
1493
  /**
1604
1494
  * An array of two numbers.
1605
1495
  * Both numbers are a 0-based index which is the position in the array of source code characters.
@@ -1613,13 +1503,6 @@ declare interface RegExpLiteral extends LiteralBase {
1613
1503
  };
1614
1504
  value: RegExp | null;
1615
1505
  }
1616
- declare interface RegularExpressionToken extends BaseToken {
1617
- type: AST_TOKEN_TYPES.RegularExpression;
1618
- regex: {
1619
- flags: string;
1620
- pattern: string;
1621
- };
1622
- }
1623
1506
  declare interface RestElement extends BaseNode {
1624
1507
  type: AST_NODE_TYPES.RestElement;
1625
1508
  argument: DestructuringPattern;
@@ -1658,9 +1541,6 @@ declare interface StaticBlock extends BaseNode {
1658
1541
  declare interface StringLiteral extends LiteralBase {
1659
1542
  value: string;
1660
1543
  }
1661
- declare interface StringToken extends BaseToken {
1662
- type: AST_TOKEN_TYPES.String;
1663
- }
1664
1544
  declare interface Super extends BaseNode {
1665
1545
  type: AST_NODE_TYPES.Super;
1666
1546
  }
@@ -1693,9 +1573,6 @@ declare interface TemplateLiteral extends BaseNode {
1693
1573
  expressions: Expression[];
1694
1574
  quasis: TemplateElement[];
1695
1575
  }
1696
- declare interface TemplateToken extends BaseToken {
1697
- type: AST_TOKEN_TYPES.Template;
1698
- }
1699
1576
  declare interface ThisExpression extends BaseNode {
1700
1577
  type: AST_NODE_TYPES.ThisExpression;
1701
1578
  }
@@ -1703,7 +1580,6 @@ declare interface ThrowStatement extends BaseNode {
1703
1580
  type: AST_NODE_TYPES.ThrowStatement;
1704
1581
  argument: Expression;
1705
1582
  }
1706
- declare type Token = BooleanToken | Comment | IdentifierToken | JSXIdentifierToken | JSXTextToken | KeywordToken | NullToken | NumericToken | PunctuatorToken | RegularExpressionToken | StringToken | TemplateToken;
1707
1583
  declare interface TryStatement extends BaseNode {
1708
1584
  type: AST_NODE_TYPES.TryStatement;
1709
1585
  block: BlockStatement;
@@ -2420,7 +2296,6 @@ declare interface UsingDeclarationBase extends BaseNode {
2420
2296
  */
2421
2297
  kind: 'await using' | 'using';
2422
2298
  }
2423
- declare type UsingDeclarator = UsingInForOfDeclarator | UsingInNormalContextDeclarator;
2424
2299
  declare interface UsingInForOfDeclaration extends UsingDeclarationBase {
2425
2300
  /**
2426
2301
  * The variables declared by this declaration.
@@ -2456,7 +2331,6 @@ declare interface UsingInNormalContextDeclarator extends VariableDeclaratorBase
2456
2331
  }
2457
2332
  declare type ValueOf<T> = T[keyof T];
2458
2333
  declare type VariableDeclaration = LetOrConstOrVarDeclaration | UsingDeclaration;
2459
- declare type VariableDeclarator = LetOrConstOrVarDeclarator | UsingDeclarator;
2460
2334
  declare interface VariableDeclaratorBase extends BaseNode {
2461
2335
  type: AST_NODE_TYPES.VariableDeclarator;
2462
2336
  /**
@@ -2521,69 +2395,16 @@ declare const isCreateElement: (node: Identifier | MemberExpression, context: _e
2521
2395
  declare const isCreateRef: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2522
2396
  declare const isForwardRef: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2523
2397
  declare const isMemo: (node: Identifier | MemberExpression, context: _eslint_react_shared.RuleContext) => boolean;
2524
- declare const isChildrenCountCall: {
2525
- (context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression & {
2526
- callee: MemberExpression;
2527
- };
2528
- (node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression & {
2529
- callee: MemberExpression;
2530
- };
2531
- };
2532
- declare const isChildrenForEachCall: {
2533
- (context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression & {
2534
- callee: MemberExpression;
2535
- };
2536
- (node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression & {
2537
- callee: MemberExpression;
2538
- };
2539
- };
2540
- declare const isChildrenMapCall: {
2541
- (context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression & {
2542
- callee: MemberExpression;
2543
- };
2544
- (node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression & {
2545
- callee: MemberExpression;
2546
- };
2547
- };
2548
- declare const isChildrenOnlyCall: {
2549
- (context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression & {
2550
- callee: MemberExpression;
2551
- };
2552
- (node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression & {
2553
- callee: MemberExpression;
2554
- };
2555
- };
2556
- declare const isChildrenToArrayCall: {
2557
- (context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression & {
2558
- callee: MemberExpression;
2559
- };
2560
- (node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression & {
2561
- callee: MemberExpression;
2562
- };
2563
- };
2564
- declare const isCloneElementCall: {
2565
- (context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression;
2566
- (node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
2567
- };
2568
- declare const isCreateContextCall: {
2569
- (context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression;
2570
- (node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
2571
- };
2572
- declare const isCreateElementCall: {
2573
- (context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression;
2574
- (node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
2575
- };
2576
- declare const isCreateRefCall: {
2577
- (context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression;
2578
- (node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
2579
- };
2580
- declare const isForwardRefCall: {
2581
- (context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression;
2582
- (node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
2583
- };
2584
- declare const isMemoCall: {
2585
- (context: _eslint_react_shared.RuleContext): (node: Node) => node is CallExpression;
2586
- (node: Node, context: _eslint_react_shared.RuleContext): node is CallExpression;
2587
- };
2398
+ declare const isChildrenCountCall: isCallFromReactMember.ReturnType;
2399
+ declare const isChildrenForEachCall: isCallFromReactMember.ReturnType;
2400
+ declare const isChildrenMapCall: isCallFromReactMember.ReturnType;
2401
+ declare const isChildrenOnlyCall: isCallFromReactMember.ReturnType;
2402
+ declare const isChildrenToArrayCall: isCallFromReactMember.ReturnType;
2403
+ declare const isCloneElementCall: isCallFromReact.ReturnType;
2404
+ declare const isCreateContextCall: isCallFromReact.ReturnType;
2405
+ declare const isCreateElementCall: isCallFromReact.ReturnType;
2406
+ declare const isCreateRefCall: isCallFromReact.ReturnType;
2407
+ declare const isForwardRefCall: isCallFromReact.ReturnType;
2408
+ declare const isMemoCall: isCallFromReact.ReturnType;
2588
2409
 
2589
- export { COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR, type ComponentCollectorOptions, DEFAULT_COMPONENT_HINT, type ERClassComponent, type ERComponent, ERComponentFlag, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectPhaseKind, type ERFunctionComponent, type ERHook, type ERHookKind, type ERLifecyclePhaseKind, type ERPhaseKind, ERPhaseRelevance, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDisplayNameAssignment, isComponentName, isComponentWillUnmount, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactMember, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
2410
+ export { COMPONENT_DISPLAY_NAME_ASSIGNMENT_SELECTOR, DEFAULT_COMPONENT_HINT, type ERClassComponent, type ERComponent, ERComponentFlag, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectPhaseKind, type ERFunctionComponent, type ERHook, type ERHookKind, type ERLifecyclePhaseKind, type ERPhaseKind, ERPhaseRelevance, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCloneElement, isCloneElementCall, isComponentDidCatch, isComponentDidMount, isComponentDisplayNameAssignment, isComponentName, isComponentWillUnmount, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFromReact, isFromReactMember, isFunctionOfComponentDidMount, isFunctionOfComponentWillUnmount, isFunctionOfRenderMethod, isFunctionOfUseEffectCleanup, isFunctionOfUseEffectSetup, isGetDerivedStateFromError, isGetDerivedStateFromProps, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderMethodLike, isRenderPropLoose, isThisSetState, isUseCallbackCall, isUseContextCall, isUseDebugValueCall, isUseDeferredValueCall, isUseEffectCall, isUseEffectCallLoose, isUseIdCall, isUseImperativeHandleCall, isUseInsertionEffectCall, isUseLayoutEffectCall, isUseMemoCall, isUseReducerCall, isUseRefCall, isUseStateCall, isUseSyncExternalStoreCall, isUseTransitionCall, useComponentCollector, useComponentCollectorLegacy, useHookCollector };
package/dist/index.js CHANGED
@@ -265,13 +265,13 @@ function isInsideReactHook(node) {
265
265
  }
266
266
  function useHookCollector() {
267
267
  const hooks = /* @__PURE__ */ new Map();
268
- const fEntries = [];
268
+ const functionEntries = [];
269
269
  const onFunctionEnter = (node) => {
270
270
  const id = AST8__namespace.getFunctionIdentifier(node);
271
+ const key = shared.getId();
271
272
  const name = id?.name;
272
273
  if (name != null && isReactHookName(name)) {
273
- const key = shared.getId();
274
- fEntries.push({ key, node });
274
+ functionEntries.push({ key, node, isHook: true });
275
275
  hooks.set(key, {
276
276
  id,
277
277
  key,
@@ -284,18 +284,15 @@ function useHookCollector() {
284
284
  });
285
285
  return;
286
286
  }
287
- fEntries.push({ key: eff._, node });
287
+ functionEntries.push({ key, node, isHook: false });
288
288
  };
289
289
  const onFunctionExit = () => {
290
- fEntries.pop();
290
+ functionEntries.pop();
291
291
  };
292
292
  const ctx = {
293
293
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
294
294
  getAllHooks(node) {
295
295
  return hooks;
296
- },
297
- getCurrentHooks() {
298
- return new Map(hooks);
299
296
  }
300
297
  };
301
298
  const listeners = {
@@ -305,7 +302,7 @@ function useHookCollector() {
305
302
  if (!isReactHookCall(node)) {
306
303
  return;
307
304
  }
308
- const fEntry = fEntries.at(-1);
305
+ const fEntry = functionEntries.at(-1);
309
306
  if (fEntry?.key == null) {
310
307
  return;
311
308
  }
@@ -502,9 +499,7 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
502
499
  const onFunctionExit = () => {
503
500
  const entry = functionEntries.at(-1);
504
501
  if (entry == null) return;
505
- if (!entry.isComponent) {
506
- return functionEntries.pop();
507
- }
502
+ if (!entry.isComponent) return functionEntries.pop();
508
503
  const shouldDrop = AST8__namespace.getNestedReturnStatements(entry.node.body).slice().reverse().some((r) => {
509
504
  return context.sourceCode.getScope(r).block === entry.node && r.argument != null && !JSX3__namespace.isJSXValue(r.argument, jsxCtx, hint);
510
505
  });
@@ -528,14 +523,10 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
528
523
  ":function[type]:exit": onFunctionExit,
529
524
  "ArrowFunctionExpression[type][body.type!='BlockStatement']"() {
530
525
  const entry = getCurrentEntry();
531
- if (entry == null) {
532
- return;
533
- }
526
+ if (entry == null) return;
534
527
  const { body } = entry.node;
535
528
  const isComponent = hasNoneOrValidComponentName(entry.node, context) && JSX3__namespace.isJSXValue(body, jsxCtx, hint) && hasValidHierarchy(entry.node, context, hint);
536
- if (!isComponent) {
537
- return;
538
- }
529
+ if (!isComponent) return;
539
530
  const initPath = AST8__namespace.getFunctionInitPath(entry.node);
540
531
  const id = getFunctionComponentIdentifier(entry.node, context);
541
532
  const name = getComponentNameFromIdentifier(id);
@@ -559,35 +550,24 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
559
550
  if (left.type !== types.AST_NODE_TYPES.MemberExpression) return;
560
551
  const componentName = left.object.type === types.AST_NODE_TYPES.Identifier ? left.object.name : eff._;
561
552
  const component = [...components.values()].findLast(({ name }) => name != null && name === componentName);
562
- if (component == null) {
563
- return;
564
- }
553
+ if (component == null) return;
565
554
  component.displayName = right;
566
555
  }
567
556
  } : {},
568
557
  ...collectHookCalls ? {
569
558
  "CallExpression[type]:exit"(node) {
570
- if (!isReactHookCall(node)) {
571
- return;
572
- }
559
+ if (!isReactHookCall(node)) return;
573
560
  const entry = getCurrentEntry();
574
- if (entry == null) {
575
- return;
576
- }
561
+ if (entry == null) return;
577
562
  entry.hookCalls.push(node);
578
563
  }
579
564
  } : {},
580
565
  "ReturnStatement[type]"(node) {
581
566
  const entry = getCurrentEntry();
582
- if (entry == null) {
583
- return;
584
- }
567
+ if (entry == null) return;
585
568
  const isComponent = hasNoneOrValidComponentName(entry.node, context) && JSX3__namespace.isJSXValue(node.argument, jsxCtx, hint) && hasValidHierarchy(entry.node, context, hint);
586
- if (!isComponent) {
587
- return;
588
- }
589
- functionEntries.pop();
590
- functionEntries.push({ ...entry, isComponent });
569
+ if (!isComponent) return;
570
+ entry.isComponent = true;
591
571
  const initPath = AST8__namespace.getFunctionInitPath(entry.node);
592
572
  const id = getFunctionComponentIdentifier(entry.node, context);
593
573
  const name = getComponentNameFromIdentifier(id);
package/dist/index.mjs CHANGED
@@ -238,13 +238,13 @@ function isInsideReactHook(node) {
238
238
  }
239
239
  function useHookCollector() {
240
240
  const hooks = /* @__PURE__ */ new Map();
241
- const fEntries = [];
241
+ const functionEntries = [];
242
242
  const onFunctionEnter = (node) => {
243
243
  const id = AST8.getFunctionIdentifier(node);
244
+ const key = getId();
244
245
  const name = id?.name;
245
246
  if (name != null && isReactHookName(name)) {
246
- const key = getId();
247
- fEntries.push({ key, node });
247
+ functionEntries.push({ key, node, isHook: true });
248
248
  hooks.set(key, {
249
249
  id,
250
250
  key,
@@ -257,18 +257,15 @@ function useHookCollector() {
257
257
  });
258
258
  return;
259
259
  }
260
- fEntries.push({ key: _, node });
260
+ functionEntries.push({ key, node, isHook: false });
261
261
  };
262
262
  const onFunctionExit = () => {
263
- fEntries.pop();
263
+ functionEntries.pop();
264
264
  };
265
265
  const ctx = {
266
266
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
267
267
  getAllHooks(node) {
268
268
  return hooks;
269
- },
270
- getCurrentHooks() {
271
- return new Map(hooks);
272
269
  }
273
270
  };
274
271
  const listeners = {
@@ -278,7 +275,7 @@ function useHookCollector() {
278
275
  if (!isReactHookCall(node)) {
279
276
  return;
280
277
  }
281
- const fEntry = fEntries.at(-1);
278
+ const fEntry = functionEntries.at(-1);
282
279
  if (fEntry?.key == null) {
283
280
  return;
284
281
  }
@@ -475,9 +472,7 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
475
472
  const onFunctionExit = () => {
476
473
  const entry = functionEntries.at(-1);
477
474
  if (entry == null) return;
478
- if (!entry.isComponent) {
479
- return functionEntries.pop();
480
- }
475
+ if (!entry.isComponent) return functionEntries.pop();
481
476
  const shouldDrop = AST8.getNestedReturnStatements(entry.node.body).slice().reverse().some((r) => {
482
477
  return context.sourceCode.getScope(r).block === entry.node && r.argument != null && !JSX3.isJSXValue(r.argument, jsxCtx, hint);
483
478
  });
@@ -501,14 +496,10 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
501
496
  ":function[type]:exit": onFunctionExit,
502
497
  "ArrowFunctionExpression[type][body.type!='BlockStatement']"() {
503
498
  const entry = getCurrentEntry();
504
- if (entry == null) {
505
- return;
506
- }
499
+ if (entry == null) return;
507
500
  const { body } = entry.node;
508
501
  const isComponent = hasNoneOrValidComponentName(entry.node, context) && JSX3.isJSXValue(body, jsxCtx, hint) && hasValidHierarchy(entry.node, context, hint);
509
- if (!isComponent) {
510
- return;
511
- }
502
+ if (!isComponent) return;
512
503
  const initPath = AST8.getFunctionInitPath(entry.node);
513
504
  const id = getFunctionComponentIdentifier(entry.node, context);
514
505
  const name = getComponentNameFromIdentifier(id);
@@ -532,35 +523,24 @@ function useComponentCollector(context, hint = DEFAULT_COMPONENT_HINT, options =
532
523
  if (left.type !== AST_NODE_TYPES.MemberExpression) return;
533
524
  const componentName = left.object.type === AST_NODE_TYPES.Identifier ? left.object.name : _;
534
525
  const component = [...components.values()].findLast(({ name }) => name != null && name === componentName);
535
- if (component == null) {
536
- return;
537
- }
526
+ if (component == null) return;
538
527
  component.displayName = right;
539
528
  }
540
529
  } : {},
541
530
  ...collectHookCalls ? {
542
531
  "CallExpression[type]:exit"(node) {
543
- if (!isReactHookCall(node)) {
544
- return;
545
- }
532
+ if (!isReactHookCall(node)) return;
546
533
  const entry = getCurrentEntry();
547
- if (entry == null) {
548
- return;
549
- }
534
+ if (entry == null) return;
550
535
  entry.hookCalls.push(node);
551
536
  }
552
537
  } : {},
553
538
  "ReturnStatement[type]"(node) {
554
539
  const entry = getCurrentEntry();
555
- if (entry == null) {
556
- return;
557
- }
540
+ if (entry == null) return;
558
541
  const isComponent = hasNoneOrValidComponentName(entry.node, context) && JSX3.isJSXValue(node.argument, jsxCtx, hint) && hasValidHierarchy(entry.node, context, hint);
559
- if (!isComponent) {
560
- return;
561
- }
562
- functionEntries.pop();
563
- functionEntries.push({ ...entry, isComponent });
542
+ if (!isComponent) return;
543
+ entry.isComponent = true;
564
544
  const initPath = AST8.getFunctionInitPath(entry.node);
565
545
  const id = getFunctionComponentIdentifier(entry.node, context);
566
546
  const name = getComponentNameFromIdentifier(id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "1.24.2-next.0",
3
+ "version": "1.24.2-next.1",
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": {
@@ -39,14 +39,14 @@
39
39
  "@typescript-eslint/utils": "^8.21.0",
40
40
  "birecord": "^0.1.1",
41
41
  "ts-pattern": "^5.6.2",
42
- "@eslint-react/ast": "1.24.2-next.0",
43
- "@eslint-react/jsx": "1.24.2-next.0",
44
- "@eslint-react/shared": "1.24.2-next.0",
45
- "@eslint-react/var": "1.24.2-next.0",
46
- "@eslint-react/eff": "1.24.2-next.0"
42
+ "@eslint-react/ast": "1.24.2-next.1",
43
+ "@eslint-react/eff": "1.24.2-next.1",
44
+ "@eslint-react/jsx": "1.24.2-next.1",
45
+ "@eslint-react/shared": "1.24.2-next.1",
46
+ "@eslint-react/var": "1.24.2-next.1"
47
47
  },
48
48
  "devDependencies": {
49
- "tsup": "^8.3.5",
49
+ "tsup": "^8.3.6",
50
50
  "@workspace/configs": "0.0.0"
51
51
  },
52
52
  "engines": {