forked from pengtoshi/251RCOSE45700
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommitlint.config.ts
More file actions
74 lines (66 loc) · 2.13 KB
/
commitlint.config.ts
File metadata and controls
74 lines (66 loc) · 2.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
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
const {
utils: { getProjects },
} = require("@commitlint/config-nx-scopes");
const typeEnum = ["Feat", "Fix", "Chore", "Test", "Deploy", "Refactor"];
const Configuration = {
extends: ["git-commit-emoji", "@commitlint/config-nx-scopes"],
rules: {
//* Type
"type-empty": [2, "never"],
//* Scope
"scope-case": [2, "never", []],
"scope-empty": [0],
"scope-enum": async (ctx) => [2, "always", [...(await getProjects(ctx))]],
//* Subject
"subject-full-stop": [2, "never", "."],
"subject-exclamation-mark": [2, "never", "!"],
"subject-case": [2, "never", []],
"subject-empty": [2, "never"],
//* Body & Footer
"body-leading-blank": [1, "always"],
"body-max-line-length": [2, "always", 100],
"footer-leading-blank": [1, "always"],
"footer-max-line-length": [2, "always", 100],
},
prompt: {},
ignores: [
(message: string) =>
message.startsWith("Merge") ||
message.startsWith("Revert") ||
message.startsWith("Amend") ||
message.startsWith("Reset") ||
message.startsWith("Rebase") ||
message.startsWith("Tag"),
],
parserPreset: {
parserOpts: {
headerPattern: /^(?:\S+\s+)?(\S+)(?:\(([^\)]+)\))?: (.+)(?:\s+\(#\d+\))?$/,
headerCorrespondence: ["type", "scope", "subject"],
},
},
plugins: [
{
rules: {
"custom-type-enum": (parsed, _when, value) => {
const { type } = parsed;
const strippedType = type.replace(/^[^\w]+/, "");
if (!value.includes(strippedType)) {
return [false, `type must be one of [${value.join(", ")}]`];
}
return [true];
},
"custom-type-case": (parsed, _when, value) => {
const { type } = parsed;
const strippedType = type.replace(/^[^\w]+/, "");
if (value === "pascal-case" && !/^[A-Z][a-z]+$/.test(strippedType)) {
return [false, `type must be pascal-case`];
}
return [true];
},
},
},
],
};
Configuration.rules["type-enum"] = [2, "always", typeEnum];
Configuration.rules["type-case"] = [2, "always", "pascal-case"];
module.exports = Configuration;