-
Notifications
You must be signed in to change notification settings - Fork 3
/
commitlint.config.js
71 lines (67 loc) · 2.54 KB
/
commitlint.config.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
71
//-----------------------------------------------------------------------------------------------------------------------------------------------------
// build: Changes that affect the build system or external dependencies
// chore: Used for miscellaneous changes that don't affect the main codebase (e.g., configuring development tools, setting up project-specific settings)
// ci: Changes to our CI configuration files and scripts
// docs: Documentation only changes
// feat: A new feature
// fix: A bug fix
// update: Update something for a specific use case
// perf: A code change that improves performance
// refactor: A code change that neither fixes a bug nor adds a feature
// style: Changes that do not affect the meaning of the code (e.g., white-space, formatting, missing semi-colons)
// test: Adding missing tests or correcting existing tests
// translation: Changes related to translations or language localization
// sec: Changes that address security vulnerabilities, implement security measures, or enhance the overall security of the codebase
// -----------------------------------------------------------------------------------------------------------------------------------------------------
module.exports = {
parserPreset: {
parserOpts: {
headerPattern: /^(\w+)(?:\((\w+)\))?:\s(.*)$/,
headerCorrespondence: ['type', 'scope', 'subject'],
},
},
plugins: [
{
rules: {
'header-match-team-pattern': (parsed) => {
const { type, subject } = parsed;
const allowedTypes = [
'build',
'chore',
'ci',
'docs',
'feat',
'update',
'fix',
'perf',
'refactor',
'style',
'test',
'translation',
'sec',
];
if (!type || !subject) {
return [
false,
"\x1b[31mERROR\x1b[0m: Please follow the format 'feat(auth): user login form' or 'fix: fixing data problems'",
];
}
if (!allowedTypes.includes(type)) {
return [
false,
`\x1b[31mERROR\x1b[0m: The commit type '${type}' is not allowed. Allowed types are: [${allowedTypes.join(', ')}]`,
];
}
return [true, ''];
},
},
},
],
rules: {
'header-match-team-pattern': [2, 'always'],
'subject-empty': [2, 'never'],
'body-leading-blank': [2, 'always'],
'footer-leading-blank': [2, 'always'],
// 'footer-empty': [2, 'always'],
},
};