forked from conventional-changelog/commitlint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload.ts
128 lines (113 loc) Β· 3.2 KB
/
load.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import {TargetCaseType} from './ensure';
import {Rule, RuleCondition} from './rules';
export type PluginRecords = Record<string, Plugin>;
export interface Plugin {
rules: {
[ruleName: string]: Rule<unknown>;
};
}
export interface LoadOptions {
cwd?: string;
file?: string;
}
export enum RuleSeverity {
Disabled = 0,
Warning = 1,
Error = 2
}
export type RuleConfigTuple<T> = T extends void
? Readonly<[RuleSeverity, RuleCondition]>
: Readonly<[RuleSeverity, RuleCondition, T]>;
export enum RuleConfigQuality {
User,
Qualified
}
export type QualifiedRuleConfig<T> =
| (() => RuleConfigTuple<T>)
| (() => RuleConfigTuple<Promise<T>>)
| RuleConfigTuple<T>;
export type RuleConfig<
V = RuleConfigQuality.Qualified,
T = void
> = V extends RuleConfigQuality.Qualified
? RuleConfigTuple<T>
: QualifiedRuleConfig<T>;
export type CaseRuleConfig<V = RuleConfigQuality.User> = RuleConfig<
V,
TargetCaseType
>;
export type LengthRuleConfig<V = RuleConfigQuality.User> = RuleConfig<
V,
number
>;
export type EnumRuleConfig<V = RuleConfigQuality.User> = RuleConfig<
V,
string[]
>;
export type RulesConfig<V = RuleConfigQuality.User> = {
'body-case': CaseRuleConfig<V>;
'body-empty': RuleConfig<V>;
'body-leading-blank': RuleConfig<V>;
'body-max-length': LengthRuleConfig<V>;
'body-max-line-length': LengthRuleConfig<V>;
'body-min-length': LengthRuleConfig<V>;
'footer-empty': RuleConfig<V>;
'footer-leading-blank': RuleConfig<V>;
'footer-max-length': LengthRuleConfig<V>;
'footer-max-line-length': LengthRuleConfig<V>;
'footer-min-length': LengthRuleConfig<V>;
'header-case': CaseRuleConfig<V>;
'header-full-stop': RuleConfig<V>;
'header-max-length': LengthRuleConfig<V>;
'header-min-length': LengthRuleConfig<V>;
'references-empty': RuleConfig<V>;
'scope-case': CaseRuleConfig<V>;
'scope-empty': RuleConfig<V>;
'scope-enum': EnumRuleConfig<V>;
'scope-max-length': LengthRuleConfig<V>;
'scope-min-length': LengthRuleConfig<V>;
'signed-off-by': RuleConfig<V>;
'subject-case': CaseRuleConfig<V>;
'subject-empty': RuleConfig<V>;
'subject-full-stop': RuleConfig<V>;
'subject-max-length': LengthRuleConfig<V>;
'subject-min-length': LengthRuleConfig<V>;
'type-case': CaseRuleConfig<V>;
'type-empty': RuleConfig<V>;
'type-enum': EnumRuleConfig<V>;
'type-max-length': LengthRuleConfig<V>;
'type-min-length': LengthRuleConfig<V>;
};
export interface UserConfig {
extends?: string[];
formatter?: unknown;
rules?: Partial<RulesConfig>;
parserPreset?: string | ParserPreset;
ignores?: ((commit: string) => boolean)[];
defaultIgnores?: boolean;
plugins?: (string | Plugin)[];
}
export interface UserPreset {
extends?: string[];
formatter?: unknown;
rules?: Partial<RulesConfig>;
parserPreset?: string | ParserPreset;
ignores?: ((commit: string) => boolean)[];
defaultIgnores?: boolean;
plugins: PluginRecords;
}
export type QualifiedRules = Partial<RulesConfig<RuleConfigQuality.Qualified>>;
export interface QualifiedConfig {
extends: string[];
formatter: unknown;
rules: Partial<QualifiedRules>;
parserPreset: ParserPreset;
ignores: ((commit: string) => boolean)[];
defaultIgnores: boolean;
plugins: PluginRecords;
}
export interface ParserPreset {
name: string;
path: string;
parserOpts?: unknown;
}