-
Notifications
You must be signed in to change notification settings - Fork 10
/
commitlint.config.ts
185 lines (166 loc) · 8.05 KB
/
commitlint.config.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
import { Helpers } from "./commitlint/helpers";
import { Plugins } from "./commitlint/plugins";
import { RuleConfigSeverity } from "@commitlint/types";
let bodyMaxLineLength = 64;
let headerMaxLineLength = 50;
module.exports = {
parserPreset: "conventional-changelog-conventionalcommits",
rules: {
"body-leading-blank": [RuleConfigSeverity.Error, "always"],
"body-soft-max-line-length": [
RuleConfigSeverity.Error,
"always",
bodyMaxLineLength,
],
"empty-wip": [RuleConfigSeverity.Error, "always"],
"footer-leading-blank": [RuleConfigSeverity.Warning, "always"],
"footer-max-line-length": [RuleConfigSeverity.Error, "always", 150],
"footer-notes-misplacement": [RuleConfigSeverity.Error, "always"],
"footer-references-existence": [RuleConfigSeverity.Error, "always"],
"header-max-length-with-suggestions": [
RuleConfigSeverity.Error,
"always",
headerMaxLineLength,
],
"subject-full-stop": [RuleConfigSeverity.Error, "never", "."],
"type-empty": [RuleConfigSeverity.Warning, "never"],
"type-space-after-colon": [RuleConfigSeverity.Error, "always"],
"subject-lowercase": [RuleConfigSeverity.Error, "always"],
"body-prose": [RuleConfigSeverity.Error, "always"],
"type-space-after-comma": [RuleConfigSeverity.Error, "always"],
"trailing-whitespace": [RuleConfigSeverity.Error, "always"],
"prefer-slash-over-backslash": [RuleConfigSeverity.Error, "always"],
"type-space-before-paren": [RuleConfigSeverity.Error, "always"],
"type-with-square-brackets": [RuleConfigSeverity.Error, "always"],
"proper-issue-refs": [RuleConfigSeverity.Error, "always"],
"too-many-spaces": [RuleConfigSeverity.Error, "always"],
"commit-hash-alone": [RuleConfigSeverity.Error, "always"],
"title-uppercase": [RuleConfigSeverity.Error, "always"],
},
plugins: [
// TODO (ideas for more rules):
// * Detect if paragraphs in body have been cropped too shortly (less than 64 chars), and suggest same auto-wrap command that body-soft-max-line-length suggests, since it unwraps and wraps (both).
// * Detect reverts which have not been elaborated.
// * Reject some stupid obvious words: change, update, modify (if first word after colon, error; otherwise warning).
// * Think of how to reject this shitty commit message: https://github.com/nblockchain/NOnion/pull/34/commits/9ffcb373a1147ed1c729e8aca4ffd30467255594
// * Title should not have dot at the end.
// * Workflow: detect if wip commit in a branch not named "wip/*" or whose name contains "squashed".
// * Detect if commit hash mention in commit msg actually exists in repo.
// * Detect area(sub-area) in the title that doesn't include area part (e.g., writing (bar) instead of foo(bar))
{
rules: {
"body-prose": ({ raw }: { raw: any }) => {
let rawStr = Helpers.convertAnyToString(raw, "raw").trim();
return Plugins.bodyProse(rawStr);
},
"commit-hash-alone": ({ raw }: { raw: any }) => {
let rawStr = Helpers.convertAnyToString(raw, "raw");
return Plugins.commitHashAlone(rawStr);
},
"empty-wip": ({ header }: { header: any }) => {
let headerStr = Helpers.convertAnyToString(
header,
"header"
);
return Plugins.emptyWip(headerStr);
},
"header-max-length-with-suggestions": (
{ header }: { header: any },
_: any,
maxLineLength: number
) => {
let headerStr = Helpers.convertAnyToString(
header,
"header"
);
return Plugins.headerMaxLengthWithSuggestions(
headerStr,
maxLineLength
);
},
"footer-notes-misplacement": ({ raw }: { raw: any }) => {
let rawStr = Helpers.convertAnyToString(raw, "raw").trim();
return Plugins.footerNotesMisplacement(rawStr);
},
"footer-references-existence": ({ raw }: { raw: any }) => {
let rawStr = Helpers.convertAnyToString(raw, "raw").trim();
return Plugins.footerReferencesExistence(rawStr);
},
"prefer-slash-over-backslash": ({
header,
}: {
header: any;
}) => {
let headerStr = Helpers.convertAnyToString(
header,
"header"
);
return Plugins.preferSlashOverBackslash(headerStr);
},
"proper-issue-refs": ({ raw }: { raw: any }) => {
let rawStr = Helpers.convertAnyToString(raw, "raw").trim();
return Plugins.properIssueRefs(rawStr);
},
"title-uppercase": ({ header }: { header: any }) => {
let headerStr = Helpers.convertAnyToString(
header,
"header"
);
return Plugins.titleUppercase(headerStr);
},
"too-many-spaces": ({ raw }: { raw: any }) => {
let rawStr = Helpers.convertAnyToString(raw, "raw");
return Plugins.tooManySpaces(rawStr);
},
"type-space-after-colon": ({ header }: { header: any }) => {
let headerStr = Helpers.convertAnyToString(
header,
"header"
);
return Plugins.typeSpaceAfterColon(headerStr);
},
"type-with-square-brackets": ({ header }: { header: any }) => {
let headerStr = Helpers.convertAnyToString(
header,
"header"
);
return Plugins.typeWithSquareBrackets(headerStr);
},
// NOTE: we use 'header' instead of 'subject' as a workaround to this bug: https://github.com/conventional-changelog/commitlint/issues/3404
"subject-lowercase": ({ header }: { header: any }) => {
let headerStr = Helpers.convertAnyToString(
header,
"header"
);
return Plugins.subjectLowercase(headerStr);
},
"type-space-after-comma": ({ header }: { header: any }) => {
let headerStr = Helpers.convertAnyToString(
header,
"header"
);
return Plugins.typeSpaceAfterComma(headerStr);
},
"body-soft-max-line-length": (
{ raw }: { raw: any },
_: any,
maxLineLength: number
) => {
let rawStr = Helpers.convertAnyToString(raw, "raw").trim();
return Plugins.bodySoftMaxLineLength(rawStr, maxLineLength);
},
"trailing-whitespace": ({ raw }: { raw: any }) => {
let rawStr = Helpers.convertAnyToString(raw, "raw");
return Plugins.trailingWhitespace(rawStr);
},
"type-space-before-paren": ({ header }: { header: any }) => {
let headerStr = Helpers.convertAnyToString(
header,
"header"
);
return Plugins.typeSpaceBeforeParen(headerStr);
},
},
},
],
};