-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommitlint.config.js
More file actions
52 lines (46 loc) · 1.35 KB
/
commitlint.config.js
File metadata and controls
52 lines (46 loc) · 1.35 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
const { execSync } = require('child_process');
const releaseTypeAllowList = new Set(['feat', 'fix', 'perf', 'revert', 'docs']);
const releaseSensitivePatterns = [
/^package\.json$/,
/^package-lock\.json$/,
/^npm\/global\.json$/,
/^\.devcontainer\/Dockerfile$/,
/^\.devcontainer\/codex-config\.json$/,
/^\.codex\//,
];
const getStagedFiles = () => {
try {
return execSync('git diff --cached --name-only', { encoding: 'utf8' }).split('\n').filter(Boolean);
} catch {
return [];
}
};
const releaseTypeRule = (parsed) => {
const files = getStagedFiles();
const touched = files.filter((file) => releaseSensitivePatterns.some((pattern) => pattern.test(file)));
if (!touched.length) {
return [true];
}
const isReleaseType = releaseTypeAllowList.has(parsed.type || '');
return [
isReleaseType,
`Changes in ${touched.join(', ')} require a release-triggering type (feat|fix|perf|revert|docs) to keep semantic-release automated.`,
];
};
module.exports = {
extends: ['@commitlint/config-conventional'],
plugins: [
{
rules: {
'codex-release-type': (parsed) => releaseTypeRule(parsed),
},
},
],
rules: {
'subject-case': [0], // 日本語対応のため無効化
'subject-empty': [2, 'never'],
'type-empty': [2, 'never'],
'scope-empty': [0],
'codex-release-type': [2, 'always'],
},
};