Skip to content

场景三:已有项目接入检查

本场景演示为未使用 GVT 生成、但已有前端目录的旧项目接入代码检查。

背景

你有一个已运行的仓库,含一个 web/ 前端目录,希望用 GVT 的行数/lint/构建检查约束提交质量。

步骤

1. 注册目录

bash
cd legacy-project
gvt add --dir web

工具自动检测工具链:

 → 正在检测工具链...
   ✓ 类型: vue | 包管理器: pnpm
   ✓ 工具: ESLint, Prettier, TypeScript, Vite
   ✓ 将注册检查项: line_count, lint, build, format, types

写入 .gvt/hook/modules/web.toml

2. 激活钩子

bash
bash scripts/install-hooks.sh

3. 验证检查

bash
gvt hook --all

全量扫描 web/ 目录,输出超行数文件与 lint 问题。

调整阈值

编辑 .gvt/hook/modules/web.toml

toml
enabled = true
dir = "web"
warn_lines = 200
max_lines = 250
checks = ["line_count", "lint", "build", "format", "types"]

手动增减检查项

checks 字段支持任意组合:

  • line_count 行数检查
  • lint oxlint/eslint/biome
  • build vite/npm build
  • format oxfmt/prettier
  • ts-types TS 类型检查
  • inline_styles 禁止内联样式

注意事项

  • gvt add 不强制 oxc 工具链,按检测结果选择。
  • 检测失败时仍可手动编辑 .toml 指定检查项。

基于 MIT 协议开源