Git Hooks 检查项
checks 字段支持以下检查项,可按场景任意组合。
检查项一览
| 检查项 | 说明 |
|---|---|
line_count | 单文件行数检查(双阈值:警告/错误) |
go_vet | go vet ./... |
go_build | go build ./... |
staticcheck | staticcheck ./... |
lint | oxlint / eslint / biome(自动检测) |
build | vite / npm build |
format | oxfmt / prettier |
vue-types | vue-tsc 类型检查 |
ts-types | TS 类型检查 |
inline_styles | 禁止 Vue style= / :style= |
relative_imports | 禁止 ../ 跨级导入 |
组合示例
Go 后端
toml
checks = ["line_count", "go_vet", "go_build", "staticcheck"]Vue 前端
toml
checks = ["line_count", "lint", "build", "format", "vue-types", "inline_styles"]React 前端
toml
checks = ["line_count", "lint", "build", "format", "ts-types"]行数检查逻辑
- 文件行数 >
warn_lines:输出警告,不阻断 - 文件行数 >
max_lines:输出错误,退出码非 0 - 默认
warn_lines=250、max_lines=300
工具自动检测
lint、format 等不指定具体工具,运行期按目录内配置自动选择 oxlint / eslint / biome / oxfmt / prettier。
注意事项
inline_styles与relative_imports主要面向 Vue 项目,其他项目可省略。- 组合越多检查越严格,建议按模块类型选择最小必要集合。