场景三:已有项目接入检查
本场景演示为未使用 GVT 生成、但已有前端目录的旧项目接入代码检查。
背景
你有一个已运行的仓库,含一个 web/ 前端目录,希望用 GVT 的行数/lint/构建检查约束提交质量。
步骤
1. 注册目录
bash
cd legacy-project
gvt add --dir web --framework vue3工具自动检测工具链:
→ 正在检测工具链...
✓ 类型: vue3 | 包管理器: pnpm
✓ 工具: ESLint, Prettier, TypeScript, Vite
✓ 将注册检查项: line_count, lint, build, format, inline_styles_block, vue-types, ts-types, error_handling写入 .gvt/hook/modules/web.toml。
2. 激活钩子
bash
bash scripts/install-hooks.sh3. 验证检查
bash
gvt hook --all全量扫描 web/ 目录,输出超行数文件与 lint 问题。
调整阈值
编辑 .gvt/hook/modules/web.toml:
toml
enabled = true
dir = "web"
module_type = "frontend"
framework = "vue3"
warn_lines = 200
max_lines = 250
check_order = ["line_count", "lint", "build", "format", "vue-types", "ts-types"]手动增减检查项
check_order 字段支持任意组合:
line_count行数检查lintoxlint/eslint/biomebuildvite/npm buildformatoxfmt/prettiervue-typesVue 类型检查(vue-tsc)ts-typesTS 类型检查(tsc)inline_styles_block禁止 Vue<style>块内联样式error_handling错误处理检查
注意事项
gvt add不强制 oxc 工具链,按检测结果选择。- 检测失败时仍可手动编辑
.toml指定检查项。