@remylagerweij/vue-doctor 1.1.2 → 2.0.1

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
@@ -12,22 +12,23 @@ npx vue-doctor@latest
12
12
 
13
13
  Vue Doctor runs **three parallel analysis passes** on your codebase:
14
14
 
15
- ### 1. Oxlint + Vue Doctor Plugin (46 rules)
15
+ ### 1. Oxlint + Vue Doctor Plugin (59 rules, 54 on by default)
16
16
  Custom ESTree-based rules for Vue.js:
17
17
 
18
18
  | Category | Rules | Examples |
19
19
  |----------|-------|---------|
20
- | **Reactivity** | 7 | `no-fetch-in-watch`, `no-watch-for-computed`, `prefer-computed` |
20
+ | **Reactivity** | 9 | `no-fetch-in-watch`, `no-watch-for-computed`, `prefer-computed` |
21
21
  | **Ecosystem** | 4 | `pinia-no-destructure`, `router-no-string-push` |
22
22
  | **Architecture** | 2 | `no-giant-component`, `no-nested-component-definition` |
23
- | **Performance** | 16 | `no-transition-all`, `no-layout-property-animation`, `async-parallel` |
24
- | **Security** | 2 | `no-secrets-in-client-code`, `no-v-html` |
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
25
  | **Bundle Size** | 5 | `no-full-lodash-import`, `no-moment`, `prefer-dynamic-import` |
26
- | **Correctness** | 4 | `no-array-index-as-key`, `no-prevent-default`, `no-direct-dom-manipulation` |
27
- | **Nuxt** | 5 | `nuxt-no-img-element`, `nuxt-no-a-element`, `nuxt-async-client-component` |
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
28
  | **Server** | 1 | `server-no-console-in-handler` |
29
+ | **Supply Chain** | 3 | `lockfile-integrity`, `no-remote-dependency-spec`, `no-dependency-install-scripts` (project checks) |
29
30
 
30
- ### 2. ESLint Plugin Vue (19 template rules)
31
+ ### 2. ESLint Plugin Vue (20 template rules)
31
32
  Template-level analysis with `eslint-plugin-vue`:
32
33
  - `vue/require-v-for-key`, `vue/no-use-v-if-with-v-for`
33
34
  - `vue/no-mutating-props`, `vue/no-ref-as-operand`
@@ -66,29 +67,61 @@ vue-doctor --diff main
66
67
 
67
68
  ## Configuration
68
69
 
69
- Create a `vue-doctor.config.json` in your project root:
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.
71
+
72
+ ```ts
73
+ // vue-doctor.config.ts
74
+ import { defineConfig } from "@remylagerweij/vue-doctor";
75
+
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
+ });
86
+ ```
70
87
 
71
88
  ```json
72
89
  {
73
- "ignore": {
74
- "rules": ["no-giant-component"],
75
- "paths": ["legacy/**"]
76
- }
90
+ "$schema": "./node_modules/@remylagerweij/vue-doctor/schema/vue-doctor.schema.json",
91
+ "ignore": { "files": ["src/legacy/**"] }
77
92
  }
78
93
  ```
79
94
 
80
- Or add to `package.json`:
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.
81
99
 
82
- ```json
83
- {
84
- "vueDoctor": {
85
- "ignore": {
86
- "rules": ["no-prevent-default"]
87
- }
88
- }
89
- }
100
+ ## Baseline
101
+
102
+ Adopting Vue Doctor on an existing codebase? Record today's findings and only fail on new ones:
103
+
104
+ ```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
90
107
  ```
91
108
 
109
+ Set `"baseline": ".vue-doctor-baseline.json"` in the config to apply it by default. Fingerprints survive code moving within a file.
110
+
111
+ ## Suppressing Findings
112
+
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.
114
+
115
+ ```ts
116
+ // vue-doctor-disable-next-line vue-doctor/bundle-size/no-moment -- legacy report page
117
+ import moment from "moment";
118
+ 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
121
+ ```
122
+
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.
124
+
92
125
  ## Programmatic API
93
126
 
94
127
  ```ts