-
Notifications
You must be signed in to change notification settings - Fork 0
/
commitlint.config.js
30 lines (28 loc) · 946 Bytes
/
commitlint.config.js
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
const { execSync, exec } = require("child_process");
module.exports = {
extends: ["@commitlint/config-conventional"],
plugins: ["commitlint-plugin-function-rules"],
rules: {
"subject-empty": [0],
"subject-case": [0],
"type-empty": [0],
"function-rules/type-enum": [
2,
"always",
(parsed) => {
// Get the name of the current branch
const branchName = execSync("git symbolic-ref --short HEAD").toString().trim();
const commitTypeList = ["story", "fix", "test", "chore"];
const commitType = commitTypeList.join("|");
const commitRegex = new RegExp("^(" + commitType + ")/" + branchName + ": [\\w+ ?]{5,50}$");
const isCommitValid = parsed.header.match(commitRegex);
if (isCommitValid) {
return [true];
}
return [
false, `Commit: story|fix|test|chore/${branchName}: char 5 to 50`,
];
},
],
},
};