-
Notifications
You must be signed in to change notification settings - Fork 7
/
commitlint.config.mjs
43 lines (41 loc) · 1.18 KB
/
commitlint.config.mjs
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
/* eslint-disable import/no-extraneous-dependencies */
import rulesChecks from '@commitlint/rules';
const forceTypeCase = (field, parsed) => {
switch (parsed.type) {
case 'feat':
case 'fix':
case 'refactor':
case 'perf':
break;
default:
return [true];
}
if (!parsed[field]?.trim()) {
return [false, `${field} is required for type '${parsed.type}'`];
}
const checked = rulesChecks[`${field}-case`](parsed, 'always', 'sentence-case');
if (!checked[0]) {
return [false, `${checked[1]} for type '${parsed.type}'`];
}
return [true];
};
export default {
extends: ['@commitlint/config-conventional'],
plugins: [
{
rules: {
'bytype-subject-case': (parsed) => forceTypeCase('subject', parsed),
'bytype-body-case': (parsed) => forceTypeCase('subject', parsed),
},
},
],
rules: {
'scope-case': [1, 'always', 'kebab-case'],
'subject-case': [1, 'always', 'sentence-case'],
'body-case': [1, 'always', 'sentence-case'],
'bytype-subject-case': [2, 'always'],
'bytype-body-case': [2, 'always'],
'body-max-line-length': [2, 'always', 400],
'footer-max-line-length': [2, 'always', 200],
},
};