@eslint-react/core 1.22.2-next.9 → 1.23.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +208 -21
- package/dist/index.d.ts +208 -21
- package/dist/index.js +30 -38
- package/dist/index.mjs +31 -38
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -160,21 +160,19 @@ 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
|
-
declare function isChildrenOfCreateElement(node: TSESTree.Node, context: RuleContext): boolean;
|
|
170
|
-
|
|
171
169
|
/**
|
|
172
|
-
*
|
|
173
|
-
* @param node The
|
|
170
|
+
* Determines whether inside `createElement`'s children.
|
|
171
|
+
* @param node The AST node to check
|
|
174
172
|
* @param context The rule context
|
|
175
|
-
* @returns `true` if the node is
|
|
173
|
+
* @returns `true` if the node is inside createElement's children
|
|
176
174
|
*/
|
|
177
|
-
declare function
|
|
175
|
+
declare function isChildrenOfCreateElement(node: TSESTree.Node, context: RuleContext): boolean;
|
|
178
176
|
|
|
179
177
|
declare function isInsideReactHook(node: TSESTree.Node): boolean;
|
|
180
178
|
|
|
@@ -316,8 +314,20 @@ declare function isFromReact(name: string): (node: TSESTree.Identifier | TSESTre
|
|
|
316
314
|
* @returns A function that checks if a given node is a member expression of a Pragma member.
|
|
317
315
|
*/
|
|
318
316
|
declare function isFromReactMember(memberName: string, name: string): (node: TSESTree.MemberExpression, context: RuleContext) => boolean;
|
|
319
|
-
|
|
320
|
-
|
|
317
|
+
type IsCallFromReact = {
|
|
318
|
+
(context: RuleContext): (node: TSESTree.Node) => node is TSESTree.CallExpression;
|
|
319
|
+
(node: TSESTree.Node, context: RuleContext): node is TSESTree.CallExpression;
|
|
320
|
+
};
|
|
321
|
+
declare function isCallFromReact(name: string): IsCallFromReact;
|
|
322
|
+
type IsCallFromReactMember = {
|
|
323
|
+
(context: RuleContext): (node: TSESTree.Node) => node is TSESTree.CallExpression & {
|
|
324
|
+
callee: TSESTree.MemberExpression;
|
|
325
|
+
};
|
|
326
|
+
(node: TSESTree.Node, context: RuleContext): node is TSESTree.CallExpression & {
|
|
327
|
+
callee: TSESTree.MemberExpression;
|
|
328
|
+
};
|
|
329
|
+
};
|
|
330
|
+
declare function isCallFromReactMember(pragmaMemberName: string, name: string): IsCallFromReactMember;
|
|
321
331
|
|
|
322
332
|
/**
|
|
323
333
|
* Check if an identifier is initialized from React
|
|
@@ -573,6 +583,21 @@ declare enum AST_NODE_TYPES {
|
|
|
573
583
|
TSUnknownKeyword = "TSUnknownKeyword",
|
|
574
584
|
TSVoidKeyword = "TSVoidKeyword"
|
|
575
585
|
}
|
|
586
|
+
declare enum AST_TOKEN_TYPES {
|
|
587
|
+
Boolean = "Boolean",
|
|
588
|
+
Identifier = "Identifier",
|
|
589
|
+
JSXIdentifier = "JSXIdentifier",
|
|
590
|
+
JSXText = "JSXText",
|
|
591
|
+
Keyword = "Keyword",
|
|
592
|
+
Null = "Null",
|
|
593
|
+
Numeric = "Numeric",
|
|
594
|
+
Punctuator = "Punctuator",
|
|
595
|
+
RegularExpression = "RegularExpression",
|
|
596
|
+
String = "String",
|
|
597
|
+
Template = "Template",
|
|
598
|
+
Block = "Block",
|
|
599
|
+
Line = "Line"
|
|
600
|
+
}
|
|
576
601
|
declare interface AwaitExpression extends BaseNode {
|
|
577
602
|
type: AST_NODE_TYPES.AwaitExpression;
|
|
578
603
|
argument: Expression;
|
|
@@ -580,6 +605,10 @@ declare interface AwaitExpression extends BaseNode {
|
|
|
580
605
|
declare interface BaseNode extends NodeOrTokenData {
|
|
581
606
|
type: AST_NODE_TYPES;
|
|
582
607
|
}
|
|
608
|
+
declare interface BaseToken extends NodeOrTokenData {
|
|
609
|
+
type: AST_TOKEN_TYPES;
|
|
610
|
+
value: string;
|
|
611
|
+
}
|
|
583
612
|
declare interface BigIntLiteral extends LiteralBase {
|
|
584
613
|
bigint: string;
|
|
585
614
|
value: bigint | null;
|
|
@@ -618,6 +647,9 @@ declare interface BinaryOperatorToText {
|
|
|
618
647
|
}
|
|
619
648
|
declare type BindingName = BindingPattern | Identifier;
|
|
620
649
|
declare type BindingPattern = ArrayPattern | ObjectPattern;
|
|
650
|
+
declare interface BlockComment extends BaseToken {
|
|
651
|
+
type: AST_TOKEN_TYPES.Block;
|
|
652
|
+
}
|
|
621
653
|
declare interface BlockStatement extends BaseNode {
|
|
622
654
|
type: AST_NODE_TYPES.BlockStatement;
|
|
623
655
|
body: Statement[];
|
|
@@ -626,6 +658,9 @@ declare interface BooleanLiteral extends LiteralBase {
|
|
|
626
658
|
raw: 'false' | 'true';
|
|
627
659
|
value: boolean;
|
|
628
660
|
}
|
|
661
|
+
declare interface BooleanToken extends BaseToken {
|
|
662
|
+
type: AST_TOKEN_TYPES.Boolean;
|
|
663
|
+
}
|
|
629
664
|
declare interface BreakStatement extends BaseNode {
|
|
630
665
|
type: AST_NODE_TYPES.BreakStatement;
|
|
631
666
|
label: Identifier | null;
|
|
@@ -706,6 +741,7 @@ declare interface ClassBody extends BaseNode {
|
|
|
706
741
|
type: AST_NODE_TYPES.ClassBody;
|
|
707
742
|
body: ClassElement[];
|
|
708
743
|
}
|
|
744
|
+
declare type ClassDeclaration = ClassDeclarationWithName | ClassDeclarationWithOptionalName;
|
|
709
745
|
declare interface ClassDeclarationBase extends ClassBase {
|
|
710
746
|
type: AST_NODE_TYPES.ClassDeclaration;
|
|
711
747
|
}
|
|
@@ -742,6 +778,7 @@ declare interface ClassPropertyDefinitionNonComputedNameBase extends PropertyDef
|
|
|
742
778
|
key: ClassPropertyNameNonComputed;
|
|
743
779
|
}
|
|
744
780
|
declare type ClassPropertyNameNonComputed = PrivateIdentifier | PropertyNameNonComputed;
|
|
781
|
+
declare type Comment = BlockComment | LineComment;
|
|
745
782
|
declare interface ConditionalExpression extends BaseNode {
|
|
746
783
|
type: AST_NODE_TYPES.ConditionalExpression;
|
|
747
784
|
alternate: Expression;
|
|
@@ -1034,6 +1071,7 @@ declare interface FunctionBase extends BaseNode {
|
|
|
1034
1071
|
*/
|
|
1035
1072
|
typeParameters: TSTypeParameterDeclaration | undefined;
|
|
1036
1073
|
}
|
|
1074
|
+
declare type FunctionDeclaration = FunctionDeclarationWithName | FunctionDeclarationWithOptionalName;
|
|
1037
1075
|
declare interface FunctionDeclarationBase extends FunctionBase {
|
|
1038
1076
|
type: AST_NODE_TYPES.FunctionDeclaration;
|
|
1039
1077
|
body: BlockStatement;
|
|
@@ -1070,6 +1108,9 @@ declare interface Identifier extends BaseNode {
|
|
|
1070
1108
|
optional: boolean;
|
|
1071
1109
|
typeAnnotation: TSTypeAnnotation | undefined;
|
|
1072
1110
|
}
|
|
1111
|
+
declare interface IdentifierToken extends BaseToken {
|
|
1112
|
+
type: AST_TOKEN_TYPES.Identifier;
|
|
1113
|
+
}
|
|
1073
1114
|
declare interface IfStatement extends BaseNode {
|
|
1074
1115
|
type: AST_NODE_TYPES.IfStatement;
|
|
1075
1116
|
alternate: Statement | null;
|
|
@@ -1195,6 +1236,9 @@ declare interface JSXIdentifier extends BaseNode {
|
|
|
1195
1236
|
type: AST_NODE_TYPES.JSXIdentifier;
|
|
1196
1237
|
name: string;
|
|
1197
1238
|
}
|
|
1239
|
+
declare interface JSXIdentifierToken extends BaseToken {
|
|
1240
|
+
type: AST_TOKEN_TYPES.JSXIdentifier;
|
|
1241
|
+
}
|
|
1198
1242
|
declare interface JSXMemberExpression extends BaseNode {
|
|
1199
1243
|
type: AST_NODE_TYPES.JSXMemberExpression;
|
|
1200
1244
|
object: JSXTagNameExpression;
|
|
@@ -1229,6 +1273,12 @@ declare interface JSXText extends BaseNode {
|
|
|
1229
1273
|
raw: string;
|
|
1230
1274
|
value: string;
|
|
1231
1275
|
}
|
|
1276
|
+
declare interface JSXTextToken extends BaseToken {
|
|
1277
|
+
type: AST_TOKEN_TYPES.JSXText;
|
|
1278
|
+
}
|
|
1279
|
+
declare interface KeywordToken extends BaseToken {
|
|
1280
|
+
type: AST_TOKEN_TYPES.Keyword;
|
|
1281
|
+
}
|
|
1232
1282
|
declare interface LabeledStatement extends BaseNode {
|
|
1233
1283
|
type: AST_NODE_TYPES.LabeledStatement;
|
|
1234
1284
|
body: Statement;
|
|
@@ -1292,6 +1342,9 @@ declare interface LetOrVarNonDeclaredDeclaration extends LetOrConstOrVarDeclarat
|
|
|
1292
1342
|
declare: false;
|
|
1293
1343
|
kind: 'let' | 'var';
|
|
1294
1344
|
}
|
|
1345
|
+
declare interface LineComment extends BaseToken {
|
|
1346
|
+
type: AST_TOKEN_TYPES.Line;
|
|
1347
|
+
}
|
|
1295
1348
|
declare type Literal = BigIntLiteral | BooleanLiteral | NullLiteral | NumberLiteral | RegExpLiteral | StringLiteral;
|
|
1296
1349
|
declare interface LiteralBase extends BaseNode {
|
|
1297
1350
|
type: AST_NODE_TYPES.Literal;
|
|
@@ -1361,6 +1414,7 @@ declare interface NewExpression extends BaseNode {
|
|
|
1361
1414
|
callee: Expression;
|
|
1362
1415
|
typeArguments: TSTypeParameterInstantiation | undefined;
|
|
1363
1416
|
}
|
|
1417
|
+
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
1418
|
declare interface NodeOrTokenData {
|
|
1365
1419
|
type: string;
|
|
1366
1420
|
/**
|
|
@@ -1375,9 +1429,15 @@ declare interface NullLiteral extends LiteralBase {
|
|
|
1375
1429
|
raw: 'null';
|
|
1376
1430
|
value: null;
|
|
1377
1431
|
}
|
|
1432
|
+
declare interface NullToken extends BaseToken {
|
|
1433
|
+
type: AST_TOKEN_TYPES.Null;
|
|
1434
|
+
}
|
|
1378
1435
|
declare interface NumberLiteral extends LiteralBase {
|
|
1379
1436
|
value: number;
|
|
1380
1437
|
}
|
|
1438
|
+
declare interface NumericToken extends BaseToken {
|
|
1439
|
+
type: AST_TOKEN_TYPES.Numeric;
|
|
1440
|
+
}
|
|
1381
1441
|
declare interface ObjectExpression extends BaseNode {
|
|
1382
1442
|
type: AST_NODE_TYPES.ObjectExpression;
|
|
1383
1443
|
properties: ObjectLiteralElement[];
|
|
@@ -1405,6 +1465,13 @@ declare interface PrivateIdentifier extends BaseNode {
|
|
|
1405
1465
|
type: AST_NODE_TYPES.PrivateIdentifier;
|
|
1406
1466
|
name: string;
|
|
1407
1467
|
}
|
|
1468
|
+
declare interface Program extends NodeOrTokenData {
|
|
1469
|
+
type: AST_NODE_TYPES.Program;
|
|
1470
|
+
body: ProgramStatement[];
|
|
1471
|
+
comments: Comment[] | undefined;
|
|
1472
|
+
sourceType: 'module' | 'script';
|
|
1473
|
+
tokens: Token[] | undefined;
|
|
1474
|
+
}
|
|
1408
1475
|
declare type ProgramStatement = ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | ImportDeclaration | Statement | TSImportEqualsDeclaration | TSNamespaceExportDeclaration;
|
|
1409
1476
|
declare type Property = PropertyComputedName | PropertyNonComputedName;
|
|
1410
1477
|
declare interface PropertyBase extends BaseNode {
|
|
@@ -1457,6 +1524,57 @@ declare interface PropertyNonComputedName extends PropertyBase {
|
|
|
1457
1524
|
computed: false;
|
|
1458
1525
|
key: PropertyNameNonComputed;
|
|
1459
1526
|
}
|
|
1527
|
+
declare interface PunctuatorToken extends BaseToken {
|
|
1528
|
+
type: AST_TOKEN_TYPES.Punctuator;
|
|
1529
|
+
value: ValueOf<PunctuatorTokenToText>;
|
|
1530
|
+
}
|
|
1531
|
+
declare interface PunctuatorTokenToText extends AssignmentOperatorToText {
|
|
1532
|
+
[SyntaxKind.AmpersandAmpersandToken]: '&&';
|
|
1533
|
+
[SyntaxKind.AmpersandToken]: '&';
|
|
1534
|
+
[SyntaxKind.AsteriskAsteriskToken]: '**';
|
|
1535
|
+
[SyntaxKind.AsteriskToken]: '*';
|
|
1536
|
+
[SyntaxKind.AtToken]: '@';
|
|
1537
|
+
[SyntaxKind.BacktickToken]: '`';
|
|
1538
|
+
[SyntaxKind.BarBarToken]: '||';
|
|
1539
|
+
[SyntaxKind.BarToken]: '|';
|
|
1540
|
+
[SyntaxKind.CaretToken]: '^';
|
|
1541
|
+
[SyntaxKind.CloseBraceToken]: '}';
|
|
1542
|
+
[SyntaxKind.CloseBracketToken]: ']';
|
|
1543
|
+
[SyntaxKind.CloseParenToken]: ')';
|
|
1544
|
+
[SyntaxKind.ColonToken]: ':';
|
|
1545
|
+
[SyntaxKind.CommaToken]: ',';
|
|
1546
|
+
[SyntaxKind.DotDotDotToken]: '...';
|
|
1547
|
+
[SyntaxKind.DotToken]: '.';
|
|
1548
|
+
[SyntaxKind.EqualsEqualsEqualsToken]: '===';
|
|
1549
|
+
[SyntaxKind.EqualsEqualsToken]: '==';
|
|
1550
|
+
[SyntaxKind.EqualsGreaterThanToken]: '=>';
|
|
1551
|
+
[SyntaxKind.ExclamationEqualsEqualsToken]: '!==';
|
|
1552
|
+
[SyntaxKind.ExclamationEqualsToken]: '!=';
|
|
1553
|
+
[SyntaxKind.ExclamationToken]: '!';
|
|
1554
|
+
[SyntaxKind.GreaterThanEqualsToken]: '>=';
|
|
1555
|
+
[SyntaxKind.GreaterThanGreaterThanGreaterThanToken]: '>>>';
|
|
1556
|
+
[SyntaxKind.GreaterThanGreaterThanToken]: '>>';
|
|
1557
|
+
[SyntaxKind.GreaterThanToken]: '>';
|
|
1558
|
+
[SyntaxKind.HashToken]: '#';
|
|
1559
|
+
[SyntaxKind.LessThanEqualsToken]: '<=';
|
|
1560
|
+
[SyntaxKind.LessThanLessThanToken]: '<<';
|
|
1561
|
+
[SyntaxKind.LessThanSlashToken]: '</';
|
|
1562
|
+
[SyntaxKind.LessThanToken]: '<';
|
|
1563
|
+
[SyntaxKind.MinusMinusToken]: '--';
|
|
1564
|
+
[SyntaxKind.MinusToken]: '-';
|
|
1565
|
+
[SyntaxKind.OpenBraceToken]: '{';
|
|
1566
|
+
[SyntaxKind.OpenBracketToken]: '[';
|
|
1567
|
+
[SyntaxKind.OpenParenToken]: '(';
|
|
1568
|
+
[SyntaxKind.PercentToken]: '%';
|
|
1569
|
+
[SyntaxKind.PlusPlusToken]: '++';
|
|
1570
|
+
[SyntaxKind.PlusToken]: '+';
|
|
1571
|
+
[SyntaxKind.QuestionDotToken]: '?.';
|
|
1572
|
+
[SyntaxKind.QuestionQuestionToken]: '??';
|
|
1573
|
+
[SyntaxKind.QuestionToken]: '?';
|
|
1574
|
+
[SyntaxKind.SemicolonToken]: ';';
|
|
1575
|
+
[SyntaxKind.SlashToken]: '/';
|
|
1576
|
+
[SyntaxKind.TildeToken]: '~';
|
|
1577
|
+
}
|
|
1460
1578
|
/**
|
|
1461
1579
|
* An array of two numbers.
|
|
1462
1580
|
* Both numbers are a 0-based index which is the position in the array of source code characters.
|
|
@@ -1470,6 +1588,13 @@ declare interface RegExpLiteral extends LiteralBase {
|
|
|
1470
1588
|
};
|
|
1471
1589
|
value: RegExp | null;
|
|
1472
1590
|
}
|
|
1591
|
+
declare interface RegularExpressionToken extends BaseToken {
|
|
1592
|
+
type: AST_TOKEN_TYPES.RegularExpression;
|
|
1593
|
+
regex: {
|
|
1594
|
+
flags: string;
|
|
1595
|
+
pattern: string;
|
|
1596
|
+
};
|
|
1597
|
+
}
|
|
1473
1598
|
declare interface RestElement extends BaseNode {
|
|
1474
1599
|
type: AST_NODE_TYPES.RestElement;
|
|
1475
1600
|
argument: DestructuringPattern;
|
|
@@ -1508,6 +1633,9 @@ declare interface StaticBlock extends BaseNode {
|
|
|
1508
1633
|
declare interface StringLiteral extends LiteralBase {
|
|
1509
1634
|
value: string;
|
|
1510
1635
|
}
|
|
1636
|
+
declare interface StringToken extends BaseToken {
|
|
1637
|
+
type: AST_TOKEN_TYPES.String;
|
|
1638
|
+
}
|
|
1511
1639
|
declare interface Super extends BaseNode {
|
|
1512
1640
|
type: AST_NODE_TYPES.Super;
|
|
1513
1641
|
}
|
|
@@ -1540,6 +1668,9 @@ declare interface TemplateLiteral extends BaseNode {
|
|
|
1540
1668
|
expressions: Expression[];
|
|
1541
1669
|
quasis: TemplateElement[];
|
|
1542
1670
|
}
|
|
1671
|
+
declare interface TemplateToken extends BaseToken {
|
|
1672
|
+
type: AST_TOKEN_TYPES.Template;
|
|
1673
|
+
}
|
|
1543
1674
|
declare interface ThisExpression extends BaseNode {
|
|
1544
1675
|
type: AST_NODE_TYPES.ThisExpression;
|
|
1545
1676
|
}
|
|
@@ -1547,6 +1678,7 @@ declare interface ThrowStatement extends BaseNode {
|
|
|
1547
1678
|
type: AST_NODE_TYPES.ThrowStatement;
|
|
1548
1679
|
argument: Expression;
|
|
1549
1680
|
}
|
|
1681
|
+
declare type Token = BooleanToken | Comment | IdentifierToken | JSXIdentifierToken | JSXTextToken | KeywordToken | NullToken | NumericToken | PunctuatorToken | RegularExpressionToken | StringToken | TemplateToken;
|
|
1550
1682
|
declare interface TryStatement extends BaseNode {
|
|
1551
1683
|
type: AST_NODE_TYPES.TryStatement;
|
|
1552
1684
|
block: BlockStatement;
|
|
@@ -2262,6 +2394,7 @@ declare interface UsingDeclarationBase extends BaseNode {
|
|
|
2262
2394
|
*/
|
|
2263
2395
|
kind: 'await using' | 'using';
|
|
2264
2396
|
}
|
|
2397
|
+
declare type UsingDeclarator = UsingInForOfDeclarator | UsingInNormalContextDeclarator;
|
|
2265
2398
|
declare interface UsingInForOfDeclaration extends UsingDeclarationBase {
|
|
2266
2399
|
/**
|
|
2267
2400
|
* The variables declared by this declaration.
|
|
@@ -2297,6 +2430,7 @@ declare interface UsingInNormalContextDeclarator extends VariableDeclaratorBase
|
|
|
2297
2430
|
}
|
|
2298
2431
|
declare type ValueOf<T> = T[keyof T];
|
|
2299
2432
|
declare type VariableDeclaration = LetOrConstOrVarDeclaration | UsingDeclaration;
|
|
2433
|
+
declare type VariableDeclarator = LetOrConstOrVarDeclarator | UsingDeclarator;
|
|
2300
2434
|
declare interface VariableDeclaratorBase extends BaseNode {
|
|
2301
2435
|
type: AST_NODE_TYPES.VariableDeclarator;
|
|
2302
2436
|
/**
|
|
@@ -2361,16 +2495,69 @@ declare const isCreateElement: (node: Identifier | MemberExpression, context: _e
|
|
|
2361
2495
|
declare const isCreateRef: (node: Identifier | MemberExpression, context: _eslint_react_types.RuleContext) => boolean;
|
|
2362
2496
|
declare const isForwardRef: (node: Identifier | MemberExpression, context: _eslint_react_types.RuleContext) => boolean;
|
|
2363
2497
|
declare const isMemo: (node: Identifier | MemberExpression, context: _eslint_react_types.RuleContext) => boolean;
|
|
2364
|
-
declare const isChildrenCountCall:
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
declare const
|
|
2373
|
-
|
|
2374
|
-
|
|
2498
|
+
declare const isChildrenCountCall: {
|
|
2499
|
+
(context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression & {
|
|
2500
|
+
callee: MemberExpression;
|
|
2501
|
+
};
|
|
2502
|
+
(node: Node, context: _eslint_react_types.RuleContext): node is CallExpression & {
|
|
2503
|
+
callee: MemberExpression;
|
|
2504
|
+
};
|
|
2505
|
+
};
|
|
2506
|
+
declare const isChildrenForEachCall: {
|
|
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 isChildrenMapCall: {
|
|
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 isChildrenOnlyCall: {
|
|
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 isChildrenToArrayCall: {
|
|
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 isCloneElementCall: {
|
|
2539
|
+
(context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression;
|
|
2540
|
+
(node: Node, context: _eslint_react_types.RuleContext): node is CallExpression;
|
|
2541
|
+
};
|
|
2542
|
+
declare const isCreateContextCall: {
|
|
2543
|
+
(context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression;
|
|
2544
|
+
(node: Node, context: _eslint_react_types.RuleContext): node is CallExpression;
|
|
2545
|
+
};
|
|
2546
|
+
declare const isCreateElementCall: {
|
|
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 isCreateRefCall: {
|
|
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 isForwardRefCall: {
|
|
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 isMemoCall: {
|
|
2559
|
+
(context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression;
|
|
2560
|
+
(node: Node, context: _eslint_react_types.RuleContext): node is CallExpression;
|
|
2561
|
+
};
|
|
2375
2562
|
|
|
2376
|
-
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,
|
|
2563
|
+
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, 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,21 +160,19 @@ 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
|
-
declare function isChildrenOfCreateElement(node: TSESTree.Node, context: RuleContext): boolean;
|
|
170
|
-
|
|
171
169
|
/**
|
|
172
|
-
*
|
|
173
|
-
* @param node The
|
|
170
|
+
* Determines whether inside `createElement`'s children.
|
|
171
|
+
* @param node The AST node to check
|
|
174
172
|
* @param context The rule context
|
|
175
|
-
* @returns `true` if the node is
|
|
173
|
+
* @returns `true` if the node is inside createElement's children
|
|
176
174
|
*/
|
|
177
|
-
declare function
|
|
175
|
+
declare function isChildrenOfCreateElement(node: TSESTree.Node, context: RuleContext): boolean;
|
|
178
176
|
|
|
179
177
|
declare function isInsideReactHook(node: TSESTree.Node): boolean;
|
|
180
178
|
|
|
@@ -316,8 +314,20 @@ declare function isFromReact(name: string): (node: TSESTree.Identifier | TSESTre
|
|
|
316
314
|
* @returns A function that checks if a given node is a member expression of a Pragma member.
|
|
317
315
|
*/
|
|
318
316
|
declare function isFromReactMember(memberName: string, name: string): (node: TSESTree.MemberExpression, context: RuleContext) => boolean;
|
|
319
|
-
|
|
320
|
-
|
|
317
|
+
type IsCallFromReact = {
|
|
318
|
+
(context: RuleContext): (node: TSESTree.Node) => node is TSESTree.CallExpression;
|
|
319
|
+
(node: TSESTree.Node, context: RuleContext): node is TSESTree.CallExpression;
|
|
320
|
+
};
|
|
321
|
+
declare function isCallFromReact(name: string): IsCallFromReact;
|
|
322
|
+
type IsCallFromReactMember = {
|
|
323
|
+
(context: RuleContext): (node: TSESTree.Node) => node is TSESTree.CallExpression & {
|
|
324
|
+
callee: TSESTree.MemberExpression;
|
|
325
|
+
};
|
|
326
|
+
(node: TSESTree.Node, context: RuleContext): node is TSESTree.CallExpression & {
|
|
327
|
+
callee: TSESTree.MemberExpression;
|
|
328
|
+
};
|
|
329
|
+
};
|
|
330
|
+
declare function isCallFromReactMember(pragmaMemberName: string, name: string): IsCallFromReactMember;
|
|
321
331
|
|
|
322
332
|
/**
|
|
323
333
|
* Check if an identifier is initialized from React
|
|
@@ -573,6 +583,21 @@ declare enum AST_NODE_TYPES {
|
|
|
573
583
|
TSUnknownKeyword = "TSUnknownKeyword",
|
|
574
584
|
TSVoidKeyword = "TSVoidKeyword"
|
|
575
585
|
}
|
|
586
|
+
declare enum AST_TOKEN_TYPES {
|
|
587
|
+
Boolean = "Boolean",
|
|
588
|
+
Identifier = "Identifier",
|
|
589
|
+
JSXIdentifier = "JSXIdentifier",
|
|
590
|
+
JSXText = "JSXText",
|
|
591
|
+
Keyword = "Keyword",
|
|
592
|
+
Null = "Null",
|
|
593
|
+
Numeric = "Numeric",
|
|
594
|
+
Punctuator = "Punctuator",
|
|
595
|
+
RegularExpression = "RegularExpression",
|
|
596
|
+
String = "String",
|
|
597
|
+
Template = "Template",
|
|
598
|
+
Block = "Block",
|
|
599
|
+
Line = "Line"
|
|
600
|
+
}
|
|
576
601
|
declare interface AwaitExpression extends BaseNode {
|
|
577
602
|
type: AST_NODE_TYPES.AwaitExpression;
|
|
578
603
|
argument: Expression;
|
|
@@ -580,6 +605,10 @@ declare interface AwaitExpression extends BaseNode {
|
|
|
580
605
|
declare interface BaseNode extends NodeOrTokenData {
|
|
581
606
|
type: AST_NODE_TYPES;
|
|
582
607
|
}
|
|
608
|
+
declare interface BaseToken extends NodeOrTokenData {
|
|
609
|
+
type: AST_TOKEN_TYPES;
|
|
610
|
+
value: string;
|
|
611
|
+
}
|
|
583
612
|
declare interface BigIntLiteral extends LiteralBase {
|
|
584
613
|
bigint: string;
|
|
585
614
|
value: bigint | null;
|
|
@@ -618,6 +647,9 @@ declare interface BinaryOperatorToText {
|
|
|
618
647
|
}
|
|
619
648
|
declare type BindingName = BindingPattern | Identifier;
|
|
620
649
|
declare type BindingPattern = ArrayPattern | ObjectPattern;
|
|
650
|
+
declare interface BlockComment extends BaseToken {
|
|
651
|
+
type: AST_TOKEN_TYPES.Block;
|
|
652
|
+
}
|
|
621
653
|
declare interface BlockStatement extends BaseNode {
|
|
622
654
|
type: AST_NODE_TYPES.BlockStatement;
|
|
623
655
|
body: Statement[];
|
|
@@ -626,6 +658,9 @@ declare interface BooleanLiteral extends LiteralBase {
|
|
|
626
658
|
raw: 'false' | 'true';
|
|
627
659
|
value: boolean;
|
|
628
660
|
}
|
|
661
|
+
declare interface BooleanToken extends BaseToken {
|
|
662
|
+
type: AST_TOKEN_TYPES.Boolean;
|
|
663
|
+
}
|
|
629
664
|
declare interface BreakStatement extends BaseNode {
|
|
630
665
|
type: AST_NODE_TYPES.BreakStatement;
|
|
631
666
|
label: Identifier | null;
|
|
@@ -706,6 +741,7 @@ declare interface ClassBody extends BaseNode {
|
|
|
706
741
|
type: AST_NODE_TYPES.ClassBody;
|
|
707
742
|
body: ClassElement[];
|
|
708
743
|
}
|
|
744
|
+
declare type ClassDeclaration = ClassDeclarationWithName | ClassDeclarationWithOptionalName;
|
|
709
745
|
declare interface ClassDeclarationBase extends ClassBase {
|
|
710
746
|
type: AST_NODE_TYPES.ClassDeclaration;
|
|
711
747
|
}
|
|
@@ -742,6 +778,7 @@ declare interface ClassPropertyDefinitionNonComputedNameBase extends PropertyDef
|
|
|
742
778
|
key: ClassPropertyNameNonComputed;
|
|
743
779
|
}
|
|
744
780
|
declare type ClassPropertyNameNonComputed = PrivateIdentifier | PropertyNameNonComputed;
|
|
781
|
+
declare type Comment = BlockComment | LineComment;
|
|
745
782
|
declare interface ConditionalExpression extends BaseNode {
|
|
746
783
|
type: AST_NODE_TYPES.ConditionalExpression;
|
|
747
784
|
alternate: Expression;
|
|
@@ -1034,6 +1071,7 @@ declare interface FunctionBase extends BaseNode {
|
|
|
1034
1071
|
*/
|
|
1035
1072
|
typeParameters: TSTypeParameterDeclaration | undefined;
|
|
1036
1073
|
}
|
|
1074
|
+
declare type FunctionDeclaration = FunctionDeclarationWithName | FunctionDeclarationWithOptionalName;
|
|
1037
1075
|
declare interface FunctionDeclarationBase extends FunctionBase {
|
|
1038
1076
|
type: AST_NODE_TYPES.FunctionDeclaration;
|
|
1039
1077
|
body: BlockStatement;
|
|
@@ -1070,6 +1108,9 @@ declare interface Identifier extends BaseNode {
|
|
|
1070
1108
|
optional: boolean;
|
|
1071
1109
|
typeAnnotation: TSTypeAnnotation | undefined;
|
|
1072
1110
|
}
|
|
1111
|
+
declare interface IdentifierToken extends BaseToken {
|
|
1112
|
+
type: AST_TOKEN_TYPES.Identifier;
|
|
1113
|
+
}
|
|
1073
1114
|
declare interface IfStatement extends BaseNode {
|
|
1074
1115
|
type: AST_NODE_TYPES.IfStatement;
|
|
1075
1116
|
alternate: Statement | null;
|
|
@@ -1195,6 +1236,9 @@ declare interface JSXIdentifier extends BaseNode {
|
|
|
1195
1236
|
type: AST_NODE_TYPES.JSXIdentifier;
|
|
1196
1237
|
name: string;
|
|
1197
1238
|
}
|
|
1239
|
+
declare interface JSXIdentifierToken extends BaseToken {
|
|
1240
|
+
type: AST_TOKEN_TYPES.JSXIdentifier;
|
|
1241
|
+
}
|
|
1198
1242
|
declare interface JSXMemberExpression extends BaseNode {
|
|
1199
1243
|
type: AST_NODE_TYPES.JSXMemberExpression;
|
|
1200
1244
|
object: JSXTagNameExpression;
|
|
@@ -1229,6 +1273,12 @@ declare interface JSXText extends BaseNode {
|
|
|
1229
1273
|
raw: string;
|
|
1230
1274
|
value: string;
|
|
1231
1275
|
}
|
|
1276
|
+
declare interface JSXTextToken extends BaseToken {
|
|
1277
|
+
type: AST_TOKEN_TYPES.JSXText;
|
|
1278
|
+
}
|
|
1279
|
+
declare interface KeywordToken extends BaseToken {
|
|
1280
|
+
type: AST_TOKEN_TYPES.Keyword;
|
|
1281
|
+
}
|
|
1232
1282
|
declare interface LabeledStatement extends BaseNode {
|
|
1233
1283
|
type: AST_NODE_TYPES.LabeledStatement;
|
|
1234
1284
|
body: Statement;
|
|
@@ -1292,6 +1342,9 @@ declare interface LetOrVarNonDeclaredDeclaration extends LetOrConstOrVarDeclarat
|
|
|
1292
1342
|
declare: false;
|
|
1293
1343
|
kind: 'let' | 'var';
|
|
1294
1344
|
}
|
|
1345
|
+
declare interface LineComment extends BaseToken {
|
|
1346
|
+
type: AST_TOKEN_TYPES.Line;
|
|
1347
|
+
}
|
|
1295
1348
|
declare type Literal = BigIntLiteral | BooleanLiteral | NullLiteral | NumberLiteral | RegExpLiteral | StringLiteral;
|
|
1296
1349
|
declare interface LiteralBase extends BaseNode {
|
|
1297
1350
|
type: AST_NODE_TYPES.Literal;
|
|
@@ -1361,6 +1414,7 @@ declare interface NewExpression extends BaseNode {
|
|
|
1361
1414
|
callee: Expression;
|
|
1362
1415
|
typeArguments: TSTypeParameterInstantiation | undefined;
|
|
1363
1416
|
}
|
|
1417
|
+
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
1418
|
declare interface NodeOrTokenData {
|
|
1365
1419
|
type: string;
|
|
1366
1420
|
/**
|
|
@@ -1375,9 +1429,15 @@ declare interface NullLiteral extends LiteralBase {
|
|
|
1375
1429
|
raw: 'null';
|
|
1376
1430
|
value: null;
|
|
1377
1431
|
}
|
|
1432
|
+
declare interface NullToken extends BaseToken {
|
|
1433
|
+
type: AST_TOKEN_TYPES.Null;
|
|
1434
|
+
}
|
|
1378
1435
|
declare interface NumberLiteral extends LiteralBase {
|
|
1379
1436
|
value: number;
|
|
1380
1437
|
}
|
|
1438
|
+
declare interface NumericToken extends BaseToken {
|
|
1439
|
+
type: AST_TOKEN_TYPES.Numeric;
|
|
1440
|
+
}
|
|
1381
1441
|
declare interface ObjectExpression extends BaseNode {
|
|
1382
1442
|
type: AST_NODE_TYPES.ObjectExpression;
|
|
1383
1443
|
properties: ObjectLiteralElement[];
|
|
@@ -1405,6 +1465,13 @@ declare interface PrivateIdentifier extends BaseNode {
|
|
|
1405
1465
|
type: AST_NODE_TYPES.PrivateIdentifier;
|
|
1406
1466
|
name: string;
|
|
1407
1467
|
}
|
|
1468
|
+
declare interface Program extends NodeOrTokenData {
|
|
1469
|
+
type: AST_NODE_TYPES.Program;
|
|
1470
|
+
body: ProgramStatement[];
|
|
1471
|
+
comments: Comment[] | undefined;
|
|
1472
|
+
sourceType: 'module' | 'script';
|
|
1473
|
+
tokens: Token[] | undefined;
|
|
1474
|
+
}
|
|
1408
1475
|
declare type ProgramStatement = ExportAllDeclaration | ExportDefaultDeclaration | ExportNamedDeclaration | ImportDeclaration | Statement | TSImportEqualsDeclaration | TSNamespaceExportDeclaration;
|
|
1409
1476
|
declare type Property = PropertyComputedName | PropertyNonComputedName;
|
|
1410
1477
|
declare interface PropertyBase extends BaseNode {
|
|
@@ -1457,6 +1524,57 @@ declare interface PropertyNonComputedName extends PropertyBase {
|
|
|
1457
1524
|
computed: false;
|
|
1458
1525
|
key: PropertyNameNonComputed;
|
|
1459
1526
|
}
|
|
1527
|
+
declare interface PunctuatorToken extends BaseToken {
|
|
1528
|
+
type: AST_TOKEN_TYPES.Punctuator;
|
|
1529
|
+
value: ValueOf<PunctuatorTokenToText>;
|
|
1530
|
+
}
|
|
1531
|
+
declare interface PunctuatorTokenToText extends AssignmentOperatorToText {
|
|
1532
|
+
[SyntaxKind.AmpersandAmpersandToken]: '&&';
|
|
1533
|
+
[SyntaxKind.AmpersandToken]: '&';
|
|
1534
|
+
[SyntaxKind.AsteriskAsteriskToken]: '**';
|
|
1535
|
+
[SyntaxKind.AsteriskToken]: '*';
|
|
1536
|
+
[SyntaxKind.AtToken]: '@';
|
|
1537
|
+
[SyntaxKind.BacktickToken]: '`';
|
|
1538
|
+
[SyntaxKind.BarBarToken]: '||';
|
|
1539
|
+
[SyntaxKind.BarToken]: '|';
|
|
1540
|
+
[SyntaxKind.CaretToken]: '^';
|
|
1541
|
+
[SyntaxKind.CloseBraceToken]: '}';
|
|
1542
|
+
[SyntaxKind.CloseBracketToken]: ']';
|
|
1543
|
+
[SyntaxKind.CloseParenToken]: ')';
|
|
1544
|
+
[SyntaxKind.ColonToken]: ':';
|
|
1545
|
+
[SyntaxKind.CommaToken]: ',';
|
|
1546
|
+
[SyntaxKind.DotDotDotToken]: '...';
|
|
1547
|
+
[SyntaxKind.DotToken]: '.';
|
|
1548
|
+
[SyntaxKind.EqualsEqualsEqualsToken]: '===';
|
|
1549
|
+
[SyntaxKind.EqualsEqualsToken]: '==';
|
|
1550
|
+
[SyntaxKind.EqualsGreaterThanToken]: '=>';
|
|
1551
|
+
[SyntaxKind.ExclamationEqualsEqualsToken]: '!==';
|
|
1552
|
+
[SyntaxKind.ExclamationEqualsToken]: '!=';
|
|
1553
|
+
[SyntaxKind.ExclamationToken]: '!';
|
|
1554
|
+
[SyntaxKind.GreaterThanEqualsToken]: '>=';
|
|
1555
|
+
[SyntaxKind.GreaterThanGreaterThanGreaterThanToken]: '>>>';
|
|
1556
|
+
[SyntaxKind.GreaterThanGreaterThanToken]: '>>';
|
|
1557
|
+
[SyntaxKind.GreaterThanToken]: '>';
|
|
1558
|
+
[SyntaxKind.HashToken]: '#';
|
|
1559
|
+
[SyntaxKind.LessThanEqualsToken]: '<=';
|
|
1560
|
+
[SyntaxKind.LessThanLessThanToken]: '<<';
|
|
1561
|
+
[SyntaxKind.LessThanSlashToken]: '</';
|
|
1562
|
+
[SyntaxKind.LessThanToken]: '<';
|
|
1563
|
+
[SyntaxKind.MinusMinusToken]: '--';
|
|
1564
|
+
[SyntaxKind.MinusToken]: '-';
|
|
1565
|
+
[SyntaxKind.OpenBraceToken]: '{';
|
|
1566
|
+
[SyntaxKind.OpenBracketToken]: '[';
|
|
1567
|
+
[SyntaxKind.OpenParenToken]: '(';
|
|
1568
|
+
[SyntaxKind.PercentToken]: '%';
|
|
1569
|
+
[SyntaxKind.PlusPlusToken]: '++';
|
|
1570
|
+
[SyntaxKind.PlusToken]: '+';
|
|
1571
|
+
[SyntaxKind.QuestionDotToken]: '?.';
|
|
1572
|
+
[SyntaxKind.QuestionQuestionToken]: '??';
|
|
1573
|
+
[SyntaxKind.QuestionToken]: '?';
|
|
1574
|
+
[SyntaxKind.SemicolonToken]: ';';
|
|
1575
|
+
[SyntaxKind.SlashToken]: '/';
|
|
1576
|
+
[SyntaxKind.TildeToken]: '~';
|
|
1577
|
+
}
|
|
1460
1578
|
/**
|
|
1461
1579
|
* An array of two numbers.
|
|
1462
1580
|
* Both numbers are a 0-based index which is the position in the array of source code characters.
|
|
@@ -1470,6 +1588,13 @@ declare interface RegExpLiteral extends LiteralBase {
|
|
|
1470
1588
|
};
|
|
1471
1589
|
value: RegExp | null;
|
|
1472
1590
|
}
|
|
1591
|
+
declare interface RegularExpressionToken extends BaseToken {
|
|
1592
|
+
type: AST_TOKEN_TYPES.RegularExpression;
|
|
1593
|
+
regex: {
|
|
1594
|
+
flags: string;
|
|
1595
|
+
pattern: string;
|
|
1596
|
+
};
|
|
1597
|
+
}
|
|
1473
1598
|
declare interface RestElement extends BaseNode {
|
|
1474
1599
|
type: AST_NODE_TYPES.RestElement;
|
|
1475
1600
|
argument: DestructuringPattern;
|
|
@@ -1508,6 +1633,9 @@ declare interface StaticBlock extends BaseNode {
|
|
|
1508
1633
|
declare interface StringLiteral extends LiteralBase {
|
|
1509
1634
|
value: string;
|
|
1510
1635
|
}
|
|
1636
|
+
declare interface StringToken extends BaseToken {
|
|
1637
|
+
type: AST_TOKEN_TYPES.String;
|
|
1638
|
+
}
|
|
1511
1639
|
declare interface Super extends BaseNode {
|
|
1512
1640
|
type: AST_NODE_TYPES.Super;
|
|
1513
1641
|
}
|
|
@@ -1540,6 +1668,9 @@ declare interface TemplateLiteral extends BaseNode {
|
|
|
1540
1668
|
expressions: Expression[];
|
|
1541
1669
|
quasis: TemplateElement[];
|
|
1542
1670
|
}
|
|
1671
|
+
declare interface TemplateToken extends BaseToken {
|
|
1672
|
+
type: AST_TOKEN_TYPES.Template;
|
|
1673
|
+
}
|
|
1543
1674
|
declare interface ThisExpression extends BaseNode {
|
|
1544
1675
|
type: AST_NODE_TYPES.ThisExpression;
|
|
1545
1676
|
}
|
|
@@ -1547,6 +1678,7 @@ declare interface ThrowStatement extends BaseNode {
|
|
|
1547
1678
|
type: AST_NODE_TYPES.ThrowStatement;
|
|
1548
1679
|
argument: Expression;
|
|
1549
1680
|
}
|
|
1681
|
+
declare type Token = BooleanToken | Comment | IdentifierToken | JSXIdentifierToken | JSXTextToken | KeywordToken | NullToken | NumericToken | PunctuatorToken | RegularExpressionToken | StringToken | TemplateToken;
|
|
1550
1682
|
declare interface TryStatement extends BaseNode {
|
|
1551
1683
|
type: AST_NODE_TYPES.TryStatement;
|
|
1552
1684
|
block: BlockStatement;
|
|
@@ -2262,6 +2394,7 @@ declare interface UsingDeclarationBase extends BaseNode {
|
|
|
2262
2394
|
*/
|
|
2263
2395
|
kind: 'await using' | 'using';
|
|
2264
2396
|
}
|
|
2397
|
+
declare type UsingDeclarator = UsingInForOfDeclarator | UsingInNormalContextDeclarator;
|
|
2265
2398
|
declare interface UsingInForOfDeclaration extends UsingDeclarationBase {
|
|
2266
2399
|
/**
|
|
2267
2400
|
* The variables declared by this declaration.
|
|
@@ -2297,6 +2430,7 @@ declare interface UsingInNormalContextDeclarator extends VariableDeclaratorBase
|
|
|
2297
2430
|
}
|
|
2298
2431
|
declare type ValueOf<T> = T[keyof T];
|
|
2299
2432
|
declare type VariableDeclaration = LetOrConstOrVarDeclaration | UsingDeclaration;
|
|
2433
|
+
declare type VariableDeclarator = LetOrConstOrVarDeclarator | UsingDeclarator;
|
|
2300
2434
|
declare interface VariableDeclaratorBase extends BaseNode {
|
|
2301
2435
|
type: AST_NODE_TYPES.VariableDeclarator;
|
|
2302
2436
|
/**
|
|
@@ -2361,16 +2495,69 @@ declare const isCreateElement: (node: Identifier | MemberExpression, context: _e
|
|
|
2361
2495
|
declare const isCreateRef: (node: Identifier | MemberExpression, context: _eslint_react_types.RuleContext) => boolean;
|
|
2362
2496
|
declare const isForwardRef: (node: Identifier | MemberExpression, context: _eslint_react_types.RuleContext) => boolean;
|
|
2363
2497
|
declare const isMemo: (node: Identifier | MemberExpression, context: _eslint_react_types.RuleContext) => boolean;
|
|
2364
|
-
declare const isChildrenCountCall:
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
declare const
|
|
2373
|
-
|
|
2374
|
-
|
|
2498
|
+
declare const isChildrenCountCall: {
|
|
2499
|
+
(context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression & {
|
|
2500
|
+
callee: MemberExpression;
|
|
2501
|
+
};
|
|
2502
|
+
(node: Node, context: _eslint_react_types.RuleContext): node is CallExpression & {
|
|
2503
|
+
callee: MemberExpression;
|
|
2504
|
+
};
|
|
2505
|
+
};
|
|
2506
|
+
declare const isChildrenForEachCall: {
|
|
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 isChildrenMapCall: {
|
|
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 isChildrenOnlyCall: {
|
|
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 isChildrenToArrayCall: {
|
|
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 isCloneElementCall: {
|
|
2539
|
+
(context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression;
|
|
2540
|
+
(node: Node, context: _eslint_react_types.RuleContext): node is CallExpression;
|
|
2541
|
+
};
|
|
2542
|
+
declare const isCreateContextCall: {
|
|
2543
|
+
(context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression;
|
|
2544
|
+
(node: Node, context: _eslint_react_types.RuleContext): node is CallExpression;
|
|
2545
|
+
};
|
|
2546
|
+
declare const isCreateElementCall: {
|
|
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 isCreateRefCall: {
|
|
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 isForwardRefCall: {
|
|
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 isMemoCall: {
|
|
2559
|
+
(context: _eslint_react_types.RuleContext): (node: Node) => node is CallExpression;
|
|
2560
|
+
(node: Node, context: _eslint_react_types.RuleContext): node is CallExpression;
|
|
2561
|
+
};
|
|
2375
2562
|
|
|
2376
|
-
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,
|
|
2563
|
+
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, 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,31 +131,23 @@ var isMemoCall = isReactAPICallWithName("memo");
|
|
|
129
131
|
// src/element/hierarchy.ts
|
|
130
132
|
function isInsideCreateElementProps(node, context) {
|
|
131
133
|
return eff.F.pipe(
|
|
132
|
-
|
|
133
|
-
eff.O.
|
|
134
|
-
eff.O.
|
|
135
|
-
eff.O.
|
|
136
|
-
eff.O.
|
|
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(
|
|
145
|
+
eff.O.filter(isCreateElementCall(context)),
|
|
145
146
|
eff.O.exists(
|
|
146
147
|
(n) => n.arguments.slice(2).some((arg) => arg === node)
|
|
147
148
|
)
|
|
148
149
|
);
|
|
149
150
|
}
|
|
150
|
-
function isFragmentElement(node, context) {
|
|
151
|
-
const settings = shared.decodeSettings(context.settings);
|
|
152
|
-
const { jsxPragma = "React", jsxPragmaFrag = "Fragment" } = settings;
|
|
153
|
-
const { name } = node.openingElement;
|
|
154
|
-
if (name.type === types.AST_NODE_TYPES.JSXIdentifier && name.name === jsxPragmaFrag) return true;
|
|
155
|
-
return name.type === types.AST_NODE_TYPES.JSXMemberExpression && name.object.type === types.AST_NODE_TYPES.JSXIdentifier && (name.object.name === jsxPragma || isInitializedFromReact(name.object.name, context.sourceCode.getScope(node), settings)) && name.property.name === jsxPragmaFrag;
|
|
156
|
-
}
|
|
157
151
|
|
|
158
152
|
// src/hook/hook-name.ts
|
|
159
153
|
var RE_HOOK_NAME = /^use[A-Z\d]/u;
|
|
@@ -255,23 +249,22 @@ function useHookCollector() {
|
|
|
255
249
|
const onFunctionEnter = (node) => {
|
|
256
250
|
const id = AST9__namespace.getFunctionIdentifier(node);
|
|
257
251
|
const name = eff.O.flatMapNullable(id, (id2) => id2.name);
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
fStack.push([node, eff.O.
|
|
252
|
+
if (eff.O.isSome(id) && eff.O.isSome(name) && isReactHookName(name.value)) {
|
|
253
|
+
const key = uid.rnd();
|
|
254
|
+
fStack.push([node, eff.O.some(key)]);
|
|
255
|
+
hooks.set(key, {
|
|
256
|
+
_: key,
|
|
257
|
+
id,
|
|
258
|
+
kind: "function",
|
|
259
|
+
name,
|
|
260
|
+
node,
|
|
261
|
+
flag: 0n,
|
|
262
|
+
hint: 0n,
|
|
263
|
+
hookCalls: []
|
|
264
|
+
});
|
|
261
265
|
return;
|
|
262
266
|
}
|
|
263
|
-
|
|
264
|
-
fStack.push([node, eff.O.some(key)]);
|
|
265
|
-
hooks.set(key, {
|
|
266
|
-
_: key,
|
|
267
|
-
id,
|
|
268
|
-
kind: "function",
|
|
269
|
-
name,
|
|
270
|
-
node,
|
|
271
|
-
flag: 0n,
|
|
272
|
-
hint: 0n,
|
|
273
|
-
hookCalls: []
|
|
274
|
-
});
|
|
267
|
+
fStack.push([node, eff.O.none()]);
|
|
275
268
|
};
|
|
276
269
|
const onFunctionExit = () => {
|
|
277
270
|
fStack.pop();
|
|
@@ -669,14 +662,14 @@ function isDeclaredInRenderPropLoose(node) {
|
|
|
669
662
|
}
|
|
670
663
|
function isRenderFunctionLoose(node, context) {
|
|
671
664
|
const { body, parent } = node;
|
|
672
|
-
|
|
673
|
-
if (eff.O.isSome(maybeId) && !maybeId.value.name.startsWith("render")) {
|
|
665
|
+
if (eff.O.exists(AST9__namespace.getFunctionIdentifier(node), (id) => id.name.startsWith("render"))) {
|
|
674
666
|
return parent.type === types.AST_NODE_TYPES.JSXExpressionContainer && parent.parent.type === types.AST_NODE_TYPES.JSXAttribute && parent.parent.name.type === types.AST_NODE_TYPES.JSXIdentifier && parent.parent.name.name.startsWith("render");
|
|
675
667
|
}
|
|
676
|
-
const jsxCtx = { getScope: (node2) => context.sourceCode.getScope(node2) };
|
|
677
668
|
return JSX4__namespace.isJSXValue(
|
|
678
669
|
body,
|
|
679
|
-
|
|
670
|
+
{
|
|
671
|
+
getScope: (node2) => context.sourceCode.getScope(node2)
|
|
672
|
+
},
|
|
680
673
|
JSX4__namespace.JSXValueHint.SkipNullLiteral | JSX4__namespace.JSXValueHint.SkipUndefinedLiteral | JSX4__namespace.JSXValueHint.StrictLogical | JSX4__namespace.JSXValueHint.StrictConditional
|
|
681
674
|
);
|
|
682
675
|
}
|
|
@@ -732,7 +725,6 @@ exports.isDeclaredInRenderPropLoose = isDeclaredInRenderPropLoose;
|
|
|
732
725
|
exports.isDirectValueOfRenderPropertyLoose = isDirectValueOfRenderPropertyLoose;
|
|
733
726
|
exports.isForwardRef = isForwardRef;
|
|
734
727
|
exports.isForwardRefCall = isForwardRefCall;
|
|
735
|
-
exports.isFragmentElement = isFragmentElement;
|
|
736
728
|
exports.isFromReact = isFromReact;
|
|
737
729
|
exports.isFromReactMember = isFromReactMember;
|
|
738
730
|
exports.isFunctionOfRenderMethod = isFunctionOfRenderMethod;
|
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,31 +104,23 @@ var isMemoCall = isReactAPICallWithName("memo");
|
|
|
102
104
|
// src/element/hierarchy.ts
|
|
103
105
|
function isInsideCreateElementProps(node, context) {
|
|
104
106
|
return F.pipe(
|
|
105
|
-
|
|
106
|
-
O.
|
|
107
|
-
O.
|
|
108
|
-
O.
|
|
109
|
-
O.
|
|
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(
|
|
118
|
+
O.filter(isCreateElementCall(context)),
|
|
118
119
|
O.exists(
|
|
119
120
|
(n) => n.arguments.slice(2).some((arg) => arg === node)
|
|
120
121
|
)
|
|
121
122
|
);
|
|
122
123
|
}
|
|
123
|
-
function isFragmentElement(node, context) {
|
|
124
|
-
const settings = decodeSettings(context.settings);
|
|
125
|
-
const { jsxPragma = "React", jsxPragmaFrag = "Fragment" } = settings;
|
|
126
|
-
const { name } = node.openingElement;
|
|
127
|
-
if (name.type === AST_NODE_TYPES.JSXIdentifier && name.name === jsxPragmaFrag) return true;
|
|
128
|
-
return name.type === AST_NODE_TYPES.JSXMemberExpression && name.object.type === AST_NODE_TYPES.JSXIdentifier && (name.object.name === jsxPragma || isInitializedFromReact(name.object.name, context.sourceCode.getScope(node), settings)) && name.property.name === jsxPragmaFrag;
|
|
129
|
-
}
|
|
130
124
|
|
|
131
125
|
// src/hook/hook-name.ts
|
|
132
126
|
var RE_HOOK_NAME = /^use[A-Z\d]/u;
|
|
@@ -228,23 +222,22 @@ function useHookCollector() {
|
|
|
228
222
|
const onFunctionEnter = (node) => {
|
|
229
223
|
const id = AST9.getFunctionIdentifier(node);
|
|
230
224
|
const name = O.flatMapNullable(id, (id2) => id2.name);
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
fStack.push([node, O.
|
|
225
|
+
if (O.isSome(id) && O.isSome(name) && isReactHookName(name.value)) {
|
|
226
|
+
const key = uid.rnd();
|
|
227
|
+
fStack.push([node, O.some(key)]);
|
|
228
|
+
hooks.set(key, {
|
|
229
|
+
_: key,
|
|
230
|
+
id,
|
|
231
|
+
kind: "function",
|
|
232
|
+
name,
|
|
233
|
+
node,
|
|
234
|
+
flag: 0n,
|
|
235
|
+
hint: 0n,
|
|
236
|
+
hookCalls: []
|
|
237
|
+
});
|
|
234
238
|
return;
|
|
235
239
|
}
|
|
236
|
-
|
|
237
|
-
fStack.push([node, O.some(key)]);
|
|
238
|
-
hooks.set(key, {
|
|
239
|
-
_: key,
|
|
240
|
-
id,
|
|
241
|
-
kind: "function",
|
|
242
|
-
name,
|
|
243
|
-
node,
|
|
244
|
-
flag: 0n,
|
|
245
|
-
hint: 0n,
|
|
246
|
-
hookCalls: []
|
|
247
|
-
});
|
|
240
|
+
fStack.push([node, O.none()]);
|
|
248
241
|
};
|
|
249
242
|
const onFunctionExit = () => {
|
|
250
243
|
fStack.pop();
|
|
@@ -642,14 +635,14 @@ function isDeclaredInRenderPropLoose(node) {
|
|
|
642
635
|
}
|
|
643
636
|
function isRenderFunctionLoose(node, context) {
|
|
644
637
|
const { body, parent } = node;
|
|
645
|
-
|
|
646
|
-
if (O.isSome(maybeId) && !maybeId.value.name.startsWith("render")) {
|
|
638
|
+
if (O.exists(AST9.getFunctionIdentifier(node), (id) => id.name.startsWith("render"))) {
|
|
647
639
|
return parent.type === AST_NODE_TYPES.JSXExpressionContainer && parent.parent.type === AST_NODE_TYPES.JSXAttribute && parent.parent.name.type === AST_NODE_TYPES.JSXIdentifier && parent.parent.name.name.startsWith("render");
|
|
648
640
|
}
|
|
649
|
-
const jsxCtx = { getScope: (node2) => context.sourceCode.getScope(node2) };
|
|
650
641
|
return JSX4.isJSXValue(
|
|
651
642
|
body,
|
|
652
|
-
|
|
643
|
+
{
|
|
644
|
+
getScope: (node2) => context.sourceCode.getScope(node2)
|
|
645
|
+
},
|
|
653
646
|
JSX4.JSXValueHint.SkipNullLiteral | JSX4.JSXValueHint.SkipUndefinedLiteral | JSX4.JSXValueHint.StrictLogical | JSX4.JSXValueHint.StrictConditional
|
|
654
647
|
);
|
|
655
648
|
}
|
|
@@ -662,4 +655,4 @@ function isThisSetState(node) {
|
|
|
662
655
|
return callee.type === AST_NODE_TYPES.MemberExpression && AST9.isThisExpression(callee.object) && callee.property.type === AST_NODE_TYPES.Identifier && callee.property.name === "setState";
|
|
663
656
|
}
|
|
664
657
|
|
|
665
|
-
export { DEFAULT_COMPONENT_HINT, ERClassComponentFlag, ERComponentHint, ERFunctionComponentFlag, ERPhaseRelevance, 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,
|
|
658
|
+
export { DEFAULT_COMPONENT_HINT, ERClassComponentFlag, ERComponentHint, ERFunctionComponentFlag, ERPhaseRelevance, 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, 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eslint-react/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.23.0-beta.0",
|
|
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.
|
|
43
|
-
"@eslint-react/
|
|
44
|
-
"@eslint-react/
|
|
45
|
-
"@eslint-react/
|
|
46
|
-
"@eslint-react/var": "1.
|
|
47
|
-
"@eslint-react/
|
|
42
|
+
"@eslint-react/ast": "1.23.0-beta.0",
|
|
43
|
+
"@eslint-react/eff": "1.23.0-beta.0",
|
|
44
|
+
"@eslint-react/shared": "1.23.0-beta.0",
|
|
45
|
+
"@eslint-react/jsx": "1.23.0-beta.0",
|
|
46
|
+
"@eslint-react/var": "1.23.0-beta.0",
|
|
47
|
+
"@eslint-react/types": "1.23.0-beta.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"tsup": "^8.3.5",
|