chore: 增加提交信息中文校验
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
if [ ! -w "${HOME:-/root}" ]; then
|
||||
export HOME=/tmp
|
||||
export XDG_CACHE_HOME="${XDG_CACHE_HOME:-/tmp}"
|
||||
export COREPACK_HOME="${COREPACK_HOME:-/tmp/corepack}"
|
||||
fi
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
if [ ! -w "${HOME:-/root}" ]; then
|
||||
export HOME=/tmp
|
||||
export XDG_CACHE_HOME="${XDG_CACHE_HOME:-/tmp}"
|
||||
export COREPACK_HOME="${COREPACK_HOME:-/tmp/corepack}"
|
||||
fi
|
||||
|
||||
@@ -8,6 +8,23 @@
|
||||
module.exports = {
|
||||
// 继承的规则
|
||||
extends: ['@commitlint/config-conventional'],
|
||||
// 自定义插件规则
|
||||
plugins: [
|
||||
{
|
||||
rules: {
|
||||
'subject-chinese': (parsed) => {
|
||||
const subject = String(parsed?.subject ?? '').trim()
|
||||
if (!subject) {
|
||||
return [false, '冒号后面的内容(subject)不能为空']
|
||||
}
|
||||
|
||||
// 要求 subject 以中文字符开头(允许后续包含数字/空格/标点/英文缩写)
|
||||
const startsWithChinese = /^[\u4E00-\u9FFF]/u.test(subject)
|
||||
return [startsWithChinese, '冒号后面的内容(subject)必须以中文开头']
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
// 自定义规则
|
||||
rules: {
|
||||
// 提交类型枚举,git提交type必须是以下类型
|
||||
@@ -29,6 +46,7 @@ module.exports = {
|
||||
'wip' // 对构建过程或辅助工具和库的更改(不影响源文件、测试用例)
|
||||
]
|
||||
],
|
||||
'subject-chinese': [2, 'always'],
|
||||
'subject-case': [0] // subject大小写不做校验
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user