-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommitlint.config.js
More file actions
82 lines (70 loc) · 2.37 KB
/
commitlint.config.js
File metadata and controls
82 lines (70 loc) · 2.37 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
export default {
// Base rules from Conventional Commits
extends: ["@commitlint/config-conventional"],
// Custom rules for Jira + Conventional Commit format
rules: {
// Limit header length to 75 characters
"header-max-length": [2, "always", 75],
// Custom rule : pattern Jira [KAN-XXX]
"jira-pattern": [2, "always"],
// Only allow specific commit types
"type-enum": [2, "always", ["FEAT", "FIX", "REFACTOR", "TEST", "BUILD", "DOCS"]],
"type-case": [2, "always", "upper-case"],
"subject-case": [0],
// Disallow empty subjects
"subject-empty": [2, "never"],
// No final dot at the end of the subject
"subject-full-stop": [2, "never", "."],
// Disallow commits containing "WIP"
"no-wip": [2, "always"],
"body-leading-blank": [2, "always"], // inserts a blank line after the header
"body-empty": [0], // allows a commit without a body
"body-max-line-length": [1, "always", 120], // warning if a line is too long
},
// Custom plugin to block "WIP" commits
plugins: [
{
rules: {
"no-wip": ({ raw }) => {
return [
!raw.toUpperCase().includes("WIP"),
'❌ Commits containing "WIP" are not allowed.',
];
},
// Verify Jira pattern
"jira-pattern": ({ raw }) => {
const pattern = /^\[(KAN-\d+)\]\s(FEAT|FIX|REFACTOR|TEST|BUILD|DOCS)(!?):\s(.+)/;
const match = raw.match(pattern);
if (!match) {
return [
false,
`
❌ Invalid format for commit message!
🧩 Expected format: [KAN-123] FEAT: short description
`,
];
}
return [
true,
`
✅ Valid format for commit message!
`,
];
},
},
},
],
// Parser configuration for matching groups in your pattern
// Commit message must follow: [KAN-123] FEAT: description
// This pattern checks for:
// - [KAN-<number>] at the beginning (Jira ticket)
// - A valid type (FEAT, FIX, REFACTOR, TEST, BUILD, DOCS)
// - A ! after the type, if it's a BREAKING CHANGE
// - A colon and a short description after a space
parserPreset: {
parserOpts: {
headerPattern: /^\[(KAN-\d+)\]\s(FEAT|FIX|REFACTOR|TEST|BUILD|DOCS)(!?):\s(.+)/,
headerCorrespondence: ["ticket", "type", "breaking", "subject"],
},
},
};