Skip to content

Commit 385bedb

Browse files
authored
fix(utils): add missing entries to the RuleListener selectors list (typescript-eslint#9992)
* fix(utils): add missing entries to the RuleListener selectors list * fix knip err
1 parent 343710e commit 385bedb

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

knip.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ export default {
6565
entry: ['src/use-at-your-own-risk.ts'],
6666
ignore: ['tests/fixtures/**'],
6767
},
68+
'packages/utils': {
69+
ignore: ['tests/**/*.type-test.ts'],
70+
},
6871
'packages/website': {
6972
entry: [
7073
'docusaurus.config.mts',

packages/utils/src/ts-eslint/Rule.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,6 @@ interface RuleListenerBaseSelectors {
423423
AssignmentExpression?: RuleFunction<TSESTree.AssignmentExpression>;
424424
AssignmentPattern?: RuleFunction<TSESTree.AssignmentPattern>;
425425
AwaitExpression?: RuleFunction<TSESTree.AwaitExpression>;
426-
BigIntLiteral?: RuleFunction<TSESTree.BigIntLiteral>;
427426
BinaryExpression?: RuleFunction<TSESTree.BinaryExpression>;
428427
BlockStatement?: RuleFunction<TSESTree.BlockStatement>;
429428
BreakStatement?: RuleFunction<TSESTree.BreakStatement>;
@@ -451,6 +450,7 @@ interface RuleListenerBaseSelectors {
451450
FunctionExpression?: RuleFunction<TSESTree.FunctionExpression>;
452451
Identifier?: RuleFunction<TSESTree.Identifier>;
453452
IfStatement?: RuleFunction<TSESTree.IfStatement>;
453+
ImportAttribute?: RuleFunction<TSESTree.ImportAttribute>;
454454
ImportDeclaration?: RuleFunction<TSESTree.ImportDeclaration>;
455455
ImportDefaultSpecifier?: RuleFunction<TSESTree.ImportDefaultSpecifier>;
456456
ImportExpression?: RuleFunction<TSESTree.ImportExpression>;
@@ -465,6 +465,7 @@ interface RuleListenerBaseSelectors {
465465
JSXFragment?: RuleFunction<TSESTree.JSXFragment>;
466466
JSXIdentifier?: RuleFunction<TSESTree.JSXIdentifier>;
467467
JSXMemberExpression?: RuleFunction<TSESTree.JSXMemberExpression>;
468+
JSXNamespacedName?: RuleFunction<TSESTree.JSXNamespacedName>;
468469
JSXOpeningElement?: RuleFunction<TSESTree.JSXOpeningElement>;
469470
JSXOpeningFragment?: RuleFunction<TSESTree.JSXOpeningFragment>;
470471
JSXSpreadAttribute?: RuleFunction<TSESTree.JSXSpreadAttribute>;
@@ -479,13 +480,15 @@ interface RuleListenerBaseSelectors {
479480
NewExpression?: RuleFunction<TSESTree.NewExpression>;
480481
ObjectExpression?: RuleFunction<TSESTree.ObjectExpression>;
481482
ObjectPattern?: RuleFunction<TSESTree.ObjectPattern>;
483+
PrivateIdentifier?: RuleFunction<TSESTree.PrivateIdentifier>;
482484
Program?: RuleFunction<TSESTree.Program>;
483485
Property?: RuleFunction<TSESTree.Property>;
484486
PropertyDefinition?: RuleFunction<TSESTree.PropertyDefinition>;
485487
RestElement?: RuleFunction<TSESTree.RestElement>;
486488
ReturnStatement?: RuleFunction<TSESTree.ReturnStatement>;
487489
SequenceExpression?: RuleFunction<TSESTree.SequenceExpression>;
488490
SpreadElement?: RuleFunction<TSESTree.SpreadElement>;
491+
StaticBlock?: RuleFunction<TSESTree.StaticBlock>;
489492
Super?: RuleFunction<TSESTree.Super>;
490493
SwitchCase?: RuleFunction<TSESTree.SwitchCase>;
491494
SwitchStatement?: RuleFunction<TSESTree.SwitchStatement>;
@@ -495,6 +498,7 @@ interface RuleListenerBaseSelectors {
495498
ThisExpression?: RuleFunction<TSESTree.ThisExpression>;
496499
ThrowStatement?: RuleFunction<TSESTree.ThrowStatement>;
497500
TryStatement?: RuleFunction<TSESTree.TryStatement>;
501+
TSAbstractAccessorProperty?: RuleFunction<TSESTree.TSAbstractAccessorProperty>;
498502
TSAbstractKeyword?: RuleFunction<TSESTree.TSAbstractKeyword>;
499503
TSAbstractMethodDefinition?: RuleFunction<TSESTree.TSAbstractMethodDefinition>;
500504
TSAbstractPropertyDefinition?: RuleFunction<TSESTree.TSAbstractPropertyDefinition>;
@@ -512,6 +516,7 @@ interface RuleListenerBaseSelectors {
512516
TSDeclareFunction?: RuleFunction<TSESTree.TSDeclareFunction>;
513517
TSDeclareKeyword?: RuleFunction<TSESTree.TSDeclareKeyword>;
514518
TSEmptyBodyFunctionExpression?: RuleFunction<TSESTree.TSEmptyBodyFunctionExpression>;
519+
TSEnumBody?: RuleFunction<TSESTree.TSEnumBody>;
515520
TSEnumDeclaration?: RuleFunction<TSESTree.TSEnumDeclaration>;
516521
TSEnumMember?: RuleFunction<TSESTree.TSEnumMember>;
517522
TSExportAssignment?: RuleFunction<TSESTree.TSExportAssignment>;
@@ -523,15 +528,18 @@ interface RuleListenerBaseSelectors {
523528
TSIndexedAccessType?: RuleFunction<TSESTree.TSIndexedAccessType>;
524529
TSIndexSignature?: RuleFunction<TSESTree.TSIndexSignature>;
525530
TSInferType?: RuleFunction<TSESTree.TSInferType>;
531+
TSInstantiationExpression?: RuleFunction<TSESTree.TSInstantiationExpression>;
526532
TSInterfaceBody?: RuleFunction<TSESTree.TSInterfaceBody>;
527533
TSInterfaceDeclaration?: RuleFunction<TSESTree.TSInterfaceDeclaration>;
528534
TSInterfaceHeritage?: RuleFunction<TSESTree.TSInterfaceHeritage>;
529535
TSIntersectionType?: RuleFunction<TSESTree.TSIntersectionType>;
536+
TSIntrinsicKeyword?: RuleFunction<TSESTree.TSIntrinsicKeyword>;
530537
TSLiteralType?: RuleFunction<TSESTree.TSLiteralType>;
531538
TSMappedType?: RuleFunction<TSESTree.TSMappedType>;
532539
TSMethodSignature?: RuleFunction<TSESTree.TSMethodSignature>;
533540
TSModuleBlock?: RuleFunction<TSESTree.TSModuleBlock>;
534541
TSModuleDeclaration?: RuleFunction<TSESTree.TSModuleDeclaration>;
542+
TSNamedTupleMember?: RuleFunction<TSESTree.TSNamedTupleMember>;
535543
TSNamespaceExportDeclaration?: RuleFunction<TSESTree.TSNamespaceExportDeclaration>;
536544
TSNeverKeyword?: RuleFunction<TSESTree.TSNeverKeyword>;
537545
TSNonNullExpression?: RuleFunction<TSESTree.TSNonNullExpression>;
@@ -551,6 +559,7 @@ interface RuleListenerBaseSelectors {
551559
TSStaticKeyword?: RuleFunction<TSESTree.TSStaticKeyword>;
552560
TSStringKeyword?: RuleFunction<TSESTree.TSStringKeyword>;
553561
TSSymbolKeyword?: RuleFunction<TSESTree.TSSymbolKeyword>;
562+
TSTemplateLiteralType?: RuleFunction<TSESTree.TSTemplateLiteralType>;
554563
TSThisType?: RuleFunction<TSESTree.TSThisType>;
555564
TSTupleType?: RuleFunction<TSESTree.TSTupleType>;
556565
TSTypeAliasDeclaration?: RuleFunction<TSESTree.TSTypeAliasDeclaration>;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import type { TSESTree } from '@typescript-eslint/types';
2+
3+
import type { RuleListener } from '../../src/ts-eslint';
4+
5+
type RuleListenerKeysWithoutIndexSignature = {
6+
[K in keyof RuleListener as string extends K ? never : K]: K;
7+
};
8+
9+
type RuleListenerSelectors = NonNullable<
10+
RuleListenerKeysWithoutIndexSignature[keyof RuleListenerKeysWithoutIndexSignature]
11+
>;
12+
13+
type AllSelectors =
14+
| `${TSESTree.AST_NODE_TYPES}`
15+
| `${TSESTree.AST_NODE_TYPES}:exit`;
16+
17+
type ExpectNever<T extends never> = T;
18+
19+
type SelectorsWithWrongNodeType = {
20+
[K in TSESTree.AST_NODE_TYPES]: Parameters<
21+
NonNullable<RuleListener[K]>
22+
>[0]['type'] extends K
23+
? K extends Parameters<NonNullable<RuleListener[K]>>[0]['type']
24+
? never
25+
: K
26+
: K;
27+
}[TSESTree.AST_NODE_TYPES];
28+
type _test_rule_listener_selectors_have_correct_node_types =
29+
ExpectNever<SelectorsWithWrongNodeType>;
30+
31+
type ExtraSelectors = Exclude<RuleListenerSelectors, AllSelectors>;
32+
type _test_rule_listener_does_not_define_extra_selectors =
33+
ExpectNever<ExtraSelectors>;
34+
35+
type MissingSelectors = Exclude<AllSelectors, RuleListenerSelectors>;
36+
type _test_rule_listener_has_selectors_for_all_node_types =
37+
ExpectNever<MissingSelectors>;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy