-
Notifications
You must be signed in to change notification settings - Fork 36
/
commitlint.config.js
117 lines (116 loc) · 2.65 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
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
const Configuration = {
/*
* Resolve and load @commitlint/config-conventional from node_modules.
* Referenced packages must be installed
*/
extends: ['@commitlint/config-conventional'],
/*
* Any rules defined here will override rules from @commitlint/config-conventional
* See https://commitlint.js.org/#/reference-rules?id=available-rules
* Rules are defined as lists:
* - level(int:required): 0 disabled, 1 warning, 2 error
* - behaviour(string:required): 'always', 'never'
* - value(mixed:optional): value to match
*/
rules: {
'type-enum': [
2,
'always',
[
'build',
'chore',
'ci',
'docs',
'feat',
'fix',
'perf',
'refactor',
'revert',
'style',
'test',
'misc',
'merge',
'cherry-pick',
]
],
'scope-empty': [
2,
'never',
],
'scope-enum': [
2,
'always',
[
'templates',
'controllers',
'views',
'plugins',
'users',
'resources',
'api',
'commands',
'gitflow',
'dev',
'tests',
]
],
'subject-full-stop': [
0,
],
'header-full-stop': [
2,
'always',
';',
],
'body-empty': [
0,
'never',
],
'body-leading-blank': [
2,
'always',
],
'body-full-stop': [
2,
'always',
'.',
],
'body-starts-with': [
2,
'always',
'- '
],
},
/*
* Custom plugins
*/
plugins: [
{
rules: {
'header-full-stop': (parsed, behaviour, value) => {
if ( ! parsed.header ){ return [true, ''] }
return [parsed.header.endsWith(value), 'header must end with `' + value + '`']
},
'body-full-stop': (parsed, behaviour, value) => {
if ( ! parsed.body ){ return [true, ''] }
return [parsed.body.endsWith(value), 'body must end with `' + value + '`']
},
'body-starts-with': (parsed, behaviour, value) => {
if ( ! parsed.body ){ return [true, ''] }
return [parsed.body.startsWith(value), 'body must start with `' + value + '`']
},
'scope-enum': (parsed, behaviour, value) => {
if ( ! parsed.scope ){ return [true, ''] }
scopes = parsed.scope.split(',')
for( let i = 0; i < scopes.length; i++ ){
if ( ! value.includes(scopes[i]) ){
return [false, 'scope must be one of `' + value.join(', ') + '`']
}
}
return [true, '']
},
},
},
],
}
module.exports = Configuration;