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