forked from phpjavac/composition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
commitlint.config.js
62 lines (62 loc) · 1.63 KB
/
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
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
const $$types = [
'feat',
'fix',
'docs',
'style',
'refactor',
'perf',
'test',
'chore',
'chore-release',
'chore-deps',
'build',
'ci',
'release',
'security',
'i18n',
'breaking',
'config',
'add',
'remove',
]
// https://github.com/conventional-changelog/commitlint/blob/master/docs/reference-rules.md
// https://github.com/vidavidorra/commitlint-plugin-function-rules#usage
// https://github.com/folke/devmoji#default-devmoji-reference
// 使用 function rules 时,要先禁用同名的rules,否则会重复校验
module.exports = {
extends: ['@commitlint/config-conventional'],
exclude: ['lib'],
plugins: ['commitlint-plugin-function-rules'],
rules: {
'type-enum': [2, 'always', $$types],
'header-max-length': [0],
'function-rules/header-max-length': [
2, // level: error
'always',
(parsed) => {
if (parsed.header.length < 72) {
return [true]
}
return [false, '提交信息的长度不能超过72个字符']
},
],
'scope-enum': [0],
'function-rules/scope-enum': [
2,
'always',
(parsed) => {
const helpMsg =
'请填写 jira 任务号 或 issue 号 \neg:\n fix(DCAW-900): 修复跳转链接\n fix(#123): 修复跳转链接\n'
const jiraScope = new RegExp(/[a-zA-Z]{2,20}-[0-9]{1,20}/, 'g')
const issueScope = new RegExp(/#[0-9]{1,20}/, 'g')
if (parsed.scope) {
if (jiraScope.test(parsed.scope) || issueScope.test(parsed.scope)) {
return [true]
}
return [false, helpMsg]
}
return [false, helpMsg]
},
],
},
}