chore: 增加提交信息中文校验

This commit is contained in:
msumshk
2026-01-29 05:27:40 +00:00
parent 3c97e355fd
commit 7b91a46653
3 changed files with 20 additions and 0 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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大小写不做校验
},