vue-doctor
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseVue Doctor Skill
Vue Doctor Skill
Diagnose Vue.js / Nuxt projects for health issues and auto-fix them. One command
runs four engines in parallel (oxlint, eslint-plugin-vue, custom Vue rules, knip)
and returns a 0–100 health score with actionable diagnostics.
诊断Vue.js / Nuxt项目的健康问题并自动修复。一条命令即可并行运行四个引擎(oxlint、eslint-plugin-vue、自定义Vue规则、knip),并返回0-100的健康评分及可执行的诊断结果。
When to use
使用场景
- The user asks to check, diagnose, audit, or fix a Vue/Nuxt project
- Reviewing Vue components for anti-patterns before a commit or PR
- Gating a build on code health in CI
- The user says "run vue-doctor" or "check my Vue project"
- 用户需要检查、诊断、审计或修复Vue/Nuxt项目
- 在提交代码或创建PR前检查Vue组件中的反模式
- 在CI流程中基于代码健康度控制构建
- 用户提出"运行vue-doctor"或"检查我的Vue项目"需求
Pick the right command
选择合适的命令
| Goal | Command |
|---|---|
| Auto-fix issues (agents — start here) | |
| Human-readable scan | |
| Only changed files (fast PR check) | |
| CI gate (fail under a threshold) | |
| Score only | |
--no-dead-code--no-lint--diff| 目标 | 命令 |
|---|---|
| 自动修复问题(Agent推荐首选) | |
| 人类可读格式扫描结果 | |
| 仅检查变更文件(快速PR检查) | |
| CI门禁(低于阈值则构建失败) | |
| 仅获取评分 | |
--no-dead-code--no-lint--diffAuto-fix workflow (for AI / coding agents)
自动修复工作流(适用于AI/编码Agent)
Always use — it emits a stable, parseable document with no colors or
spinner noise. Do not parse the human/ output.
--json--fix- Run (add
npx vue-doctor@latest . --jsonto scope to the PR).--diff main - Parse the JSON. Each entry in has:
diagnostics[],file,line,column,severity,category,rule,message.fix - For each diagnostic, open at
file, apply theline:columnguidance (see the rule table below), and edit the code.fix - Fix items first, then
severity: "error".warning - Re-run and confirm
--jsonwent up andscore.valuedropped.summary.errors
请始终使用参数——它会输出稳定、可解析的文档,不包含颜色或加载动画干扰信息。请勿解析人类可读格式/参数的输出。
--json--fix- 运行(添加
npx vue-doctor@latest . --json参数可限定为PR范围内的文件)。--diff main - 解析JSON结果。中的每个条目包含:
diagnostics[](文件)、file(行号)、line(列号)、column(严重程度)、severity(类别)、category(规则)、rule(提示信息)、message(修复方案)。fix - 针对每个诊断结果,打开对应文件并定位到
file位置,按照line:column中的指导方案(参考下方规则表)修改代码。fix - 优先修复级别的问题,再处理
severity: "error"级别的问题。warning - 重新运行命令,确认
--json提升且score.value数量减少。summary.errors
JSON shape
JSON结果结构
json
{
"schema": "vue-doctor/diagnosis@1",
"score": { "value": 82, "label": "Great" },
"project": { "framework": "nuxt3", "vueVersion": "^3.4.0", "typescript": true },
"summary": { "total": 5, "errors": 1, "warnings": 4, "byCategory": { "Reactivity": 2 } },
"diagnostics": [
{
"file": "src/components/User.vue",
"line": 12, "column": 1,
"severity": "error",
"category": "Reactivity",
"rule": "vue-doctor/reactivity-destructure-props",
"message": "Destructuring props loses reactivity in Vue 3",
"fix": "Use toRefs(props) or access props.xxx directly"
}
],
"diff": null,
"elapsedMs": 1240
}json
{
"schema": "vue-doctor/diagnosis@1",
"score": { "value": 82, "label": "Great" },
"project": { "framework": "nuxt3", "vueVersion": "^3.4.0", "typescript": true },
"summary": { "total": 5, "errors": 1, "warnings": 4, "byCategory": { "Reactivity": 2 } },
"diagnostics": [
{
"file": "src/components/User.vue",
"line": 12, "column": 1,
"severity": "error",
"category": "Reactivity",
"rule": "vue-doctor/reactivity-destructure-props",
"message": "Destructuring props loses reactivity in Vue 3",
"fix": "Use toRefs(props) or access props.xxx directly"
}
],
"diff": null,
"elapsedMs": 1240
}Exit codes (CI / scripting)
退出码(适用于CI/脚本)
- — completed (and, if
0was set, score met the threshold)--min-score - — score below
1, or the scan failed (no Vue project, etc.)--min-score
bash
npx vue-doctor@latest . --min-score 80 # exits 1 if health < 80- — 执行完成(若设置了
0,则表示评分达到阈值)--min-score - — 评分低于
1阈值,或扫描失败(如未检测到Vue项目等)--min-score
bash
npx vue-doctor@latest . --min-score 80 # exits 1 if health < 80Score interpretation
评分解读
- 80–100 (Great): healthy project, minor optimizations only
- 50–79 (Needs work): several issues to address
- 0–49 (Critical): major problems needing urgent attention
- 80–100分(优秀): 项目健康,仅需少量优化
- 50–79分(待改进): 存在多个需要解决的问题
- 0–49分(严重): 存在重大问题,需紧急处理
Diagnostic categories
诊断类别
Reactivity · Performance · Security · Correctness · Accessibility ·
Architecture · Best Practices · Nuxt · Dead Code
响应式 · 性能 · 安全 · 正确性 · 可访问性 · 架构 · 最佳实践 · Nuxt · 死代码
Rule → fix reference
规则→修复方案参考
| Rule | How to fix |
|---|---|
| Use |
| Use |
| Add |
| Wrap with |
| Use store actions or |
| Emit an event to the parent, or copy the prop into local |
| Extract sub-components to get the file under 300 lines |
| Replace the in-template method call with a |
| Move |
| Add an |
| Sanitize HTML (e.g. DOMPurify) or use |
| Move |
| |
| Migrate to Composition API with |
| 规则 | 修复方法 |
|---|---|
| 使用 |
| 使用 |
| 在 |
| 使用 |
| 使用store的actions或 |
| 向父组件触发事件,或将prop复制到本地 |
| 提取子组件,将文件行数控制在300行以内 |
| 将模板中的方法调用替换为 |
| 将 |
| 添加 |
| 对HTML进行 sanitize 处理(例如使用DOMPurify)或使用 |
| 将 |
| 在setup中返回 |
| 迁移到使用 |
Node.js API
Node.js API
For programmatic use in custom scripts:
typescript
import { diagnose } from "@healerlab/vue-doctor/api";
const result = await diagnose("./path/to/vue-project");
console.log(result.score); // { score: 82, label: "Great" }
console.log(result.diagnostics); // Array<Diagnostic>用于自定义脚本中的程序化调用:
typescript
import { diagnose } from "@healerlab/vue-doctor/api";
const result = await diagnose("./path/to/vue-project");
console.log(result.score); // { score: 82, label: "Great" }
console.log(result.diagnostics); // Array<Diagnostic>Configuration
配置
Users can ignore rules/files via in the project root:
.vue-doctorrcjson
{
"ignore": {
"rules": ["vue/no-v-html"],
"files": ["src/generated/**"]
}
}用户可通过项目根目录下的文件忽略指定规则/文件:
.vue-doctorrcjson
{
"ignore": {
"rules": ["vue/no-v-html"],
"files": ["src/generated/**"]
}
}