-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
.commitlintrc.js
70 lines (65 loc) · 2.15 KB
/
.commitlintrc.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
module.exports = {
extends: ['@commitlint/config-conventional'],
plugins: [
{
// Relaxes max length rules for dependency updates, which can regularly
// exceed limits set by commitlint.
// See https://github.com/dependabot/dependabot-core/issues/2445
// The following solution is taken from
// https://github.com/vidavidorra/commitlint-config/blob/master/commitlint.config.js
rules: {
'header-max-length-deps': (parsed) => {
const config = {
maxLength: 100,
dependencyCommit: {
type: /^(chore|fix)/,
scope: /^(peer-)?deps(-dev)?$/,
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: {
'type-enum': [
2,
'always',
['feat', 'enhance', 'fix', 'pkg', 'internal', 'docs'],
],
'subject-case': [2, 'never', ['start-case', 'pascal-case', 'upper-case']],
// Completely relaxes body and footer line length
'body-max-line-length': [0],
'footer-max-line-length': [0],
// Replace header-max-length rule with one that relaxes it for dependency updates
'header-max-length': [0],
'header-max-length-deps': [2, 'always'],
},
};