Skip to content

Git Hooks 检查项

checks 字段支持以下检查项,可按场景任意组合。

检查项一览

检查项说明
line_count单文件行数检查(双阈值:警告/错误)
go_vetgo vet ./...
go_buildgo build ./...
staticcheckstaticcheck ./...
lintoxlint / eslint / biome(自动检测)
buildvite / npm build
formatoxfmt / prettier
vue-typesvue-tsc 类型检查
ts-typesTS 类型检查
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=250max_lines=300

工具自动检测

lintformat 等不指定具体工具,运行期按目录内配置自动选择 oxlint / eslint / biome / oxfmt / prettier。

注意事项

  • inline_stylesrelative_imports 主要面向 Vue 项目,其他项目可省略。
  • 组合越多检查越严格,建议按模块类型选择最小必要集合。

基于 MIT 协议开源