-
Notifications
You must be signed in to change notification settings - Fork 933
/
Copy pathlint.ts
45 lines (40 loc) · 1.32 KB
/
lint.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
import {IsIgnoredOptions} from './is-ignored';
import {PluginRecords} from './load';
import {ParserOptions} from './parse';
import {RuleConfigSeverity, RuleConfigTuple} from './rules';
export type LintRuleConfig = Record<
string,
| Readonly<[RuleConfigSeverity.Disabled]>
| RuleConfigTuple<void>
| RuleConfigTuple<unknown>
>;
export interface LintOptions {
/** If it should ignore the default commit messages (defaults to `true`) */
defaultIgnores?: IsIgnoredOptions['defaults'];
/** Additional commits to ignore, defined by ignore matchers */
ignores?: IsIgnoredOptions['ignores'];
/** The parser configuration to use when linting the commit */
parserOpts?: ParserOptions;
plugins?: PluginRecords;
helpUrl?: string;
}
export interface LintOutcome {
/** The linted commit, as string */
input: string;
/** If the linted commit is considered valid */
valid: boolean;
/** All errors, per rule, for the commit */
errors: LintRuleOutcome[];
/** All warnings, per rule, for the commit */
warnings: LintRuleOutcome[];
}
export interface LintRuleOutcome {
/** If the commit is considered valid for the rule */
valid: boolean;
/** The "severity" of the rule (1 = warning, 2 = error) */
level: RuleConfigSeverity;
/** The name of the rule */
name: string;
/** The message returned from the rule, if invalid */
message: string;
}