-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommitlint.config.js
More file actions
executable file
·47 lines (43 loc) · 1.13 KB
/
commitlint.config.js
File metadata and controls
executable file
·47 lines (43 loc) · 1.13 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
const allowedTypes = [
"feature",
"fix",
"docs",
"style",
"refactor",
"test",
"chore",
"version",
];
const headerPattern =
/^(?<type>feature|fix|docs|style|refactor|test|chore|version)-(?<ticket>LA-\d{2,4}):\s(?<subject>.+)$/u;
const ticketPattern = /^LA-\d{2,4}$/u;
const laTicketPlugin = {
rules: {
"require-la-ticket": (parsed, when = "always") => {
const ticket = parsed?.ticket ?? "";
const hasValidTicket = ticketPattern.test(ticket);
const isValid = when === "always" ? hasValidTicket : !hasValidTicket;
return [
isValid,
"コミットメッセージには feature-LA-xx: の形式でチケット番号を含めてください。",
];
},
},
};
module.exports = {
extends: ["@commitlint/config-conventional"],
parserPreset: {
parserOpts: {
headerPattern,
headerCorrespondence: ["type", "ticket", "subject"],
},
},
plugins: [laTicketPlugin],
rules: {
"type-empty": [2, "never"],
"subject-empty": [2, "never"],
"type-enum": [2, "always", allowedTypes],
"subject-case": [0, "always"],
"require-la-ticket": [2, "always"],
},
};