@remylagerweij/vue-doctor 2.0.2 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,158 +1,344 @@
1
- # Vue Doctor 🩺
1
+ <div align="center">
2
2
 
3
- Diagnose and fix performance issues in your Vue.js app. Get a 0–100 health score with actionable recommendations.
3
+ # 🩺 Vue Doctor
4
4
 
5
- ## Quick Start
5
+ **Production-grade diagnostics, performance optimization, security auditing, and dead-code detection for Vue.js and Nuxt applications.**
6
+
7
+ [![npm version](https://img.shields.io/npm/v/@remylagerweij/vue-doctor.svg?color=42b883&logo=npm)](https://www.npmjs.com/package/@remylagerweij/vue-doctor)
8
+ [![npm downloads](https://img.shields.io/npm/dm/@remylagerweij/vue-doctor.svg?color=42b883&logo=npm)](https://www.npmjs.com/package/@remylagerweij/vue-doctor)
9
+ [![node version](https://img.shields.io/node/v/@remylagerweij/vue-doctor.svg?color=42b883&logo=node.js)](https://nodejs.org)
10
+ [![Documentation](https://img.shields.io/badge/docs-vitepress-42b883?logo=vitepress)](https://remylagerweij.github.io/vue-doctor/)
11
+ [![CI](https://github.com/remylagerweij/vue-doctor/actions/workflows/ci.yml/badge.svg)](https://github.com/remylagerweij/vue-doctor/actions/workflows/ci.yml)
12
+ [![Self-Test](https://github.com/remylagerweij/vue-doctor/actions/workflows/self-test.yml/badge.svg)](https://github.com/remylagerweij/vue-doctor/actions/workflows/self-test.yml)
13
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
14
+
15
+ [Quick Start](#-quick-start) • [Features](#-key-features) • [Rule Categories](#-what-it-checks) • [AI Agents & MCP](#-ai-coding-agents--mcp) • [GitHub Actions CI](#-github-actions-ci) • [Documentation](https://remylagerweij.github.io/vue-doctor/)
16
+
17
+ </div>
18
+
19
+ ---
20
+
21
+ Vue Doctor computes an actionable **0–100 health score** for your Vue and Nuxt codebases. It combines **sub-second AST analysis** via custom Oxlint rules, deep template validation via `eslint-plugin-vue`, dead code and unused export detection via Knip, and dependency vulnerability audits via OSV.dev.
22
+
23
+ ---
24
+
25
+ ## ⚡ Quick Start
26
+
27
+ ### Zero-Install (Run Instantly)
28
+
29
+ Scan your project in seconds without installing anything:
30
+
31
+ ```bash
32
+ npx @remylagerweij/vue-doctor@latest .
33
+ ```
34
+
35
+ ### Install as a Dev Dependency
6
36
 
7
37
  ```bash
8
- npx vue-doctor@latest
38
+ # npm
39
+ npm i -D @remylagerweij/vue-doctor
40
+
41
+ # pnpm
42
+ pnpm add -D @remylagerweij/vue-doctor
43
+
44
+ # yarn
45
+ yarn add -D @remylagerweij/vue-doctor
46
+
47
+ # bun
48
+ bun add -d @remylagerweij/vue-doctor
49
+ ```
50
+
51
+ Then add a script to your `package.json`:
52
+
53
+ ```json
54
+ {
55
+ "scripts": {
56
+ "doctor": "vue-doctor",
57
+ "doctor:fix": "vue-doctor --fix",
58
+ "doctor:diff": "vue-doctor --diff"
59
+ }
60
+ }
9
61
  ```
10
62
 
11
- ## What It Checks
63
+ ---
12
64
 
13
- Vue Doctor runs **three parallel analysis passes** on your codebase:
65
+ ## 🚀 Key Features
14
66
 
15
- ### 1. Oxlint + Vue Doctor Plugin (59 rules, 54 on by default)
16
- Custom ESTree-based rules for Vue.js:
67
+ - ⚡ **Sub-Second Performance:** Blazing-fast scans powered by Oxlint and native caching (`node_modules/.cache/vue-doctor`).
68
+ - 🛡️ **Comprehensive Quality Gates:** 85 custom rules (85 on by default) + 19 eslint-plugin-vue rules = 104 registered rules.
69
+ - 🔒 **Deep Security Guardrails:** Detects hardcoded secrets, unsafe HTML sinks (`v-html`), SSRF, command & SQL injection, prototype pollution, and LLM prompt injection risks.
70
+ - 🧹 **Dead Code & Unused Exports:** Finds unused components, unreferenced exports, orphan types, and dead dependencies using Knip.
71
+ - 🔧 **Automated Codemods:** Deterministic `--fix` automatically repairs lodash imports, in-place array mutation, missing `v-for` keys, and `rel="noopener noreferrer"`.
72
+ - 🤖 **First-Class AI Agent Support:** Built-in stdio Model Context Protocol (MCP) server (`vue-doctor mcp`) and one-command agent playbook installer (`vue-doctor agents install`) for Cursor, Claude Code, Copilot, and Windsurf.
73
+ - 🚦 **GitHub Actions CI & PR Feedback:** Full pull request feedback with sticky summary comments, line-level reviews with AI remediation prompts, check annotations, and score delta tracking.
74
+ - 📈 **Baseline for Existing Codebases:** Adopt Vue Doctor on legacy applications instantly; record existing issues and only fail on new violations.
75
+ - 📊 **Multiple Output Formats:** Terminal text with color banner, JSON, JSONL, SARIF (GitHub Code Scanning), Markdown, HTML, and GitHub Step Summary.
17
76
 
18
- | Category | Rules | Examples |
19
- |----------|-------|---------|
20
- | **Reactivity** | 9 | `no-fetch-in-watch`, `no-watch-for-computed`, `prefer-computed` |
21
- | **Ecosystem** | 4 | `pinia-no-destructure`, `router-no-string-push` |
22
- | **Architecture** | 2 | `no-giant-component`, `no-nested-component-definition` |
23
- | **Performance** | 18 | `no-transition-all`, `no-layout-property-animation`, `async-parallel` |
24
- | **Security** | 3 | `no-secrets-in-client-code`, `no-unsafe-html-sink` |
25
- | **Bundle Size** | 5 | `no-full-lodash-import`, `no-moment`, `prefer-dynamic-import` |
26
- | **Correctness** | 8 | `no-array-index-as-key`, `no-prevent-default`, `no-direct-dom-manipulation` |
27
- | **Nuxt** | 9 | `nuxt-no-img-element`, `nuxt-no-a-element`, `nuxt-async-client-component` |
28
- | **Server** | 1 | `server-no-console-in-handler` |
29
- | **Supply Chain** | 3 | `lockfile-integrity`, `no-remote-dependency-spec`, `no-dependency-install-scripts` (project checks) |
77
+ ---
30
78
 
31
- ### 2. ESLint Plugin Vue (20 template rules)
32
- Template-level analysis with `eslint-plugin-vue`:
79
+ ## 🔍 What It Checks
80
+
81
+ Vue Doctor executes **four parallel analysis passes**:
82
+
83
+ ### 1. Oxlint AST Plugin (85 rules)
84
+ Custom, sub-second JavaScript/TypeScript and `.vue` script AST analysis:
85
+
86
+ | Category | Focus | Example Anti-Patterns Detected |
87
+ |---|---|---|
88
+ | **Reactivity** | Vue 3 reactivity traps | `no-fetch-in-watch`, `no-watch-for-computed`, `prefer-computed`, ref unwrapping |
89
+ | **Performance** | Runtime & rendering speed | `no-transition-all`, `no-layout-property-animation`, `async-parallel`, large lists |
90
+ | **Security** | XSS, injection & secrets | `no-unsafe-html-sink`, `no-secrets-in-client-code`, `no-eval`, SSRF, prompt injection |
91
+ | **Bundle Size** | Bloat & tree-shaking | `no-full-lodash-import`, `no-moment`, `prefer-dynamic-import`, duplicate packages |
92
+ | **Nuxt** | SSR & hydration pitfalls | `nuxt-no-img-element`, `nuxt-no-a-element`, `nuxt-async-client-component` |
93
+ | **Ecosystem** | Pinia & Vue Router | `pinia-no-destructure`, `router-no-string-push` |
94
+ | **Architecture** | Maintainability & design | `no-giant-component`, `no-nested-component-definition` |
95
+ | **Correctness** | Logic bugs & runtime errors | `no-array-index-as-key`, `no-prevent-default`, `no-direct-dom-manipulation` |
96
+ | **Server** | Nitro / server handlers | `server-no-console-in-handler` |
97
+ | **Supply Chain** | Dependencies & lockfiles | `lockfile-integrity`, `no-remote-dependency-spec`, `no-dependency-install-scripts` |
98
+
99
+ ### 2. ESLint Template Validation (19 rules)
100
+ Deep `.vue` template structure checks via bundled flat-config ESLint:
33
101
  - `vue/require-v-for-key`, `vue/no-use-v-if-with-v-for`
34
102
  - `vue/no-mutating-props`, `vue/no-ref-as-operand`
35
103
  - `vue/no-side-effects-in-computed-properties`
104
+ - `vue/no-template-target-blank`
36
105
  - `vue/component-name-in-template-casing`
37
- - And more...
38
106
 
39
- ### 3. Dead Code Detection
40
- Powered by [Knip](https://github.com/webpro/knip):
41
- - Unused files, exports, types, dependencies
107
+ ### 3. Dead Code Detection (Knip)
108
+ - Unused `.vue`, `.ts`, and `.js` files
109
+ - Unused component exports, composables, and TypeScript types
110
+ - Unreferenced production dependencies and devDependencies
111
+
112
+ ### 4. Dependency Vulnerability Audits (OSV.dev)
113
+ - Real-time advisory lookups against the Open Source Vulnerability (OSV) database using `--audit`.
114
+
115
+ ---
42
116
 
43
- ## Usage
117
+ ## 💻 Common Commands
44
118
 
45
119
  ```bash
46
120
  # Scan current directory
47
121
  vue-doctor
48
122
 
49
- # Scan a specific project
50
- vue-doctor --project ./my-vue-app
123
+ # Scan a specific directory or workspace project
124
+ vue-doctor ./apps/web
51
125
 
52
- # Score only (for CI)
53
- vue-doctor --score
126
+ # Automatically apply deterministic codemods
127
+ vue-doctor --fix
54
128
 
55
- # Verbose output with file details
56
- vue-doctor --verbose
129
+ # Preview codemods without changing files (unified diff)
130
+ vue-doctor --fix --dry-run
57
131
 
58
- # Only lint checks (skip dead code)
59
- vue-doctor --no-dead-code
132
+ # Scan only files changed in your git branch (fast pre-commit / PR mode)
133
+ vue-doctor --diff main
60
134
 
61
- # Only dead code checks (skip lint)
62
- vue-doctor --no-lint
135
+ # Output numeric score only (0–100, useful for quick shell scripts)
136
+ vue-doctor --score
63
137
 
64
- # Scan only changed files (diff mode)
65
- vue-doctor --diff main
138
+ # Fail CI gate if health score is below 80 or if any error occurs
139
+ vue-doctor --min-score 80 --fail-on error
140
+
141
+ # Output formats: text (default), json, sarif, markdown, html
142
+ vue-doctor --format json --output report.json
143
+ vue-doctor --format sarif --output results.sarif
66
144
  ```
67
145
 
68
- ## Configuration
146
+ ---
69
147
 
70
- Put one config file in the project root: `vue-doctor.config.ts` (or `.mts`, `.js`, `.mjs`, `.json`), or a `vueDoctor` key in `package.json`. Parent directories are never searched.
148
+ ## 🤖 AI Coding Agents & MCP
71
149
 
72
- ```ts
73
- // vue-doctor.config.ts
74
- import { defineConfig } from "@remylagerweij/vue-doctor";
150
+ Vue Doctor is built from the ground up for AI-assisted development:
75
151
 
76
- export default defineConfig({
77
- extends: ["vue-doctor/recommended"], // or "vue-doctor/strict", "vue-doctor/security"
78
- rules: {
79
- "no-giant-component": "off",
80
- "vue-doctor/security/no-unsafe-html-sink": "error",
81
- },
82
- ignore: { files: ["src/legacy/**"], rules: ["no-prevent-default"] },
83
- gate: { failOn: "error", scope: "new", minScore: 70 },
84
- deadCode: true,
85
- });
152
+ ### 1. Model Context Protocol (MCP) Server
153
+ Launch the built-in MCP server for Claude Code, Cursor, Windsurf, or Antigravity:
154
+
155
+ ```bash
156
+ npx @remylagerweij/vue-doctor@latest mcp
86
157
  ```
87
158
 
159
+ Add it to your Claude Desktop or Cursor MCP settings:
160
+
88
161
  ```json
89
162
  {
90
- "$schema": "./node_modules/@remylagerweij/vue-doctor/schema/vue-doctor.schema.json",
91
- "ignore": { "files": ["src/legacy/**"] }
163
+ "mcpServers": {
164
+ "vue-doctor": {
165
+ "command": "npx",
166
+ "args": ["-y", "@remylagerweij/vue-doctor@latest", "mcp"]
167
+ }
168
+ }
92
169
  }
93
170
  ```
94
171
 
95
- - `rules` sets a severity (`"off"`, `"warn"`, `"error"`) per rule. Rule IDs are `vue-doctor/<category>/<rule>` (e.g. `vue-doctor/bundle-size/no-moment`), `vue/<rule>` for template rules and `knip/<type>`; `vue-doctor/security/*` selects a whole group. The 1.x forms `no-moment` and `vue-doctor/no-moment` still work but print a deprecation warning.
96
- - `gate`, `lint`, `deadCode`, `verbose` and `diff` are defaults; command-line flags win.
97
- - The config is validated: unknown keys and invalid values exit with code 2 and say what is wrong.
98
- - `.ts`/`.js` configs are executed. Use JSON when scanning untrusted code.
172
+ ### 2. Install AI Agent Instructions
173
+ Install tailored playbooks for all detected coding assistants (`CLAUDE.md`, `.cursorrules`, Copilot, `AGENTS.md`):
174
+
175
+ ```bash
176
+ npx @remylagerweij/vue-doctor@latest agents install
177
+ ```
178
+
179
+ ### 3. Explain Any Rule with AI Remediation Steps
180
+ ```bash
181
+ npx @remylagerweij/vue-doctor@latest explain vue-doctor/security/no-unsafe-html-sink
182
+ ```
183
+
184
+ ---
185
+
186
+ ## 🛠️ GitHub Actions CI
187
+
188
+ Set up automated pull request quality gates and sticky review comments in one command:
189
+
190
+ ```bash
191
+ npx @remylagerweij/vue-doctor@latest ci install
192
+ ```
193
+
194
+ Or add `.github/workflows/vue-doctor.yml`:
195
+
196
+ ```yaml
197
+ name: Vue Doctor
198
+
199
+ on:
200
+ pull_request:
201
+ types: [opened, synchronize, reopened, ready_for_review]
202
+ push:
203
+ branches: [main]
204
+
205
+ permissions:
206
+ contents: read
207
+ pull-requests: write
208
+ checks: write
209
+ statuses: write
210
+
211
+ jobs:
212
+ diagnose:
213
+ name: Vue Doctor Health Check
214
+ runs-on: ubuntu-latest
215
+ steps:
216
+ - uses: actions/checkout@v4
217
+ with:
218
+ fetch-depth: 0
219
+
220
+ - uses: remylagerweij/vue-doctor@v2
221
+ with:
222
+ fail-on: error
223
+ gate: new
224
+ feedback: summary,findings
225
+ grouping: rule-per-file
226
+ agent-prompt: true
227
+ ```
228
+
229
+ ---
99
230
 
100
- ## Baseline
231
+ ## 📈 Baseline (Adopting on Existing Projects)
101
232
 
102
- Adopting Vue Doctor on an existing codebase? Record today's findings and only fail on new ones:
233
+ Adopt Vue Doctor on large or legacy codebases without failing existing code:
103
234
 
104
235
  ```bash
105
- npx @remylagerweij/vue-doctor baseline # writes .vue-doctor-baseline.json (commit it)
106
- npx @remylagerweij/vue-doctor --baseline .vue-doctor-baseline.json --gate new --fail-on error
236
+ # 1. Record current findings into a baseline file
237
+ npx @remylagerweij/vue-doctor@latest baseline
238
+
239
+ # 2. Commit the baseline file
240
+ git add .vue-doctor-baseline.json && git commit -m "chore: add vue-doctor baseline"
241
+
242
+ # 3. Only fail CI when NEW issues are introduced
243
+ npx @remylagerweij/vue-doctor@latest --baseline .vue-doctor-baseline.json --gate new --fail-on error
244
+ ```
245
+
246
+ ---
247
+
248
+ ## ⚙️ Configuration
249
+
250
+ Configure Vue Doctor via `vue-doctor.config.ts` (or `.js`, `.mjs`, `.json`, or a `"vueDoctor"` property in `package.json`):
251
+
252
+ ```typescript
253
+ import { defineConfig } from "@remylagerweij/vue-doctor";
254
+
255
+ export default defineConfig({
256
+ gate: {
257
+ failOn: "error", // "none" | "error" | "warning"
258
+ scope: "new", // "new" (only new issues fail) | "all"
259
+ minScore: 80, // Minimum 0-100 score required to pass gate
260
+ },
261
+ lint: true,
262
+ deadCode: true,
263
+ rules: {
264
+ "vue-doctor/security/no-unsafe-html-sink": "error",
265
+ "vue-doctor/bundle-size/no-moment": "warn",
266
+ "vue-doctor/architecture/no-giant-component": "off",
267
+ },
268
+ ignore: {
269
+ paths: ["legacy/**", "dist/**", "coverage/**"],
270
+ rules: ["vue-doctor/bundle-size/no-full-lodash-import"],
271
+ },
272
+ baseline: ".vue-doctor-baseline.json",
273
+ });
107
274
  ```
108
275
 
109
- Set `"baseline": ".vue-doctor-baseline.json"` in the config to apply it by default. Fingerprints survive code moving within a file.
276
+ ---
110
277
 
111
- ## Suppressing Findings
278
+ ## 🔕 Suppressing Findings
112
279
 
113
- Vue Doctor has its own suppression comments. `eslint-disable` / `oxlint-disable` comments do **not** hide Vue Doctor findings, and Vue Doctor never modifies your files.
280
+ Vue Doctor features non-destructive, dedicated suppression comments. `eslint-disable` comments never hide Vue Doctor findings:
114
281
 
115
- ```ts
116
- // vue-doctor-disable-next-line vue-doctor/bundle-size/no-moment -- legacy report page
282
+ ```typescript
283
+ // Line suppression
284
+ // vue-doctor-disable-next-line vue-doctor/bundle-size/no-moment -- legacy compatibility
117
285
  import moment from "moment";
286
+
287
+ // Inline suppression
118
288
  const html = render(); // vue-doctor-disable-line
119
- /* vue-doctor-disable vue-doctor/bundle-size/no-moment */ /* vue-doctor-enable vue-doctor/bundle-size/no-moment */
120
- // vue-doctor-disable-file no-giant-component
289
+
290
+ // File suppression
291
+ // vue-doctor-disable-file vue-doctor/architecture/no-giant-component
121
292
  ```
122
293
 
123
- In `.vue` templates use HTML comments: `<!-- vue-doctor-disable-next-line vue-doctor/security/no-unsafe-html-sink -->`. Without a rule list every rule is suppressed; rules are written as canonical IDs (`vue-doctor/<category>/<rule>`, `vue/<rule>`); the 1.x forms `rule` and `vue-doctor/rule` still work with a deprecation warning.
294
+ In `.vue` templates, use standard HTML comments:
295
+ ```html
296
+ <!-- vue-doctor-disable-next-line vue-doctor/security/no-unsafe-html-sink -->
297
+ <div v-html="trustedContent" />
298
+ ```
299
+
300
+ ---
301
+
302
+ ## 🔌 Programmatic API
124
303
 
125
- ## Programmatic API
304
+ Use Vue Doctor directly from Node.js scripts or custom build tooling:
126
305
 
127
- ```ts
128
- import { diagnose } from "vue-doctor/api";
306
+ ```typescript
307
+ import { diagnose } from "@remylagerweij/vue-doctor/api";
129
308
 
130
- const result = await diagnose({
131
- directory: "./my-vue-app",
309
+ const result = await diagnose("./my-vue-app", {
132
310
  lint: true,
133
311
  deadCode: true,
134
- verbose: false,
135
312
  });
136
313
 
137
- console.log(result.scoreResult?.score); // 0–100
138
- console.log(result.diagnostics.length); // number of issues
314
+ console.log(`Health Score: ${result.score}/100`);
315
+ console.log(`Total Findings: ${result.diagnostics.length}`);
139
316
  ```
140
317
 
141
- ## GitHub Action
318
+ ---
142
319
 
143
- ```yaml
144
- - uses: remylagerweij/vue-doctor@v1
145
- with:
146
- directory: "."
147
- ```
320
+ ## 🌐 Framework & Tooling Support
321
+
322
+ - **Vue.js:** Vue 3 (Composition API, `<script setup>`, Options API)
323
+ - **Nuxt:** Nuxt 3 (auto-detected, with specialized server, routing, and hydration checks)
324
+ - **Bundlers:** Vite, Rollup, Webpack, Nuxt CLI, Quasar, Vue CLI
325
+ - **Monorepos:** npm, pnpm, yarn, bun workspaces, Turborepo, Nx
326
+
327
+ ---
328
+
329
+ ## 📚 Documentation & Resources
148
330
 
149
- ## Framework Support
331
+ - **[Official Documentation](https://remylagerweij.github.io/vue-doctor/)**
332
+ - **[Full Rules Catalog](https://remylagerweij.github.io/vue-doctor/rules/)**
333
+ - **[CI & GitHub PR Guide](https://remylagerweij.github.io/vue-doctor/guide/ci)**
334
+ - **[AI Agents Playbook](https://remylagerweij.github.io/vue-doctor/guide/agents)**
335
+ - **[Model Context Protocol (MCP) Guide](https://remylagerweij.github.io/vue-doctor/guide/mcp)**
336
+ - **[CLI Reference](https://remylagerweij.github.io/vue-doctor/reference/cli)**
337
+ - **[Configuration Reference](https://remylagerweij.github.io/vue-doctor/reference/config)**
338
+ - **[LLM Full-Text Reference (`llms.txt`)](https://remylagerweij.github.io/vue-doctor/llms.txt)**
150
339
 
151
- - **Vue 3** (Composition API, `<script setup>`)
152
- - **Nuxt 3** (auto-detected, enables Nuxt-specific rules)
153
- - **Vite** / **Quasar** / **Vue CLI**
154
- - **Monorepo** workspaces (npm, pnpm, yarn)
340
+ ---
155
341
 
156
- ## License
342
+ ## 📄 License
157
343
 
158
- MIT
344
+ [MIT](https://github.com/remylagerweij/vue-doctor/blob/main/LICENSE) © [Remy Martin Lagerweij](https://github.com/remylagerweij)