forked from argentlabs/dappland
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commitlint.config.js
71 lines (61 loc) · 1.78 KB
/
commitlint.config.js
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
const capturingGroupType = /(\w*:\s)/ // 'type: '
const capturingGroupSubject = /([^[].+)/ // 'subject'
/*
❌ Bad commit messages
git commit -m "add feature"
git commit -m "ABC-123 add feature"
git commit -m "feat / add feature"
✅ Good commit messages
git commit -m "feat: add feature"
git commit -m "[ABC-123] feat: add feature"
*/
module.exports = {
parserPreset: {
parserOpts: {
headerPattern: new RegExp(
"^" + capturingGroupType.source + capturingGroupSubject.source + "$",
),
headerCorrespondence: ["type", "subject"],
},
},
plugins: [
{
rules: {
"header-match-pattern": (parsed) => {
const { type, subject } = parsed
if (type === null && subject === null)
return [false, "commit message must be in format 'type: subject'"]
return [true, ""]
},
"check-type": (parsed, _when, expectedValues) => {
const { type } = parsed
if (type && !Object.keys(expectedValues).includes(type.split(":")[0]))
return [
false,
`commit message must be in format 'type: subject'\ntype must be one of:\n${Object.keys(
expectedValues,
)
.map((type) => `${type} - ${expectedValues[type]}`)
.join("\n")}`,
]
return [true, ""]
},
},
},
],
rules: {
"header-match-pattern": [2, "always"],
"check-type": [
2,
"always",
{
feat: "add a new feature to your application",
chore: "tool, configuration changes, linters",
fix: "bug fix",
docs: "documentation update",
refactor: "code changes, no new features added",
test: "add / update tests",
},
],
},
}