Commit f2dfb16a by pangchong

chore(tooling): 添加提交前自动规则校验脚本

- 新增 scripts/verify-rules.js,实现对暂存区代码的多项规范检查
- 配置 package.json 新增 verify-rules 脚本用于执行规则校验
- husky 钩子 pre-commit 调用 verify-rules,在格式化前阻断不合规提交
- 规则涵盖 Vue 文件结构、禁用 class 和 function 声明模式、禁止手动导入 Vue/Pinia API
- 强制统一异步处理为 async/await,禁止使用 .then/.catch 链式调用
- 限制灰度色硬编码,禁止原生某些组件,强制规定 UI 交互模式
- 违规时输出详细违规文件、行号和原因,阻止不规范代码提交
parent fb0f4d9b
#!/usr/bin/env sh #!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh" . "$(dirname -- "$0")/_/husky.sh"
# 1. 静态校验暂存区代码是否符合 .gemini/.rules.md 规范(不符合立即阻断提交)
npm run verify-rules
npm run format npm run format
echo '***************************************************' echo '***************************************************'
echo '********************注意提交格式*******************' echo '********************注意提交格式*******************'
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
"preview": "vite preview", "preview": "vite preview",
"prepare": "husky install", "prepare": "husky install",
"commitlint": "commitlint --config commitlint.config.cjs -e -V", "commitlint": "commitlint --config commitlint.config.cjs -e -V",
"verify-rules": "node scripts/verify-rules.js",
"format": "prettier --write \"./**/*.{html,vue,ts,js,json,md}\"" "format": "prettier --write \"./**/*.{html,vue,ts,js,json,md}\""
}, },
"dependencies": { "dependencies": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment