Skip to content

Commit d36c8ab

Browse files
committed
ci(commits): add commitlint configuration to allow longer dependency commits
1 parent fd4f06b commit d36c8ab

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

commitlint.config.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,57 @@
11
module.exports = {
22
extends: ['@commitlint/config-conventional'],
3+
plugins: [
4+
{
5+
rules: {
6+
'header-max-length-deps': (parsed) => {
7+
const config = {
8+
maxLength: 100,
9+
dependencyCommit: {
10+
type: /^(chore|fix)/,
11+
scope: /(peer-)?deps/,
12+
maxLength: 200,
13+
},
14+
};
15+
16+
const length = parsed.header.length;
17+
const isDepsCommit =
18+
config.dependencyCommit.type.test(parsed.type) &&
19+
config.dependencyCommit.scope.test(parsed.scope);
20+
21+
if (length <= config.maxLength) {
22+
return [true];
23+
}
24+
25+
if (!isDepsCommit && length > config.maxLength) {
26+
return [
27+
false,
28+
[
29+
`header must not be longer than ${config.maxLength}`,
30+
`characters, current length is ${length}`,
31+
].join(' '),
32+
];
33+
}
34+
35+
if (isDepsCommit && length > config.dependencyCommit.maxLength) {
36+
return [
37+
false,
38+
[
39+
`header for dependency commits must not be longer than`,
40+
`${config.dependencyCommit.maxLength} characters, current`,
41+
`length is ${length}`,
42+
].join(' '),
43+
];
44+
}
45+
46+
return [true];
47+
},
48+
},
49+
},
50+
],
51+
rules: {
52+
'body-max-line-length': [0],
53+
'footer-max-line-length': [0],
54+
'header-max-length': [0],
55+
'header-max-length-deps': [2, 'always'],
56+
},
357
};

0 commit comments

Comments
 (0)