-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcommitlint.config.ts
42 lines (38 loc) · 1.16 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
import { type UserConfig } from '@commitlint/types';
const COMMIT_MODIFIERS = ['+', '*', '-'];
const COMMIT_MESSAGE_REGEXP = new RegExp(`([${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:
- <modifier> <description>
Where:
- <modifier>: ${COMMIT_MODIFIERS.join(', ')}
Examples:
- + container
- - unused code
`;
const configuration: UserConfig = {
parserPreset: {
parserOpts: {
headerPattern: COMMIT_MESSAGE_REGEXP,
headerCorrespondence: ['modifier', 'description'],
},
},
defaultIgnores: true,
plugins: [
{
rules: {
'commit-message-match': ({ header }): [true] | [false, string] => {
if (!COMMIT_MESSAGE_REGEXP.test(header)) {
return [false, COMMIT_MESSAGE_MATCH_RULE_MESSAGE];
}
return [true];
},
},
},
],
rules: {
'commit-message-match': [2, 'always'],
},
};
export default configuration;