From 7b91a46653deb6b1cd22b7ca9efca9770d2d4bf7 Mon Sep 17 00:00:00 2001 From: msumshk Date: Thu, 29 Jan 2026 05:27:40 +0000 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=A2=9E=E5=8A=A0=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E4=B8=AD=E6=96=87=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .husky/commit-msg | 1 + .husky/pre-commit | 1 + commitlint.config.cjs | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/.husky/commit-msg b/.husky/commit-msg index 28e67e9..70643b1 100644 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -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 diff --git a/.husky/pre-commit b/.husky/pre-commit index 882a730..aedcdfb 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -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 diff --git a/commitlint.config.cjs b/commitlint.config.cjs index d2ef1bd..afd5361 100644 --- a/commitlint.config.cjs +++ b/commitlint.config.cjs @@ -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大小写不做校验 },