-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommitlint.config.cjs
48 lines (44 loc) · 1.38 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
37
38
39
40
41
42
43
44
45
46
47
48
const { ProjectPrefix } = require('./project.config.cjs');
const COMMIT_MODIFIERS = ['+', '*', '-'];
const COMMIT_MESSAGE_REGEXP = new RegExp(
`^(((${ProjectPrefix.APP})-[0-9]{1,6})|(${ProjectPrefix.ENVIRONMENTS.join(
'|'
)})): ([${COMMIT_MODIFIERS.join(',')}]) (.*\\S)$`
);
const COMMIT_MESSAGE_MATCH_RULE_MESSAGE = `commit message doesn't match format requirements
Commit message must have one of the following formats:
- <project-prefix>-<issue-number>: <modifier> <description>
- <environment>: <modifier> <description>
Where:
- <project-prefix>: ${ProjectPrefix.APP}
- <modifier>: ${COMMIT_MODIFIERS.join(', ')}
- <environment>: ${ProjectPrefix.ENVIRONMENTS.join(', ')}
Examples:
- ${ProjectPrefix.APP}-5: + ui/ux lecture
- ${ProjectPrefix.APP}-12: * docker homework
- production: - comments in ui/ux homework`;
const configuration = {
parserPreset: {
parserOpts: {
headerPattern: COMMIT_MESSAGE_REGEXP,
headerCorrespondence: ['prefix', 'modifier', 'description']
}
},
defaultIgnores: true,
plugins: [
{
rules: {
'commit-message-match': ({ header }) => {
if (!COMMIT_MESSAGE_REGEXP.test(header)) {
return [false, COMMIT_MESSAGE_MATCH_RULE_MESSAGE];
}
return [true];
}
}
}
],
rules: {
'commit-message-match': [2, 'always']
}
};
module.exports = configuration;