@eslint-react/core 1.22.2-next.10 → 1.22.2-next.11

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
@@ -160,12 +160,18 @@ declare function isCleanupFunction(node: TSESTree.Node): boolean;
160
160
  declare function getElementRepresentName(node: TSESTree.JSXOpeningElement, context: RuleContext): string;
161
161
 
162
162
  /**
163
- * Determines whether inside createElement's props.
163
+ * Determines whether inside `createElement`'s props.
164
164
  * @param node The AST node to check
165
165
  * @param context The rule context
166
166
  * @returns `true` if the node is inside createElement's props
167
167
  */
168
168
  declare function isInsideCreateElementProps(node: TSESTree.Node, context: RuleContext): boolean;
169
+ /**
170
+ * Determines whether inside `createElement`'s children.
171
+ * @param node The AST node to check
172
+ * @param context The rule context
173
+ * @returns `true` if the node is inside createElement's children
174
+ */
169
175
  declare function isChildrenOfCreateElement(node: TSESTree.Node, context: RuleContext): boolean;
170
176
 
171
177
  /**
@@ -316,8 +322,20 @@ declare function isFromReact(name: string): (node: TSESTree.Identifier | TSESTre
316
322
  * @returns A function that checks if a given node is a member expression of a Pragma member.
317
323
  */
318
324
  declare function isFromReactMember(memberName: string, name: string): (node: TSESTree.MemberExpression, context: RuleContext) => boolean;
319
- declare function isCallFromReact(name: string): (node: TSESTree.CallExpression, context: RuleContext) => boolean;
320
- declare function isCallFromReactMember(pragmaMemberName: string, name: string): (node: TSESTree.CallExpression, context: RuleContext) => boolean;
325
+ type IsCallFromReact = {
326
+ (context: RuleContext): (node: TSESTree.Node) => node is TSESTree.CallExpression;
327
+ (node: TSESTree.Node, context: RuleContext): node is TSESTree.CallExpression;
328
+ };
329
+ declare function isCallFromReact(name: string): IsCallFromReact;
330
+ type IsCallFromReactMember = {
331
+ (context: RuleContext): (node: TSESTree.Node) => node is TSESTree.CallExpression & {
332
+ callee: TSESTree.MemberExpression;
333
+ };
334
+ (node: TSESTree.Node, context: RuleContext): node is TSESTree.CallExpression & {
335
+ callee: TSESTree.MemberExpression;
336
+ };
337
+ };
338
+ declare function isCallFromReactMember(pragmaMemberName: string, name: string): IsCallFromReactMember;
321
339
 
322
340
  /**
323
341
  * Check if an identifier is initialized from React
@@ -573,6 +591,21 @@ declare enum AST_NODE_TYPES {
573
591
  TSUnknownKeyword = "TSUnknownKeyword",
574
592
  TSVoidKeyword = "TSVoidKeyword"
575
593
  }
594
+ declare enum AST_TOKEN_TYPES {
595
+ Boolean = "Boolean",
596
+ Identifier = "Identifier",
597
+ JSXIdentifier = "JSXIdentifier",
598
+ JSXText = "JSXText",
599
+ Keyword = "Keyword",
600
+ Null = "Null",
601
+ Numeric = "Numeric",
602
+ Punctuator = "Punctuator",
603
+ RegularExpression = "RegularExpression",
604
+ String = "String",
605
+ Template = "Template",
606
+ Block = "Block",
607
+ Line = "Line"
608
+ }
576
609
  declare interface AwaitExpression extends BaseNode {
577
610
  type: AST_NODE_TYPES.AwaitExpression;
578
611
  argument: Expression;
@@ -580,6 +613,10 @@ declare interface AwaitExpression extends BaseNode {
580
613
  declare interface BaseNode extends NodeOrTokenData {
581
614
  type: AST_NODE_TYPES;
582
615
  }
616
+ declare interface BaseToken extends NodeOrTokenData {
617
+ type: AST_TOKEN_TYPES;
618
+ value: string;
619
+ }
583
620
  declare interface BigIntLiteral extends LiteralBase {
584
621
  bigint: string;
585
622
  value: bigint | null;
@@ -618,6 +655,9 @@ declare interface BinaryOperatorToText {
618
655
  }
619
656
  declare type BindingName = BindingPattern | Identifier;
620
657
  declare type BindingPattern = ArrayPattern | ObjectPattern;
658
+ declare interface BlockComment extends BaseToken {
659
+ type: AST_TOKEN_TYPES.Block;
660
+ }
621
661
  declare interface BlockStatement extends BaseNode {
622
662
  type: AST_NODE_TYPES.BlockStatement;
623
663
  body: Statement[];
@@ -626,6 +666,9 @@ declare interface BooleanLiteral extends LiteralBase {
626
666
  raw: 'false' | 'true';
627
667
  value: boolean;
628
668
  }
669
+ declare interface BooleanToken extends BaseToken {
670
+ type: AST_TOKEN_TYPES.Boolean;
671
+ }
629
672
  declare interface BreakStatement extends BaseNode {
630
673
  type: AST_NODE_TYPES.BreakStatement;
631
674
  label: Identifier | null;
@@ -706,6 +749,7 @@ declare interface ClassBody extends BaseNode {
706
749
  type: AST_NODE_TYPES.ClassBody;
707
750
  body: ClassElement[];
708
751
  }
752
+ declare type ClassDeclaration = ClassDeclarationWithName | ClassDeclarationWithOptionalName;
709
753
  declare interface ClassDeclarationBase extends ClassBase {
710
754
  type: AST_NODE_TYPES.ClassDeclaration;
711
755
  }
@@ -742,6 +786,7 @@ declare interface ClassPropertyDefinitionNonComputedNameBase extends PropertyDef
742
786
  key: ClassPropertyNameNonComputed;
743
787
  }
744
788
  declare type ClassPropertyNameNonComputed = PrivateIdentifier | PropertyNameNonComputed;
789
+ declare type Comment = BlockComment | LineComment;
745
790
  declare interface ConditionalExpression extends BaseNode {
746
791
  type: AST_NODE_TYPES.ConditionalExpression;
747
792
  alternate: Expression;
@@ -1034,6 +1079,7 @@ declare interface FunctionBase extends BaseNode {
1034
1079
  */
1035
1080
  typeParameters: TSTypeParameterDeclaration | undefined;
1036
1081
  }
