-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcommitlint.config.js
57 lines (52 loc) · 1.52 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
module.exports = {
extends: ['@commitlint/config-conventional'],
plugins: [
{
rules: {
'header-max-length-deps': (parsed) => {
const config = {
maxLength: 100,
dependencyCommit: {
type: /^(chore|fix)/,
scope: /(peer-)?deps/,
maxLength: 200,
},
};
const length = parsed.header.length;
const isDepsCommit =
config.dependencyCommit.type.test(parsed.type) &&
config.dependencyCommit.scope.test(parsed.scope);
if (length <= config.maxLength) {
return [true];
}
if (!isDepsCommit && length > config.maxLength) {
return [
false,
[
`header must not be longer than ${config.maxLength}`,
`characters, current length is ${length}`,
].join(' '),
];
}
if (isDepsCommit && length > config.dependencyCommit.maxLength) {
return [
false,
[
`header for dependency commits must not be longer than`,
`${config.dependencyCommit.maxLength} characters, current`,
`length is ${length}`,
].join(' '),
];
}
return [true];
},
},
},
],
rules: {
'body-max-line-length': [0],
'footer-max-line-length': [0],
'header-max-length': [0],
'header-max-length-deps': [2, 'always'],
},
};