forked from vtexdocs/dev-portal-content
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommitlint.config.js
More file actions
49 lines (44 loc) · 1.58 KB
/
commitlint.config.js
File metadata and controls
49 lines (44 loc) · 1.58 KB
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
module.exports = {
extends: ['@commitlint/config-conventional'],
plugins: ['commitlint-plugin-function-rules'],
rules: {
'type-enum': [
2,
'always',
['new', 'fix', 'media', 'update', 'remove', 'loc', 'docs', 'feat', 'test']
],
'scope-case': [2, 'always', 'kebab-case'],
'scope-empty': [
2,
'never',
['new'] // "new" requires scope
],
'scope-empty': [
0,
'always',
['fix', 'media'] // "fix" and "media" allow optional scopes
],
'function-rules/scope-enum': [
2,
'always',
(parsed) => {
const allowedScopes = {
new: ['guide', 'troubleshooting', 'release-notes'],
fix: ['typo', 'broken-link', 'markdown']
};
const { type, scope } = parsed;
// Only validate scopes for "new" and "fix"
if (!allowedScopes[type]) return [true];
// Validate "new" scopes
if (type === 'new' && !allowedScopes.new.includes(scope)) {
return [false, `new() scope must be one of: ${allowedScopes.new.join(', ')}`];
}
// Validate "fix" scopes (if used)
if (type === 'fix' && scope && !allowedScopes.fix.includes(scope)) {
return [false, `fix() scope must be one of: ${allowedScopes.fix.join(', ')}`];
}
return [true];
}
]
}
};