forked from eslint-types/eslint-define-config
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: types with intellisense (eslint-types#152)
- Loading branch information
Showing
3 changed files
with
81 additions
and
20 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
export type Severity = 0 | 1 | 2; | ||
export type RuleLevel = Severity | 'off' | 'warn' | 'error'; | ||
|
||
type Rule<ARGS extends [RuleLevel, ...any[]]> = | ||
| (ARGS extends [RuleLevel] | ||
? [RuleLevel] | ||
: ARGS extends [RuleLevel, infer A] | ||
? [RuleLevel, A?] | ||
: ARGS extends [RuleLevel, infer A, infer B] | ||
? [RuleLevel, A?, B?] | ||
: ARGS extends [RuleLevel, infer A, infer B, infer C] | ||
? [RuleLevel, A?, B?, C?] | ||
: never) | ||
| RuleLevel; | ||
|
||
export type ARule = { | ||
'a-rule': Rule<[RuleLevel]>; | ||
// ^? | ||
// (property) 'a-rule': Rule<[RuleLevel]> | ||
}; | ||
export type BRule = { | ||
'b-rule': Rule<[RuleLevel, 'a' | 'b']>; | ||
// ^? | ||
// (property) 'b-rule': Rule<[RuleLevel, "a" | "b"]> | ||
}; | ||
export type CRule = { | ||
'c-rule': Rule<[RuleLevel, 'a' | 'b', { optional: boolean }]>; | ||
// ^? | ||
// (property) 'c-rule': Rule<[RuleLevel, "a" | "b", { optional: boolean; }]> | ||
}; | ||
export type DRule = { | ||
'd-rule': Rule< | ||
// ^? | ||
// (property) 'd-rule': Rule<[RuleLevel, "a" | "b", { optional: boolean; }, { extended: boolean; }]> | ||
[RuleLevel, 'a' | 'b', { optional: boolean }, { extended: boolean }] | ||
>; | ||
}; | ||
|
||
export type IntellisenceRules = ARule & BRule & CRule & DRule; |
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