-
Notifications
You must be signed in to change notification settings - Fork 12
/
commitlint.config.ts
55 lines (47 loc) · 1.44 KB
/
commitlint.config.ts
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
import { type UserConfig } from '@commitlint/types';
import { ProjectPrefix } from './project.config';
const COMMIT_MODIFIERS = ['+', '*', '-'];
const COMMIT_MESSAGE_REGEXP = new RegExp(
`^(((${ProjectPrefix.APPS.join(
'|',
)})-[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.APPS.join(', ')}
- <modifier>: ${COMMIT_MODIFIERS.join(', ')}
- <environment>: ${ProjectPrefix.ENVIRONMENTS.join(', ')}
Examples:
- qc-5: + type naming rule
- qc-12: * array methods rule
- qc-16: - es-modules forcing rule`;
const configuration: UserConfig = {
parserPreset: {
parserOpts: {
headerPattern: COMMIT_MESSAGE_REGEXP,
headerCorrespondence: ['prefix', 'modifier', 'description'],
},
},
defaultIgnores: true,
plugins: [
{
rules: {
'commit-message-match': ({ header }) => {
if (!header.match(COMMIT_MESSAGE_REGEXP)) {
return [false, COMMIT_MESSAGE_MATCH_RULE_MESSAGE];
}
return [true];
},
},
},
],
rules: {
'commit-message-match': [2, 'always'],
},
};
export default configuration;