-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommitlint.config.cjs
More file actions
89 lines (82 loc) · 2.09 KB
/
commitlint.config.cjs
File metadata and controls
89 lines (82 loc) · 2.09 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
const { readFileSync, readdirSync, statSync } = require('fs');
const { join } = require('path');
const { defaultConfig, RuleConfigSeverity } = require('cz-git');
function findProjectJsonFiles(dir, files = []) {
try {
const items = readdirSync(dir);
for (const item of items) {
const fullPath = join(dir, item);
if (
statSync(fullPath).isDirectory() &&
!item.startsWith('.') &&
item !== 'node_modules'
) {
if (item === 'project.json') continue;
findProjectJsonFiles(fullPath, files);
} else if (item === 'project.json') {
files.push(fullPath);
}
}
} catch (e) {
// Skip directories we can't read
}
return files;
}
// Resolve scopes from Nx project tags
const scopeSet = new Set();
const projectFiles = findProjectJsonFiles(__dirname);
for (const file of projectFiles) {
// Skip e2e projects
if (file.includes('-e2e/')) continue;
try {
const content = JSON.parse(readFileSync(file, 'utf-8'));
if (content.tags) {
for (const tag of content.tags) {
if (tag.startsWith('scope:')) {
scopeSet.add(tag.replace('scope:', ''));
}
}
}
} catch (e) {
// Skip invalid JSON files
}
}
const scopes = Array.from(scopeSet).sort();
// Allow some custom scopes
scopes.push('deps', 'release', 'repo', 'workflow');
/** @type {import('cz-git').UserConfig} */
module.exports = {
extends: ['@commitlint/config-angular'],
rules: {
'scope-enum': [RuleConfigSeverity.Error, 'always', scopes],
'type-enum': [
RuleConfigSeverity.Error,
'always',
[
'build',
'chore',
'ci',
'docs',
'feat',
'fix',
'perf',
'refactor',
'revert',
'style',
'test',
'release'
]
]
},
prompt: {
allowBreakingChanges: ['feat', 'fix'],
allowCustomScopes: false,
allowEmptyScopes: false,
allowCustomIssuePrefix: false,
allowEmptyIssuePrefix: false
},
messages: {
...defaultConfig.messages,
footer: defaultConfig.messages?.footer?.replace(/#/g, 'COD-')
}
};