1082
+ declare type FunctionDeclaration = FunctionDeclarationWithName | FunctionDeclarationWithOptionalName;
1037
1083
  declare interface FunctionDeclarationBase extends FunctionBase {
1038
1084
  type: AST_NODE_TYPES.FunctionDeclaration;
1039
1085
  body: BlockStatement;
@@ -1070,6 +1116,9 @@ declare interface Identifier extends BaseNode {
1070
1116
  optional: boolean;
1071
1117
  typeAnnotation: TSTypeAnnotation | undefined;
1072
1118
  }
1119
+ declare interface IdentifierToken extends BaseToken {
1120
+ type: AST_TOKEN_TYPES.Identifier;
1121
+ }
1073
1122
  declare interface IfStatement extends BaseNode {
1074
1123
  type: AST_NODE_TYPES.IfStatement;
1075
1124
  alternate: Statement | null;
@@ -1195,6 +1244,9 @@ declare interface JSXIdentifier extends BaseNode {
1195
1244
  type: AST_NODE_TYPES.JSXIdentifier;
1196
1245
  name: string;
1197
1246
  }
1247
+ declare interface JSXIdentifierToken extends BaseToken {
1248
+ type: AST_TOKEN_TYPES.JSXIdentifier;
1249
+ }
1198
1250
  declare interface JSXMemberExpression extends BaseNode {
1199
1251
  type: AST_NODE_TYPES.JSXMemberExpression;
1200
1252
  object: JSXTagNameExpression;
@@ -1229,6 +1281,12 @@ declare interface JSXText extends BaseNode {
1229
1281
  raw: string;
1230
1282
  value: string;
1231
1283
  }
1284
+ declare interface JSXTextToken extends BaseToken {
1285
+ type: AST_TOKEN_TYPES.JSXText;
1286
+ }
1287
+ declare interface KeywordToken extends BaseToken {
1288
+ type: AST_TOKEN_TYPES.Keyword;
1289
+ }
1232
1290
  declare interface LabeledStatement extends BaseNode {
1233
1291
  type: AST_NODE_TYPES.LabeledStatement;
1234
1292
  body: Statement;
@@ -1292,6 +1350,9 @@ declare interface LetOrVarNonDeclaredDeclaration extends LetOrConstOrVarDeclarat
1292
1350
  declare: false;
1293
1351
  kind: 'let' | 'var';
1294
1352
  }
1353
+ declare interface LineComment extends BaseToken {
1354
+ type: AST_TOKEN_TYPES.Line;
1355
+ }
1295
1356
  declare type Literal = BigIntLiteral | BooleanLiteral | NullLiteral | NumberLiteral | RegExpLiteral | StringLiteral;
1296
1357
  declare interface LiteralBase extends BaseNode {
1297
1358
  type: AST_NODE_TYPES.Literal;
@@ -1361,6 +1422,7 @@ declare interface NewExpression extends BaseNode {
1361
1422
  callee: Expression;
1362
1423
  typeArguments: TSTypeParameterInstantiation | undefined;
1363
1424
  }
1425
+ 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;
1364
1426
  declare interface NodeOrTokenData {
1365
1427
  type: string;
1366
1428
  /**
@@ -1375,9 +1437,15 @@ declare interface NullLiteral extends LiteralBase {
1375
1437
  raw: 'null';
1376
1438
  value: null;
1377
1439
  }
1440
+ declare interface NullToken extends BaseToken {
1441
+ type: AST_TOKEN_TYPES.Null;
1442
+ }
1378
1443
  declare interface NumberLiteral extends LiteralBase {
1379
1444
  value: number;
1380
1445
  }
1446
+ declare interface NumericToken extends BaseToken {
1447
+ type: AST_TOKEN_TYPES.Numeric;
1448
+ }
1381
1449
  declare interface ObjectExpression extends BaseNode {
1382
1450
  type: AST_NODE_TYPES.ObjectExpression;
1383
1451
  properties: ObjectLiteralElement[];
@@ -1405,6 +1473,13 @@ declare interface PrivateIdentifier extends BaseNode {
1405
1473
  type: AST_NODE_TYPES.PrivateIdentifier;
1406
1474
  name: string;
1407
1475
  }
1476
+ declare interface Program extends NodeOrTokenData {
1477
+ type: AST_NODE_TYPES.Program;
1478
+ body: ProgramStatement[];
1479
+ comments: Comment[] | undefined;
1480
+ sourceType: 'module' | 'script';
1481
+ tokens: Token[] | undefined;
1482
+ }
1408
1483
  declare type ProgramStatement = ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | ImportDeclaration | Statement | TSImportEqualsDeclaration | TSNamespaceExportDeclaration;
1409
1484
  declare type Property = PropertyComputedName | PropertyNonComputedName;
1410
1485
  declare interface PropertyBase extends BaseNode {
@@ -1457,6 +1532,57 @@ declare interface PropertyNonComputedName extends PropertyBase {
1457
1532
  computed: false;
1458
1533
  key: PropertyNameNonComputed;
1459
1534
  }
1535
+ declare interface PunctuatorToken extends BaseToken {
1536
+ type: AST_TOKEN_TYPES.Punctuator;
1537
+ value: ValueOf<PunctuatorTokenToText>;
1538
+ }
1539
+ declare interface PunctuatorTokenToText extends AssignmentOperatorToText {
1540
+ [SyntaxKind.AmpersandAmpersandToken]: '&&';
1541
+ [SyntaxKind.AmpersandToken]: '&';
1542
+ [SyntaxKind.AsteriskAsteriskToken]: '**';
1543
+ [SyntaxKind.AsteriskToken]: '*';
1544
+ [SyntaxKind.AtToken]: '@';
1545
+ [SyntaxKind.BacktickToken]: '`';
1546
+ [SyntaxKind.BarBarToken]: '||';
1547
+ [SyntaxKind.BarToken]: '|';
1548
+ [SyntaxKind.CaretToken]: '^';
1549
+ [SyntaxKind.CloseBraceToken]: '}';
1550
+ [SyntaxKind.CloseBracketToken]: ']';
1551
+ [SyntaxKind.CloseParenToken]: ')';
1552
+ [SyntaxKind.ColonToken]: ':';
1553
+ [SyntaxKind.CommaToken]: ',';
1554
+ [SyntaxKind.DotDotDotToken]: '...';
1555
+ [SyntaxKind.DotToken]: '.';
1556
+ [SyntaxKind.EqualsEqualsEqualsToken]: '===';
1557
+ [SyntaxKind.EqualsEqualsToken]: '==';
1558
+ [SyntaxKind.EqualsGreaterThanToken]: '=>';
1559
+ [SyntaxKind.ExclamationEqualsEqualsToken]: '!==';
1560
+ [SyntaxKind.ExclamationEqualsToken]: '!=';
1561
+ [SyntaxKind.ExclamationToken]: '!';
1562
+ [SyntaxKind.GreaterThanEqualsToken]: '>=';
1563
+ [SyntaxKind.GreaterThanGreaterThanGreaterThanToken]: '>>>';
1564
+ [SyntaxKind.GreaterThanGreaterThanToken]: '>>';
1565
+ [SyntaxKind.GreaterThanToken]: '>';
1566
+ [SyntaxKind.HashToken]: '#';
1567
+ [SyntaxKind.LessThanEqualsToken]: '<=';
1568
+ [SyntaxKind.LessThanLessThanToken]: '<<';
1569
+ [SyntaxKind.LessThanSlashToken]: '</';
1570
+ [SyntaxKind.LessThanToken]: '<';
1571
+ [SyntaxKind.MinusMinusToken]: '--';
1572
+ [SyntaxKind.MinusToken]: '-';
1573
+ [SyntaxKind.OpenBraceToken]: '{';
1574
+ [SyntaxKind.OpenBracketToken]: '[';
1575
+ [SyntaxKind.OpenParenToken]: '(';
1576
+ [SyntaxKind.PercentToken]: '%';
1577
+ [SyntaxKind.PlusPlusToken]: '++';
1578
+ [SyntaxKind.PlusToken]: '+';
1579
+ [SyntaxKind.QuestionDotToken]: '?.';
1580
+ [SyntaxKind.QuestionQuestionToken]: '??';
1581
+ [SyntaxKind.QuestionToken]: '?';
1582
+ [SyntaxKind.SemicolonToken]: ';';
1583
+ [SyntaxKind.SlashToken]: '/';
1584
+ [SyntaxKind.TildeToken]: '~';
1585
+ }
1460
1586
  /**
1461
1587
  * An array of two numbers.
1462
1588
  * Both numbers are a 0-based index which is the position in the array of source code characters.
@@ -1470,6 +1596,13 @@ declare interface RegExpLiteral extends LiteralBase {
1470
1596
  };
1471
1597
  value: RegExp | null;
1472
1598
  }
1599
+ declare interface RegularExpressionToken extends BaseToken {
1600
+ type: AST_TOKEN_TYPES.RegularExpression;
1601
+ regex: {
1602
+ flags: string;
1603
+ pattern: string;
1604
+ };
1605
+ }
1473
1606
  declare interface RestElement extends BaseNode {
1474
1607
  type: AST_NODE_TYPES.RestElement;
1475
1608
  argument: DestructuringPattern;
@@ -1508,6 +1641,9 @@ declare interface StaticBlock extends BaseNode {
1508
1641
  declare interface StringLiteral extends LiteralBase {
1509
1642
  value: string;
1510
1643
  }
1644
+ declare interface StringToken extends BaseToken {
1645
+ type: AST_TOKEN_TYPES.String;
1646
+ }
1511
1647
  declare interface Super extends BaseNode {
1512
1648
  type: AST_NODE_TYPES.Super;
1513
1649
  }
@@ -1540,6 +1676,9 @@ declare interface TemplateLiteral extends BaseNode {
1540
1676
  expressions: Expression[];
1541
1677
  quasis: TemplateElement[];
1542
1678
  }
1679
+ declare interface TemplateToken extends BaseToken {
1680
+ type: AST_TOKEN_TYPES.Template;
1681
+ }
1543
1682
  declare interface ThisExpression extends BaseNode {
1544
1683
  type: AST_NODE_TYPES.ThisExpression;
1545
1684
  }
@@ -1547,6 +1686,7 @@ declare interface ThrowStatement extends BaseNode {
1547
1686
  type: AST_NODE_TYPES.ThrowStatement;
1548
1687
  argument: Expression;
1549
1688
  }
1689
+ declare type Token = BooleanToken | Comment | IdentifierToken | JSXIdentifierToken | JSXTextToken | KeywordToken | NullToken | NumericToken | PunctuatorToken | RegularExpressionToken | StringToken | TemplateToken;
1550
1690
  declare interface TryStatement extends BaseNode {
1551
1691
  type: AST_NODE_TYPES.TryStatement;
1552
1692
  block: BlockStatement;
@@ -2262,6 +2402,7 @@ declare interface UsingDeclarationBase extends BaseNode {
2262
2402
  */
2263
2403
  kind: 'await using' | 'using';
2264
2404
  }
2405
+ declare type UsingDeclarator = UsingInForOfDeclarator | UsingInNormalContextDeclarator;
2265
2406
  declare interface UsingInForOfDeclaration extends UsingDeclarationBase {
2266
2407
  /**
2267
2408
  * The variables declared by this declaration.
@@ -2297,6 +2438,7 @@ declare interface UsingInNormalContextDeclarator extends VariableDeclaratorBase
2297
2438
  }
2298
2439
  declare type ValueOf<T> = T[keyof T];
2299
2440
  declare type VariableDeclaration = LetOrConstOrVarDeclaration | UsingDeclaration;
2441
+ declare type VariableDeclarator = LetOrConstOrVarDeclarator | UsingDeclarator;
2300
2442
  declare interface VariableDeclaratorBase extends BaseNode {
2301
2443
  type: AST_NODE_TYPES.VariableDeclarator;
2302
2444
  /**
@@ -2361,16 +2503,69 @@ declare const isCreateElement: (node: Identifier | MemberExpression, context: _e
2361
2503
  declare const isCreateRef: (node: Identifier | MemberExpression, context: _eslint_react_types.RuleContext) => boolean;
2362
2504
  declare const isForwardRef: (node: Identifier | MemberExpression, context: _eslint_react_types.RuleContext) => boolean;
2363
2505
  declare const isMemo: (node: Identifier | MemberExpression, context: _eslint_react_types.RuleContext) => boolean;
2364
- declare const isChildrenCountCall: (node: CallExpression, context: _eslint_react_types.RuleContext) => boolean;
2365
- declare const isChildrenForEachCall: (node: CallExpression, context: _eslint_react_types.RuleContext) => boolean;
2366
- declare const isChildrenMapCall: (node: CallExpression, context: _eslint_react_types.RuleContext) => boolean;
2367
- declare const isChildrenOnlyCall: (node: CallExpression, context: _eslint_react_types.RuleContext) => boolean;
2368
- declare const isChildrenToArrayCall: (node: CallExpression, context: _eslint_react_types.RuleContext) => boolean;
2369
- declare const isCloneElementCall: (node: CallExpression, context: _eslint_react_types.RuleContext) => boolean;
2370
- declare const isCreateContextCall: (node: CallExpression, context: _eslint_react_types.RuleContext) => boolean;
2371
- declare const isCreateElementCall: (node: CallExpression, context: _eslint_react_types.RuleContext) => boolean;
2372
- declare const isCreateRefCall: (node: CallExpression, context: _eslint_react_types.RuleContext) => boolean;
2373
- declare const isForwardRefCall: (node: CallExpression, context: _eslint_react_types.RuleContext) => boolean;
2374
- declare const isMemoCall: (node: CallExpression, context: _eslint_react_types.RuleContext) => boolean;
2506
+ declare const isChildrenCountCall: {
2507
+ (context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression & {
2508
+ callee: MemberExpression;
2509
+ };
2510
+ (node: Node, context: _eslint_react_types.RuleContext): node is CallExpression & {
2511
+ callee: MemberExpression;
2512
+ };
2513
+ };
2514
+ declare const isChildrenForEachCall: {
2515
+ (context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression & {
2516
+ callee: MemberExpression;
2517
+ };
2518
+ (node: Node, context: _eslint_react_types.RuleContext): node is CallExpression & {
2519
+ callee: MemberExpression;
2520
+ };
2521
+ };
2522
+ declare const isChildrenMapCall: {
2523
+ (context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression & {
2524
+ callee: MemberExpression;
2525
+ };
2526
+ (node: Node, context: _eslint_react_types.RuleContext): node is CallExpression & {
2527
+ callee: MemberExpression;
2528
+ };
2529
+ };
2530
+ declare const isChildrenOnlyCall: {
2531
+ (context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression & {
2532
+ callee: MemberExpression;
2533
+ };
2534
+ (node: Node, context: _eslint_react_types.RuleContext): node is CallExpression & {
2535
+ callee: MemberExpression;
2536
+ };
2537
+ };
2538
+ declare const isChildrenToArrayCall: {
2539
+ (context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression & {
2540
+ callee: MemberExpression;
2541
+ };
2542
+ (node: Node, context: _eslint_react_types.RuleContext): node is CallExpression & {
2543
+ callee: MemberExpression;
2544
+ };
2545
+ };
2546
+ declare const isCloneElementCall: {
2547
+ (context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression;
2548
+ (node: Node, context: _eslint_react_types.RuleContext): node is CallExpression;
2549
+ };
2550
+ declare const isCreateContextCall: {
2551
+ (context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression;
2552
+ (node: Node, context: _eslint_react_types.RuleContext): node is CallExpression;
2553
+ };
2554
+ declare const isCreateElementCall: {
2555
+ (context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression;
2556
+ (node: Node, context: _eslint_react_types.RuleContext): node is CallExpression;
2557
+ };
2558
+ declare const isCreateRefCall: {
2559
+ (context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression;
2560
+ (node: Node, context: _eslint_react_types.RuleContext): node is CallExpression;
2561
+ };
2562
+ declare const isForwardRefCall: {
2563
+ (context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression;
2564
+ (node: Node, context: _eslint_react_types.RuleContext): node is CallExpression;
2565
+ };
2566
+ declare const isMemoCall: {
2567
+ (context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression;
2568
+ (node: Node, context: _eslint_react_types.RuleContext): node is CallExpression;
2569
+ };
2375
2570
 
2376
2571
  export { DEFAULT_COMPONENT_HINT, type ERClassComponent, ERClassComponentFlag, type ERComponent, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectMethodKind, type EREffectPhaseKind, type ERFunctionComponent, ERFunctionComponentFlag, type ERHook, type ERHookKind, type ERLifecycleMethodKind, type ERLifecyclePhaseKind, type ERPhaseKind, ERPhaseRelevance, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getElementRepresentName, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCleanupFunction, isCloneElement, isCloneElementCall, isComponentDidMount, isComponentDidMountFunction, isComponentName, isComponentWillUnmount, isComponentWillUnmountFunction, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFragmentElement, isFromReact, isFromReactMember, isFunctionOfRenderMethod, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderPropLoose, isSetupFunction, 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
@@ -160,12 +160,18 @@ declare function isCleanupFunction(node: TSESTree.Node): boolean;
160
160
  declare function getElementRepresentName(node: TSESTree.JSXOpeningElement, context: RuleContext): string;
161
161
 
162
162
  /**
163
- * Determines whether inside createElement's props.
163
+ * Determines whether inside `createElement`'s props.
164
164
  * @param node The AST node to check
165
165
  * @param context The rule context
166
166
  * @returns `true` if the node is inside createElement's props
167
167
  */
168
168
  declare function isInsideCreateElementProps(node: TSESTree.Node, context: RuleContext): boolean;
169
+ /**
170
+ * Determines whether inside `createElement`'s children.
171
+ * @param node The AST node to check
172
+ * @param context The rule context
173
+ * @returns `true` if the node is inside createElement's children
174
+ */
169
175
  declare function isChildrenOfCreateElement(node: TSESTree.Node, context: RuleContext): boolean;
170
176
 
171
177
  /**
@@ -316,8 +322,20 @@ declare function isFromReact(name: string): (node: TSESTree.Identifier | TSESTre
316
322
  * @returns A function that checks if a given node is a member expression of a Pragma member.
317
323
  */
318
324
  declare function isFromReactMember(memberName: string, name: string): (node: TSESTree.MemberExpression, context: RuleContext) => boolean;
319
- declare function isCallFromReact(name: string): (node: TSESTree.CallExpression, context: RuleContext) => boolean;
320
- declare function isCallFromReactMember(pragmaMemberName: string, name: string): (node: TSESTree.CallExpression, context: RuleContext) => boolean;
325
+ type IsCallFromReact = {
326
+ (context: RuleContext): (node: TSESTree.Node) => node is TSESTree.CallExpression;
327
+ (node: TSESTree.Node, context: RuleContext): node is TSESTree.CallExpression;
328
+ };
329
+ declare function isCallFromReact(name: string): IsCallFromReact;
330
+ type IsCallFromReactMember = {
331
+ (context: RuleContext): (node: TSESTree.Node) => node is TSESTree.CallExpression & {
332
+ callee: TSESTree.MemberExpression;
333
+ };
334
+ (node: TSESTree.Node, context: RuleContext): node is TSESTree.CallExpression & {
335
+ callee: TSESTree.MemberExpression;
336
+ };
337
+ };
338
+ declare function isCallFromReactMember(pragmaMemberName: string, name: string): IsCallFromReactMember;
321
339
 
322
340
  /**
323
341
  * Check if an identifier is initialized from React
@@ -573,6 +591,21 @@ declare enum AST_NODE_TYPES {
573
591
  TSUnknownKeyword = "TSUnknownKeyword",
574
592
  TSVoidKeyword = "TSVoidKeyword"
575
593
  }
594
+ declare enum AST_TOKEN_TYPES {
595
+ Boolean = "Boolean",
596
+ Identifier = "Identifier",
597
+ JSXIdentifier = "JSXIdentifier",
598
+ JSXText = "JSXText",
599
+ Keyword = "Keyword",
600
+ Null = "Null",
601
+ Numeric = "Numeric",
602
+ Punctuator = "Punctuator",
603
+ RegularExpression = "RegularExpression",
604
+ String = "String",
605
+ Template = "Template",
606
+ Block = "Block",
607
+ Line = "Line"
608
+ }
576
609
  declare interface AwaitExpression extends BaseNode {
577
610
  type: AST_NODE_TYPES.AwaitExpression;
578
611
  argument: Expression;
@@ -580,6 +613,10 @@ declare interface AwaitExpression extends BaseNode {
580
613
  declare interface BaseNode extends NodeOrTokenData {
581
614
  type: AST_NODE_TYPES;
582
615
  }
616
+ declare interface BaseToken extends NodeOrTokenData {
617
+ type: AST_TOKEN_TYPES;
618
+ value: string;
619
+ }
583
620
  declare interface BigIntLiteral extends LiteralBase {
584
621
  bigint: string;
585
622
  value: bigint | null;
@@ -618,6 +655,9 @@ declare interface BinaryOperatorToText {
618
655
  }
619
656
  declare type BindingName = BindingPattern | Identifier;
620
657
  declare type BindingPattern = ArrayPattern | ObjectPattern;
658
+ declare interface BlockComment extends BaseToken {
659
+ type: AST_TOKEN_TYPES.Block;
660
+ }
621
661
  declare interface BlockStatement extends BaseNode {
622
662
  type: AST_NODE_TYPES.BlockStatement;
623
663
  body: Statement[];
@@ -626,6 +666,9 @@ declare interface BooleanLiteral extends LiteralBase {
626
666
  raw: 'false' | 'true';
627
667
  value: boolean;
628
668
  }
669
+ declare interface BooleanToken extends BaseToken {
670
+ type: AST_TOKEN_TYPES.Boolean;
671
+ }
629
672
  declare interface BreakStatement extends BaseNode {
630
673
  type: AST_NODE_TYPES.BreakStatement;
631
674
  label: Identifier | null;
@@ -706,6 +749,7 @@ declare interface ClassBody extends BaseNode {
706
749
  type: AST_NODE_TYPES.ClassBody;
707
750
  body: ClassElement[];
708
751
  }
752
+ declare type ClassDeclaration = ClassDeclarationWithName | ClassDeclarationWithOptionalName;
709
753
  declare interface ClassDeclarationBase extends ClassBase {
710
754
  type: AST_NODE_TYPES.ClassDeclaration;
711
755
  }
@@ -742,6 +786,7 @@ declare interface ClassPropertyDefinitionNonComputedNameBase extends PropertyDef
742
786
  key: ClassPropertyNameNonComputed;
743
787
  }
744
788
  declare type ClassPropertyNameNonComputed = PrivateIdentifier | PropertyNameNonComputed;
789
+ declare type Comment = BlockComment | LineComment;
745
790
  declare interface ConditionalExpression extends BaseNode {
746
791
  type: AST_NODE_TYPES.ConditionalExpression;
747
792
  alternate: Expression;
@@ -1034,6 +1079,7 @@ declare interface FunctionBase extends BaseNode {
1034
1079
  */
1035
1080
  typeParameters: TSTypeParameterDeclaration | undefined;
1036
1081
  }
1082
+ declare type FunctionDeclaration = FunctionDeclarationWithName | FunctionDeclarationWithOptionalName;
1037
1083
  declare interface FunctionDeclarationBase extends FunctionBase {
1038
1084
  type: AST_NODE_TYPES.FunctionDeclaration;
1039
1085
  body: BlockStatement;
@@ -1070,6 +1116,9 @@ declare interface Identifier extends BaseNode {
1070
1116
  optional: boolean;
1071
1117
  typeAnnotation: TSTypeAnnotation | undefined;
1072
1118
  }
1119
+ declare interface IdentifierToken extends BaseToken {
1120
+ type: AST_TOKEN_TYPES.Identifier;
1121
+ }
1073
1122
  declare interface IfStatement extends BaseNode {
1074
1123
  type: AST_NODE_TYPES.IfStatement;
1075
1124
  alternate: Statement | null;
@@ -1195,6 +1244,9 @@ declare interface JSXIdentifier extends BaseNode {
1195
1244
  type: AST_NODE_TYPES.JSXIdentifier;
1196
1245
  name: string;
1197
1246
  }
1247
+ declare interface JSXIdentifierToken extends BaseToken {
1248
+ type: AST_TOKEN_TYPES.JSXIdentifier;
1249
+ }
1198
1250
  declare interface JSXMemberExpression extends BaseNode {
1199
1251
  type: AST_NODE_TYPES.JSXMemberExpression;
1200
1252
  object: JSXTagNameExpression;
@@ -1229,6 +1281,12 @@ declare interface JSXText extends BaseNode {
1229
1281
  raw: string;
1230
1282
  value: string;
1231
1283
  }
1284
+ declare interface JSXTextToken extends BaseToken {
1285
+ type: AST_TOKEN_TYPES.JSXText;
1286
+ }
1287
+ declare interface KeywordToken extends BaseToken {
1288
+ type: AST_TOKEN_TYPES.Keyword;
1289
+ }
1232
1290
  declare interface LabeledStatement extends BaseNode {
1233
1291
  type: AST_NODE_TYPES.LabeledStatement;
1234
1292
  body: Statement;
@@ -1292,6 +1350,9 @@ declare interface LetOrVarNonDeclaredDeclaration extends LetOrConstOrVarDeclarat
1292
1350
  declare: false;
1293
1351
  kind: 'let' | 'var';
1294
1352
  }
1353
+ declare interface LineComment extends BaseToken {
1354
+ type: AST_TOKEN_TYPES.Line;
1355
+ }
1295
1356
  declare type Literal = BigIntLiteral | BooleanLiteral | NullLiteral | NumberLiteral | RegExpLiteral | StringLiteral;
1296
1357
  declare interface LiteralBase extends BaseNode {
1297
1358
  type: AST_NODE_TYPES.Literal;
@@ -1361,6 +1422,7 @@ declare interface NewExpression extends BaseNode {
1361
1422
  callee: Expression;
1362
1423
  typeArguments: TSTypeParameterInstantiation | undefined;
1363
1424
  }
1425
+ 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;
1364
1426
  declare interface NodeOrTokenData {
1365
1427
  type: string;
1366
1428
  /**
@@ -1375,9 +1437,15 @@ declare interface NullLiteral extends LiteralBase {
1375
1437
  raw: 'null';
1376
1438
  value: null;
1377
1439
  }
1440
+ declare interface NullToken extends BaseToken {
1441
+ type: AST_TOKEN_TYPES.Null;
1442
+ }
1378
1443
  declare interface NumberLiteral extends LiteralBase {
1379
1444
  value: number;
1380
1445
  }
1446
+ declare interface NumericToken extends BaseToken {
1447
+ type: AST_TOKEN_TYPES.Numeric;
1448
+ }
1381
1449
  declare interface ObjectExpression extends BaseNode {
1382
1450
  type: AST_NODE_TYPES.ObjectExpression;
1383
1451
  properties: ObjectLiteralElement[];
@@ -1405,6 +1473,13 @@ declare interface PrivateIdentifier extends BaseNode {
1405
1473
  type: AST_NODE_TYPES.PrivateIdentifier;
1406
1474
  name: string;
1407
1475
  }
1476
+ declare interface Program extends NodeOrTokenData {
1477
+ type: AST_NODE_TYPES.Program;
1478
+ body: ProgramStatement[];
1479
+ comments: Comment[] | undefined;
1480
+ sourceType: 'module' | 'script';
1481
+ tokens: Token[] | undefined;
1482
+ }
1408
1483
  declare type ProgramStatement = ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | ImportDeclaration | Statement | TSImportEqualsDeclaration | TSNamespaceExportDeclaration;
1409
1484
  declare type Property = PropertyComputedName | PropertyNonComputedName;
1410
1485
  declare interface PropertyBase extends BaseNode {
@@ -1457,6 +1532,57 @@ declare interface PropertyNonComputedName extends PropertyBase {
1457
1532
  computed: false;
1458
1533
  key: PropertyNameNonComputed;
1459
1534
  }
1535
+ declare interface PunctuatorToken extends BaseToken {
1536
+ type: AST_TOKEN_TYPES.Punctuator;
1537
+ value: ValueOf<PunctuatorTokenToText>;
1538
+ }
1539
+ declare interface PunctuatorTokenToText extends AssignmentOperatorToText {
1540
+ [SyntaxKind.AmpersandAmpersandToken]: '&&';
1541
+ [SyntaxKind.AmpersandToken]: '&';
1542
+ [SyntaxKind.AsteriskAsteriskToken]: '**';
1543
+ [SyntaxKind.AsteriskToken]: '*';
1544
+ [SyntaxKind.AtToken]: '@';
1545
+ [SyntaxKind.BacktickToken]: '`';
1546
+ [SyntaxKind.BarBarToken]: '||';
1547
+ [SyntaxKind.BarToken]: '|';
1548
+ [SyntaxKind.CaretToken]: '^';
1549
+ [SyntaxKind.CloseBraceToken]: '}';
1550
+ [SyntaxKind.CloseBracketToken]: ']';
1551
+ [SyntaxKind.CloseParenToken]: ')';
1552
+ [SyntaxKind.ColonToken]: ':';
1553
+ [SyntaxKind.CommaToken]: ',';
1554
+ [SyntaxKind.DotDotDotToken]: '...';
1555
+ [SyntaxKind.DotToken]: '.';
1556
+ [SyntaxKind.EqualsEqualsEqualsToken]: '===';
1557
+ [SyntaxKind.EqualsEqualsToken]: '==';
1558
+ [SyntaxKind.EqualsGreaterThanToken]: '=>';
1559
+ [SyntaxKind.ExclamationEqualsEqualsToken]: '!==';
1560
+ [SyntaxKind.ExclamationEqualsToken]: '!=';
1561
+ [SyntaxKind.ExclamationToken]: '!';
1562
+ [SyntaxKind.GreaterThanEqualsToken]: '>=';
1563
+ [SyntaxKind.GreaterThanGreaterThanGreaterThanToken]: '>>>';
1564
+ [SyntaxKind.GreaterThanGreaterThanToken]: '>>';
1565
+ [SyntaxKind.GreaterThanToken]: '>';
1566
+ [SyntaxKind.HashToken]: '#';
1567
+ [SyntaxKind.LessThanEqualsToken]: '<=';
1568
+ [SyntaxKind.LessThanLessThanToken]: '<<';
1569
+ [SyntaxKind.LessThanSlashToken]: '</';
1570
+ [SyntaxKind.LessThanToken]: '<';
1571
+ [SyntaxKind.MinusMinusToken]: '--';
1572
+ [SyntaxKind.MinusToken]: '-';
1573
+ [SyntaxKind.OpenBraceToken]: '{';
1574
+ [SyntaxKind.OpenBracketToken]: '[';
1575
+ [SyntaxKind.OpenParenToken]: '(';
1576
+ [SyntaxKind.PercentToken]: '%';
1577
+ [SyntaxKind.PlusPlusToken]: '++';
1578
+ [SyntaxKind.PlusToken]: '+';
1579
+ [SyntaxKind.QuestionDotToken]: '?.';
1580
+ [SyntaxKind.QuestionQuestionToken]: '??';
1581
+ [SyntaxKind.QuestionToken]: '?';
1582
+ [SyntaxKind.SemicolonToken]: ';';
1583
+ [SyntaxKind.SlashToken]: '/';
1584
+ [SyntaxKind.TildeToken]: '~';
1585
+ }
1460
1586
  /**
1461
1587
  * An array of two numbers.
1462
1588
  * Both numbers are a 0-based index which is the position in the array of source code characters.
@@ -1470,6 +1596,13 @@ declare interface RegExpLiteral extends LiteralBase {
1470
1596
  };
1471
1597
  value: RegExp | null;
1472
1598
  }
1599
+ declare interface RegularExpressionToken extends BaseToken {
1600
+ type: AST_TOKEN_TYPES.RegularExpression;
1601
+ regex: {
1602
+ flags: string;
1603
+ pattern: string;
1604
+ };
1605
+ }
1473
1606
  declare interface RestElement extends BaseNode {
1474
1607
  type: AST_NODE_TYPES.RestElement;
1475
1608
  argument: DestructuringPattern;
@@ -1508,6 +1641,9 @@ declare interface StaticBlock extends BaseNode {
1508
1641
  declare interface StringLiteral extends LiteralBase {
1509
1642
  value: string;
1510
1643
  }
1644
+ declare interface StringToken extends BaseToken {
1645
+ type: AST_TOKEN_TYPES.String;
1646
+ }
1511
1647
  declare interface Super extends BaseNode {
1512
1648
  type: AST_NODE_TYPES.Super;
1513
1649
  }
@@ -1540,6 +1676,9 @@ declare interface TemplateLiteral extends BaseNode {
1540
1676
  expressions: Expression[];
1541
1677
  quasis: TemplateElement[];
1542
1678
  }
1679
+ declare interface TemplateToken extends BaseToken {
1680
+ type: AST_TOKEN_TYPES.Template;
1681
+ }
1543
1682
  declare interface ThisExpression extends BaseNode {
1544
1683
  type: AST_NODE_TYPES.ThisExpression;
1545
1684
  }
@@ -1547,6 +1686,7 @@ declare interface ThrowStatement extends BaseNode {
1547
1686
  type: AST_NODE_TYPES.ThrowStatement;
1548
1687
  argument: Expression;
1549
1688
  }
1689
+ declare type Token = BooleanToken | Comment | IdentifierToken | JSXIdentifierToken | JSXTextToken | KeywordToken | NullToken | NumericToken | PunctuatorToken | RegularExpressionToken | StringToken | TemplateToken;
1550
1690
  declare interface TryStatement extends BaseNode {
1551
1691
  type: AST_NODE_TYPES.TryStatement;
1552
1692
  block: BlockStatement;
@@ -2262,6 +2402,7 @@ declare interface UsingDeclarationBase extends BaseNode {
2262
2402
  */
2263
2403
  kind: 'await using' | 'using';
2264
2404
  }
2405
+ declare type UsingDeclarator = UsingInForOfDeclarator | UsingInNormalContextDeclarator;
2265
2406
  declare interface UsingInForOfDeclaration extends UsingDeclarationBase {
2266
2407
  /**
2267
2408
  * The variables declared by this declaration.
@@ -2297,6 +2438,7 @@ declare interface UsingInNormalContextDeclarator extends VariableDeclaratorBase
2297
2438
  }
2298
2439
  declare type ValueOf<T> = T[keyof T];
2299
2440
  declare type VariableDeclaration = LetOrConstOrVarDeclaration | UsingDeclaration;
2441
+ declare type VariableDeclarator = LetOrConstOrVarDeclarator | UsingDeclarator;
2300
2442
  declare interface VariableDeclaratorBase extends BaseNode {
2301
2443
  type: AST_NODE_TYPES.VariableDeclarator;
2302
2444
  /**
@@ -2361,16 +2503,69 @@ declare const isCreateElement: (node: Identifier | MemberExpression, context: _e
2361
2503
  declare const isCreateRef: (node: Identifier | MemberExpression, context: _eslint_react_types.RuleContext) => boolean;
2362
2504
  declare const isForwardRef: (node: Identifier | MemberExpression, context: _eslint_react_types.RuleContext) => boolean;
2363
2505
  declare const isMemo: (node: Identifier | MemberExpression, context: _eslint_react_types.RuleContext) => boolean;
2364
- declare const isChildrenCountCall: (node: CallExpression, context: _eslint_react_types.RuleContext) => boolean;
2365
- declare const isChildrenForEachCall: (node: CallExpression, context: _eslint_react_types.RuleContext) => boolean;
2366
- declare const isChildrenMapCall: (node: CallExpression, context: _eslint_react_types.RuleContext) => boolean;
2367
- declare const isChildrenOnlyCall: (node: CallExpression, context: _eslint_react_types.RuleContext) => boolean;
2368
- declare const isChildrenToArrayCall: (node: CallExpression, context: _eslint_react_types.RuleContext) => boolean;
2369
- declare const isCloneElementCall: (node: CallExpression, context: _eslint_react_types.RuleContext) => boolean;
2370
- declare const isCreateContextCall: (node: CallExpression, context: _eslint_react_types.RuleContext) => boolean;
2371
- declare const isCreateElementCall: (node: CallExpression, context: _eslint_react_types.RuleContext) => boolean;
2372
- declare const isCreateRefCall: (node: CallExpression, context: _eslint_react_types.RuleContext) => boolean;
2373
- declare const isForwardRefCall: (node: CallExpression, context: _eslint_react_types.RuleContext) => boolean;
2374
- declare const isMemoCall: (node: CallExpression, context: _eslint_react_types.RuleContext) => boolean;
2506
+ declare const isChildrenCountCall: {
2507
+ (context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression & {
2508
+ callee: MemberExpression;
2509
+ };
2510
+ (node: Node, context: _eslint_react_types.RuleContext): node is CallExpression & {
2511
+ callee: MemberExpression;
2512
+ };
2513
+ };
2514
+ declare const isChildrenForEachCall: {
2515
+ (context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression & {
2516
+ callee: MemberExpression;
2517
+ };
2518
+ (node: Node, context: _eslint_react_types.RuleContext): node is CallExpression & {
2519
+ callee: MemberExpression;
2520
+ };
2521
+ };
2522
+ declare const isChildrenMapCall: {
2523
+ (context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression & {
2524
+ callee: MemberExpression;
2525
+ };
2526
+ (node: Node, context: _eslint_react_types.RuleContext): node is CallExpression & {
2527
+ callee: MemberExpression;
2528
+ };
2529
+ };
2530
+ declare const isChildrenOnlyCall: {
2531
+ (context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression & {
2532
+ callee: MemberExpression;
2533
+ };
2534
+ (node: Node, context: _eslint_react_types.RuleContext): node is CallExpression & {
2535
+ callee: MemberExpression;
2536
+ };
2537
+ };
2538
+ declare const isChildrenToArrayCall: {
2539
+ (context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression & {
2540
+ callee: MemberExpression;
2541
+ };
2542
+ (node: Node, context: _eslint_react_types.RuleContext): node is CallExpression & {
2543
+ callee: MemberExpression;
2544
+ };
2545
+ };
2546
+ declare const isCloneElementCall: {
2547
+ (context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression;
2548
+ (node: Node, context: _eslint_react_types.RuleContext): node is CallExpression;
2549
+ };
2550
+ declare const isCreateContextCall: {
2551
+ (context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression;
2552
+ (node: Node, context: _eslint_react_types.RuleContext): node is CallExpression;
2553
+ };
2554
+ declare const isCreateElementCall: {
2555
+ (context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression;
2556
+ (node: Node, context: _eslint_react_types.RuleContext): node is CallExpression;
2557
+ };
2558
+ declare const isCreateRefCall: {
2559
+ (context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression;
2560
+ (node: Node, context: _eslint_react_types.RuleContext): node is CallExpression;
2561
+ };
2562
+ declare const isForwardRefCall: {
2563
+ (context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression;
2564
+ (node: Node, context: _eslint_react_types.RuleContext): node is CallExpression;
2565
+ };
2566
+ declare const isMemoCall: {
2567
+ (context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression;
2568
+ (node: Node, context: _eslint_react_types.RuleContext): node is CallExpression;
2569
+ };
2375
2570
 
2376
2571
  export { DEFAULT_COMPONENT_HINT, type ERClassComponent, ERClassComponentFlag, type ERComponent, ERComponentHint, type ERComponentKind, type EREffectKind, type EREffectMethodKind, type EREffectPhaseKind, type ERFunctionComponent, ERFunctionComponentFlag, type ERHook, type ERHookKind, type ERLifecycleMethodKind, type ERLifecyclePhaseKind, type ERPhaseKind, ERPhaseRelevance, type ERSemanticEntry, type ERSemanticNode, type ERStateKind, RE_COMPONENT_NAME, RE_HOOK_NAME, getComponentNameFromIdentifier, getElementRepresentName, getFunctionComponentIdentifier, hasNoneOrValidComponentName, isCallFromReact, isCallFromReactMember, isChildrenCount, isChildrenCountCall, isChildrenForEach, isChildrenForEachCall, isChildrenMap, isChildrenMapCall, isChildrenOfCreateElement, isChildrenOnly, isChildrenOnlyCall, isChildrenToArray, isChildrenToArrayCall, isClassComponent, isCleanupFunction, isCloneElement, isCloneElementCall, isComponentDidMount, isComponentDidMountFunction, isComponentName, isComponentWillUnmount, isComponentWillUnmountFunction, isCreateContext, isCreateContextCall, isCreateElement, isCreateElementCall, isCreateRef, isCreateRefCall, isDeclaredInRenderPropLoose, isDirectValueOfRenderPropertyLoose, isForwardRef, isForwardRefCall, isFragmentElement, isFromReact, isFromReactMember, isFunctionOfRenderMethod, isInitializedFromReact, isInsideCreateElementProps, isInsideReactHook, isInsideRenderMethod, isInversePhase, isMemo, isMemoCall, isPureComponent, isReactAPICallWithName, isReactAPIWithName, isReactHook, isReactHookCall, isReactHookCallWithName, isReactHookCallWithNameAlias, isReactHookCallWithNameLoose, isReactHookName, isRenderFunctionLoose, isRenderPropLoose, isSetupFunction, 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
@@ -84,16 +84,18 @@ function isFromReactMember(memberName, name) {
84
84
  };
85
85
  }
86
86
  function isCallFromReact(name) {
87
- return (node, context) => {
87
+ return eff.F.dual(2, (node, context) => {
88
+ if (node.type !== types.AST_NODE_TYPES.CallExpression) return false;
88
89
  if (!AST9__namespace.isOneOf([types.AST_NODE_TYPES.Identifier, types.AST_NODE_TYPES.MemberExpression])(node.callee)) return false;
89
90
  return isFromReact(name)(node.callee, context);
90
- };
91
+ });
91
92
  }
92
93
  function isCallFromReactMember(pragmaMemberName, name) {
93
- return (node, context) => {
94
+ return eff.F.dual(2, (node, context) => {
95
+ if (node.type !== types.AST_NODE_TYPES.CallExpression) return false;
94
96
  if (!AST9__namespace.is(types.AST_NODE_TYPES.MemberExpression)(node.callee)) return false;
95
97
  return isFromReactMember(pragmaMemberName, name)(node.callee, context);
96
- };
98
+ });
97
99
  }
98
100
 
99
101
  // src/utils/is-react-api.ts
@@ -129,19 +131,18 @@ var isMemoCall = isReactAPICallWithName("memo");
129
131
  // src/element/hierarchy.ts
130
132
  function isInsideCreateElementProps(node, context) {
131
133
  return eff.F.pipe(
132
- AST9__namespace.traverseUp(node, (n) => AST9__namespace.is(types.AST_NODE_TYPES.CallExpression)(n) && isCreateElementCall(n, context)),
133
- eff.O.filter(AST9__namespace.is(types.AST_NODE_TYPES.CallExpression)),
134
- eff.O.flatMapNullable((c) => c.arguments.at(1)),
135
- eff.O.filter(AST9__namespace.is(types.AST_NODE_TYPES.ObjectExpression)),
136
- eff.O.zipWith(AST9__namespace.traverseUp(node, AST9__namespace.is(types.AST_NODE_TYPES.ObjectExpression)), (a, b) => a === b),
137
- eff.O.getOrElse(eff.F.constFalse)
134
+ eff.O.Do,
135
+ eff.O.bind("call", () => AST9__namespace.traverseUpGuard(node, isCreateElementCall(context))),
136
+ eff.O.bind("prop", () => AST9__namespace.traverseUpGuard(node, AST9__namespace.is(types.AST_NODE_TYPES.ObjectExpression))),
137
+ eff.O.bind("arg1", ({ call }) => eff.O.fromNullable(call.arguments[1])),
138
+ eff.O.exists(({ arg1, prop }) => prop === arg1)
138
139
  );
139
140
  }
140
141
  function isChildrenOfCreateElement(node, context) {
141
142
  return eff.F.pipe(
142
143
  eff.O.fromNullable(node.parent),
143
144
  eff.O.filter(AST9__namespace.is(types.AST_NODE_TYPES.CallExpression)),
144
- eff.O.filter((n) => isCreateElementCall(n, context)),
145
+ eff.O.filter(isCreateElementCall(context)),
145
146
  eff.O.exists(
146
147
  (n) => n.arguments.slice(2).some((arg) => arg === node)
147
148
  )
package/dist/index.mjs CHANGED
@@ -57,16 +57,18 @@ function isFromReactMember(memberName, name) {
57
57
  };
58
58
  }
59
59
  function isCallFromReact(name) {
60
- return (node, context) => {
60
+ return F.dual(2, (node, context) => {
61
+ if (node.type !== AST_NODE_TYPES.CallExpression) return false;
61
62
  if (!AST9.isOneOf([AST_NODE_TYPES.Identifier, AST_NODE_TYPES.MemberExpression])(node.callee)) return false;
62
63
  return isFromReact(name)(node.callee, context);
63
- };
64
+ });
64
65
  }
65
66
  function isCallFromReactMember(pragmaMemberName, name) {
66
- return (node, context) => {
67
+ return F.dual(2, (node, context) => {
68
+ if (node.type !== AST_NODE_TYPES.CallExpression) return false;
67
69
  if (!AST9.is(AST_NODE_TYPES.MemberExpression)(node.callee)) return false;
68
70
  return isFromReactMember(pragmaMemberName, name)(node.callee, context);
69
- };
71
+ });
70
72
  }
71
73
 
72
74
  // src/utils/is-react-api.ts
@@ -102,19 +104,18 @@ var isMemoCall = isReactAPICallWithName("memo");
102
104
  // src/element/hierarchy.ts
103
105
  function isInsideCreateElementProps(node, context) {
104
106
  return F.pipe(
105
- AST9.traverseUp(node, (n) => AST9.is(AST_NODE_TYPES.CallExpression)(n) && isCreateElementCall(n, context)),
106
- O.filter(AST9.is(AST_NODE_TYPES.CallExpression)),
107
- O.flatMapNullable((c) => c.arguments.at(1)),
108
- O.filter(AST9.is(AST_NODE_TYPES.ObjectExpression)),
109
- O.zipWith(AST9.traverseUp(node, AST9.is(AST_NODE_TYPES.ObjectExpression)), (a, b) => a === b),
110
- O.getOrElse(F.constFalse)
107
+ O.Do,
108
+ O.bind("call", () => AST9.traverseUpGuard(node, isCreateElementCall(context))),
109
+ O.bind("prop", () => AST9.traverseUpGuard(node, AST9.is(AST_NODE_TYPES.ObjectExpression))),
110
+ O.bind("arg1", ({ call }) => O.fromNullable(call.arguments[1])),
111
+ O.exists(({ arg1, prop }) => prop === arg1)
111
112
  );
112
113
  }
113
114
  function isChildrenOfCreateElement(node, context) {
114
115
  return F.pipe(
115
116
  O.fromNullable(node.parent),
116
117
  O.filter(AST9.is(AST_NODE_TYPES.CallExpression)),
117
- O.filter((n) => isCreateElementCall(n, context)),
118
+ O.filter(isCreateElementCall(context)),
118
119
  O.exists(
119
120
  (n) => n.arguments.slice(2).some((arg) => arg === node)
120
121
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eslint-react/core",
3
- "version": "1.22.2-next.10",
3
+ "version": "1.22.2-next.11",
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,12 +39,12 @@
39
39
  "@typescript-eslint/utils": "^8.18.2",
40
40
  "short-unique-id": "^5.2.0",
41
41
  "ts-pattern": "^5.6.0",
42
- "@eslint-react/ast": "1.22.2-next.10",
43
- "@eslint-react/eff": "1.22.2-next.10",
44
- "@eslint-react/jsx": "1.22.2-next.10",
45
- "@eslint-react/shared": "1.22.2-next.10",
46
- "@eslint-react/types": "1.22.2-next.10",
47
- "@eslint-react/var": "1.22.2-next.10"
42
+ "@eslint-react/ast": "1.22.2-next.11",
43
+ "@eslint-react/eff": "1.22.2-next.11",
44
+ "@eslint-react/shared": "1.22.2-next.11",
45
+ "@eslint-react/types": "1.22.2-next.11",
46
+ "@eslint-react/jsx": "1.22.2-next.11",
47
+ "@eslint-react/var": "1.22.2-next.11"
48
48
  },
49
49
  "devDependencies": {
50
50
  "tsup": "^8.3.5",