Skip to content
This repository was archived by the owner on Mar 7, 2025. It is now read-only.

Commit 2673552

Browse files
authored
Sync to eslint Linter.Rule types (#173)
1 parent cd23dd9 commit 2673552

File tree

2 files changed

+42
-5
lines changed

2 files changed

+42
-5
lines changed

src/rules/rule-config.d.ts

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,31 @@
1-
import type { RuleSeverity } from './rule-severity';
1+
import type { RuleLevel } from './rule-severity';
2+
3+
// Synced to https://github.com/DefinitelyTyped/DefinitelyTyped/blob/042141ce5f77f36df01c344ad09f32feda26c4fd/types/eslint/helpers.d.ts#L1-L3
4+
5+
export type Prepend<Tuple extends any[], Addend> = ((
6+
_: Addend,
7+
..._1: Tuple
8+
) => any) extends (..._: infer Result) => any
9+
? Result
10+
: never;
11+
12+
// Synced to https://github.com/DefinitelyTyped/DefinitelyTyped/blob/042141ce5f77f36df01c344ad09f32feda26c4fd/types/eslint/index.d.ts#L717-L719
13+
14+
/**
15+
* Rule configuration.
16+
*/
17+
export type RuleLevelAndOptions<Options extends any[] = any[]> = Prepend<
18+
Partial<Options>,
19+
RuleLevel
20+
>;
21+
22+
export type RuleEntry<Options extends any[] = any[]> =
23+
| RuleLevel
24+
| RuleLevelAndOptions<Options>;
225

326
/**
427
* Rule configuration.
28+
*
29+
* @alias RuleEntry
530
*/
6-
export type RuleConfig<Options extends unknown[] = unknown[]> =
7-
| RuleSeverity
8-
| [RuleSeverity, ...Options];
31+
export type RuleConfig<Options extends any[] = any[]> = RuleEntry<Options>;

src/rules/rule-severity.d.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,18 @@
1+
// Synced to https://github.com/DefinitelyTyped/DefinitelyTyped/blob/042141ce5f77f36df01c344ad09f32feda26c4fd/types/eslint/index.d.ts#L714-L716
2+
3+
/**
4+
* Rule ordinal severity.
5+
*/
6+
export type Severity = 0 | 1 | 2;
7+
8+
/**
9+
* Rule severity.
10+
*/
11+
export type RuleLevel = Severity | 'off' | 'warn' | 'error';
12+
113
/**
214
* Rule severity.
15+
*
16+
* @alias RuleLevel
317
*/
4-
export type RuleSeverity = 'off' | 'warn' | 'error' | 0 | 1 | 2;
18+
export type RuleSeverity = RuleLevel;

0 commit comments

Comments
 (0)