-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(utils): add missing entries to the RuleListener selectors list (#…
…9992) * fix(utils): add missing entries to the RuleListener selectors list * fix knip err
- Loading branch information
Showing
3 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import type { TSESTree } from '@typescript-eslint/types'; | ||
|
||
import type { RuleListener } from '../../src/ts-eslint'; | ||
|
||
type RuleListenerKeysWithoutIndexSignature = { | ||
[K in keyof RuleListener as string extends K ? never : K]: K; | ||
}; | ||
|
||
type RuleListenerSelectors = NonNullable< | ||
RuleListenerKeysWithoutIndexSignature[keyof RuleListenerKeysWithoutIndexSignature] | ||
>; | ||
|
||
type AllSelectors = | ||
| `${TSESTree.AST_NODE_TYPES}` | ||
| `${TSESTree.AST_NODE_TYPES}:exit`; | ||
|
||
type ExpectNever<T extends never> = T; | ||
|
||
type SelectorsWithWrongNodeType = { | ||
[K in TSESTree.AST_NODE_TYPES]: Parameters< | ||
NonNullable<RuleListener[K]> | ||
>[0]['type'] extends K | ||
? K extends Parameters<NonNullable<RuleListener[K]>>[0]['type'] | ||
? never | ||
: K | ||
: K; | ||
}[TSESTree.AST_NODE_TYPES]; | ||
type _test_rule_listener_selectors_have_correct_node_types = | ||
ExpectNever<SelectorsWithWrongNodeType>; | ||
|
||
type ExtraSelectors = Exclude<RuleListenerSelectors, AllSelectors>; | ||
type _test_rule_listener_does_not_define_extra_selectors = | ||
ExpectNever<ExtraSelectors>; | ||
|
||
type MissingSelectors = Exclude<AllSelectors, RuleListenerSelectors>; | ||
type _test_rule_listener_has_selectors_for_all_node_types = | ||
ExpectNever<MissingSelectors>; |