forked from luohy15/y-router
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcommitlint.config.cjs
More file actions
79 lines (70 loc) · 2.46 KB
/
Copy pathcommitlint.config.cjs
File metadata and controls
79 lines (70 loc) · 2.46 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
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
// Type enforcement - more restrictive than default
'type-enum': [
2,
'always',
[
'build', // Changes that affect the build system
'ci', // Changes to CI configuration files and scripts
'docs', // Documentation only changes
'feat', // A new feature
'fix', // A bug fix
'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
'test', // Adding missing tests or correcting existing tests
'revert', // Reverts a previous commit
'chore', // Other changes that don't modify src or test files
'security', // Security improvements
],
],
// Subject line rules
'subject-case': [2, 'never', ['start-case', 'pascal-case', 'upper-case']],
'subject-empty': [2, 'never'],
'subject-full-stop': [2, 'never', '.'],
'subject-max-length': [2, 'always', 100],
'subject-min-length': [2, 'always', 3],
// Type rules
'type-case': [2, 'always', 'lower-case'],
'type-empty': [2, 'never'],
'type-max-length': [2, 'always', 10],
// Scope rules
'scope-case': [2, 'always', 'lower-case'],
'scope-max-length': [2, 'always', 20],
// Header rules
'header-max-length': [2, 'always', 120],
'header-min-length': [2, 'always', 10],
// Body rules
'body-leading-blank': [2, 'always'],
'body-max-line-length': [2, 'always', 100],
// Footer rules
'footer-leading-blank': [2, 'always'],
'footer-max-line-length': [2, 'always', 100],
},
// Custom validators
plugins: [
{
rules: {
'no-secrets-in-message': parsed => {
const message = parsed.raw;
const secretPatterns = [
/[A-Za-z0-9+/]{40,}/, // Base64 encoded secrets
/[0-9a-f]{32,}/, // Hexadecimal secrets
/(password|secret|key|token)[\s=:]+[\w\-+/]{8,}/i,
/-----BEGIN[\s\S]+?-----END/, // Private keys
];
for (const pattern of secretPatterns) {
if (pattern.test(message)) {
return [false, 'Commit message appears to contain secrets'];
}
}
return [true];
},
},
},
],
// Configure help URL
helpUrl: 'https://github.com/conventional-changelog/commitlint/#what-is-commitlint',
};