vite-doctor 0.0.1-alpha.2 → 0.0.2

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.
Files changed (57) hide show
  1. package/README.md +126 -0
  2. package/dist/cli.d.mts +1 -1
  3. package/dist/cli.mjs +98 -11
  4. package/dist/config-B96z9mkv.d.mts +44 -0
  5. package/dist/config-Dnzvhp-h.mjs +17 -0
  6. package/dist/config.d.mts +2 -0
  7. package/dist/config.mjs +2 -0
  8. package/dist/{dist-BrWLPMO_.mjs → core-DXS10waH.mjs} +1455 -2599
  9. package/dist/doctor-D_fAijfx.mjs +112 -0
  10. package/dist/index-BKZ67WMa.d.mts +1 -0
  11. package/dist/index-BVVgDSdq.d.mts +1 -0
  12. package/dist/index-BZ2DY0NT.d.mts +41 -0
  13. package/dist/index-oT29pHXX.d.mts +39 -0
  14. package/dist/index.d.mts +3 -2
  15. package/dist/index.mjs +3 -2
  16. package/dist/module-Cy-5RxgV.mjs +176 -0
  17. package/dist/module-D63348VO.d.mts +33 -0
  18. package/dist/nitro-CFxa1y5r.mjs +2 -0
  19. package/dist/nuxt.d.mts +2 -13
  20. package/dist/nuxt.mjs +1 -15785
  21. package/dist/plugin-CWjUWdmC.d.mts +23 -0
  22. package/dist/{plugin-BxANflhW.mjs → plugin-QYmdGYMa.mjs} +37 -4
  23. package/dist/plugin.d.mts +2 -2
  24. package/dist/plugin.mjs +1 -1
  25. package/dist/primitives-mLCLAmZ3.d.mts +524 -0
  26. package/dist/rule-packs/nitro/index.d.mts +2 -0
  27. package/dist/rule-packs/nitro/index.mjs +3 -0
  28. package/dist/rule-packs/nitro/rules.d.mts +2 -0
  29. package/dist/rule-packs/nitro/rules.mjs +2 -0
  30. package/dist/rule-packs/nuxt/index.d.mts +3 -0
  31. package/dist/rule-packs/nuxt/index.mjs +2 -0
  32. package/dist/rule-packs/nuxt/module.d.mts +3 -0
  33. package/dist/rule-packs/nuxt/module.mjs +2 -0
  34. package/dist/rule-packs/nuxt/rules/index.d.mts +34 -0
  35. package/dist/rule-packs/nuxt/rules/index.mjs +3 -0
  36. package/dist/rule-packs/vite/index.d.mts +2 -0
  37. package/dist/rule-packs/vite/index.mjs +2 -0
  38. package/dist/rule-packs/vite/rules/index.d.mts +2 -0
  39. package/dist/rule-packs/vite/rules/index.mjs +2 -0
  40. package/dist/rule-packs/vue/index.d.mts +2 -0
  41. package/dist/rule-packs/vue/index.mjs +2 -0
  42. package/dist/rule-packs/vue/rules.d.mts +2 -0
  43. package/dist/rule-packs/vue/rules.mjs +2 -0
  44. package/dist/rules-8_T4dDGE.mjs +2 -0
  45. package/dist/rules-BELxdqAV.d.mts +79 -0
  46. package/dist/rules-Ci1PkZG_.mjs +529 -0
  47. package/dist/{rules-WBqh_GLn.mjs → rules-CpZKSMoL.mjs} +507 -91
  48. package/dist/{rules-B-3hPfgr.mjs → rules-TJ8mVfH6.mjs} +239 -102
  49. package/dist/{rules-DFoclETT.mjs → rules-Wl3xtW3p.mjs} +854 -748
  50. package/dist/rules.d.mts +1 -409
  51. package/dist/rules.mjs +2 -1
  52. package/package.json +67 -36
  53. package/dist/cli-be9W7NnU.mjs +0 -76
  54. package/dist/doctor-Bke3eE9Z.mjs +0 -91
  55. package/dist/plugin-Ch9LazsD.d.mts +0 -19
  56. package/dist/rules-CX8QGsK4.mjs +0 -2
  57. package/dist/rules-FTCJ71Xs.mjs +0 -2
package/README.md ADDED
@@ -0,0 +1,126 @@
1
+ <p align="center">
2
+ <img src="https://vite-doctor.onmax.me/og/doctor-lifeline-bg.png" alt="Vite Doctor" width="100%">
3
+ </p>
4
+
5
+ <h1 align="center"><img src="https://vite-doctor.onmax.me/doctor-icon.png" alt="" width="32" height="32" style="vertical-align: middle;"> Vite Doctor</h1>
6
+
7
+ <p align="center">Catch framework bugs AI agents miss. Diagnostics for Nuxt, Vue, Nitro and Vite.</p>
8
+
9
+ <p align="center">
10
+ <code>pnpm dlx vite-doctor .</code>
11
+ </p>
12
+
13
+ <p align="center">
14
+ <a href="https://vite-doctor.onmax.me">Docs</a>
15
+ </p>
16
+
17
+ ## Usage
18
+
19
+ Run Vite Doctor from the project root:
20
+
21
+ ```bash
22
+ pnpm dlx vite-doctor .
23
+ ```
24
+
25
+ Vite Doctor reads app code, build config, project metadata, and server handlers to catch framework bugs before review. It picks the Nuxt, Vue, Nitro, or Vite diagnostics that fit your project.
26
+
27
+ Need a narrower Doctor Run? Select exact presets, one Rule, or a framework override:
28
+
29
+ ```bash
30
+ pnpm dlx vite-doctor . --extends vite/recommended,vue/recommended
31
+ pnpm dlx vite-doctor . --rules nuxt/fetch/no-raw-fetch-in-setup
32
+ pnpm dlx vite-doctor . --framework nitro
33
+ ```
34
+
35
+ For Nuxt projects, install Vite Doctor and run it through Nuxt:
36
+
37
+ ```bash
38
+ pnpm add -D vite-doctor
39
+ pnpm nuxt doctor
40
+ ```
41
+
42
+ Use `--framework` only when Doctor cannot identify the framework automatically.
43
+
44
+ ## Configuration
45
+
46
+ Standalone trusted config files can use the full Doctor config shape:
47
+
48
+ ```ts
49
+ // doctor.config.ts
50
+ import { defineDoctorConfig } from "vite-doctor/config";
51
+
52
+ export default defineDoctorConfig({
53
+ rules: {
54
+ "vite/define/no-secret-define": "error",
55
+ },
56
+ });
57
+ ```
58
+
59
+ Plugin surfaces accept the same policy through host config:
60
+
61
+ ```ts
62
+ // vite.config.ts
63
+ import { doctor } from "vite-doctor";
64
+
65
+ export default {
66
+ plugins: [
67
+ doctor({
68
+ config: {
69
+ rules: {
70
+ "vite/define/no-secret-define": "error",
71
+ },
72
+ },
73
+ }),
74
+ ],
75
+ };
76
+ ```
77
+
78
+ In Vite config, the same plugin covers Vite, Vue, and Nitro projects. Doctor picks the matching diagnostics automatically:
79
+
80
+ ```ts
81
+ // vite.config.ts
82
+ import { doctor } from "vite-doctor";
83
+
84
+ export default {
85
+ plugins: [doctor()],
86
+ };
87
+ ```
88
+
89
+ Set `framework: "nitro"` only when Doctor cannot identify the framework automatically:
90
+
91
+ ```ts
92
+ // vite.config.ts
93
+ import { doctor } from "vite-doctor";
94
+
95
+ export default {
96
+ plugins: [doctor({ framework: "nitro" })],
97
+ };
98
+ ```
99
+
100
+ Use the Nuxt module surface for Nuxt-specific configuration:
101
+
102
+ ```ts
103
+ // nuxt.config.ts
104
+ export default defineNuxtConfig({
105
+ modules: [
106
+ [
107
+ "vite-doctor/nuxt",
108
+ {
109
+ config: {
110
+ rules: {
111
+ "nuxt/routing/prefer-nuxt-useroute": "error",
112
+ },
113
+ },
114
+ },
115
+ ],
116
+ ],
117
+ });
118
+ ```
119
+
120
+ ## Development
121
+
122
+ ```bash
123
+ vp run ready
124
+ vp run -r test
125
+ vp run -r build
126
+ ```
package/dist/cli.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- //#region src/cli.d.ts
1
+ //#region src/cli-main.d.ts
2
2
  declare function main(args?: string[], cwd?: string): Promise<number>;
3
3
  //#endregion
4
4
  export { main };
package/dist/cli.mjs CHANGED
@@ -1,13 +1,94 @@
1
1
  #!/usr/bin/env node
2
- import { a as createReport, o as createRulesReport, s as explainRule, t as cleanCache } from "./dist-BrWLPMO_.mjs";
3
- import { n as shouldFailDoctorRun, r as viteDoctorRulePacks, t as runViteDoctor } from "./doctor-Bke3eE9Z.mjs";
4
- import { n as normalizeDoctorCommand, r as parseDoctorArgs, t as applyDoctorOptions } from "./cli-be9W7NnU.mjs";
2
+ import { i as explainRule, n as createReport, o as cleanCache, r as createRulesReport } from "./core-DXS10waH.mjs";
3
+ import { i as viteDoctorVersion, n as shouldFailDoctorRun, r as viteDoctorRulePacks, t as runViteDoctor } from "./doctor-D_fAijfx.mjs";
5
4
  import { resolve } from "pathe";
6
5
  import { realpathSync, statSync } from "node:fs";
7
6
  import { fileURLToPath } from "node:url";
8
- import { consola } from "consola";
9
7
  import { cac } from "cac";
10
- //#region src/cli.ts
8
+ import { consola } from "consola";
9
+ //#region src/core/internal/cli.ts
10
+ function parseDoctorArgs(args) {
11
+ const options = {};
12
+ let path = ".";
13
+ for (let index = 0; index < args.length; index++) {
14
+ const arg = args[index];
15
+ if (arg === "--changed") options.changed = true;
16
+ else if (arg === "--types") options.types = true;
17
+ else if (arg === "--threads") options.threads = Number(args[++index]);
18
+ else if (arg === "--coverage") options.coverage = args[++index];
19
+ else if (arg === "--runtime-evidence") options.runtimeEvidence = args[++index];
20
+ else if (arg === "--analyses") options.analyses = args[++index];
21
+ else if (arg === "--emit-graph") options.emitGraph = true;
22
+ else if (arg === "--confidence-min") options.confidenceMin = args[++index];
23
+ else if (arg === "--structural-review") options.structuralReview = true;
24
+ else if (arg === "--no-types") options.types = false;
25
+ else if (arg === "--profile") options.profile = true;
26
+ else if (arg === "--new-only") options.newOnly = true;
27
+ else if (arg === "--update-baseline") options.updateBaseline = true;
28
+ else if (arg === "--cache") options.cache = true;
29
+ else if (arg === "--no-cache") options.cache = false;
30
+ else if (arg === "--fix") options.fix = true;
31
+ else if (arg === "--unsafe-fix") options.unsafeFix = true;
32
+ else if (arg === "--max-warnings") options.maxWarnings = Number(args[++index]);
33
+ else if (arg === "--framework") options.framework = args[++index];
34
+ else if (arg === "--rules") options.rules = args[++index];
35
+ else if (arg === "--severity") options.severity = args[++index];
36
+ else if (arg === "--extends") options.extends = parseExtends(args[++index]);
37
+ else if (arg === "--since") options.since = args[++index];
38
+ else if (arg === "--baseline") options.baseline = args[++index];
39
+ else if (arg === "--format") options.format = args[++index];
40
+ else if (!arg.startsWith("-")) path = arg;
41
+ }
42
+ return {
43
+ options,
44
+ path
45
+ };
46
+ }
47
+ function applyDoctorOptions(options, flags) {
48
+ if (flags.changed) options.changed = true;
49
+ if (flags.types) options.types = true;
50
+ if (flags.threads) options.threads = Number(flags.threads);
51
+ options.coverage = stringFlag(flags.coverage) ?? options.coverage;
52
+ options.runtimeEvidence = stringFlag(flags.runtimeEvidence) ?? options.runtimeEvidence;
53
+ options.analyses = stringFlag(flags.analyses) ?? options.analyses;
54
+ if (flags.emitGraph) options.emitGraph = true;
55
+ options.confidenceMin = stringFlag(flags.confidenceMin) ?? options.confidenceMin;
56
+ if (flags.structuralReview) options.structuralReview = true;
57
+ if (flags.types === false) options.types = false;
58
+ if (flags.profile) options.profile = true;
59
+ if (flags.newOnly) options.newOnly = true;
60
+ if (flags.updateBaseline) options.updateBaseline = true;
61
+ if (flags.cache) options.cache = true;
62
+ if (flags.cache === false) options.cache = false;
63
+ if (flags.fix) options.fix = true;
64
+ if (flags.unsafeFix) options.unsafeFix = true;
65
+ if (flags.maxWarnings !== void 0) options.maxWarnings = Number(flags.maxWarnings);
66
+ options.framework = stringFlag(flags.framework) ?? options.framework;
67
+ options.rules = stringFlag(flags.rules) ?? options.rules;
68
+ options.severity = stringFlag(flags.severity) ?? options.severity;
69
+ options.extends = parseExtendsFlag(flags.extends) ?? options.extends;
70
+ options.since = stringFlag(flags.since) ?? options.since;
71
+ options.baseline = stringFlag(flags.baseline) ?? options.baseline;
72
+ options.format = stringFlag(flags.format) ?? options.format;
73
+ }
74
+ function parseExtends(value) {
75
+ if (!value || value === "auto") return "auto";
76
+ return value.split(",").map((item) => item.trim()).filter(Boolean);
77
+ }
78
+ function parseExtendsFlag(value) {
79
+ return typeof value === "string" ? parseExtends(value) : void 0;
80
+ }
81
+ function stringFlag(value) {
82
+ return typeof value === "string" ? value : void 0;
83
+ }
84
+ function normalizeDoctorCommand(args, commands) {
85
+ const first = args.find((arg) => !arg.startsWith("-"));
86
+ if (!first) return ["scan", ...args];
87
+ if (commands.has(first)) return args;
88
+ return ["scan", ...args];
89
+ }
90
+ //#endregion
91
+ //#region src/cli-main.ts
11
92
  const commands = new Set([
12
93
  "scan",
13
94
  "check",
@@ -17,6 +98,10 @@ const commands = new Set([
17
98
  ]);
18
99
  const removedCommands = new Set(["run", "ci"]);
19
100
  async function main(args = process.argv.slice(2), cwd = process.cwd()) {
101
+ if (args.includes("--version") || args.includes("-v")) {
102
+ process.stdout.write(`${viteDoctorVersion}\n`);
103
+ return 0;
104
+ }
20
105
  if (removedCommands.has(args[0] ?? "")) {
21
106
  errorHuman(`vite-doctor ${args[0]} was removed. Use your package manager scripts directly.`);
22
107
  return 1;
@@ -25,13 +110,13 @@ async function main(args = process.argv.slice(2), cwd = process.cwd()) {
25
110
  const cli = cac("vite-doctor");
26
111
  addScanCommand(cli, "scan", cwd, (code) => exitCode = code);
27
112
  addScanCommand(cli, "check", cwd, (code) => exitCode = code);
28
- cli.command("rules", "List available Doctor rules.").option("--format <format>", "Output format.").option("--framework <framework>", "Framework override.").action(async (options) => {
29
- const runOptions = {};
113
+ cli.command("rules", "List available Doctor rules.").option("--format <format>", "Machine output: json or sarif.").option("--framework <framework>", "Framework override.").action(async (options) => {
114
+ const runOptions = { root: cwd };
30
115
  applyDoctorOptions(runOptions, options);
31
116
  process.stdout.write(createRulesReport(await viteDoctorRulePacks(runOptions), runOptions.format));
32
117
  });
33
- cli.command("explain <rule>", "Explain a Doctor rule.").option("--format <format>", "Output format.").option("--framework <framework>", "Framework override.").action(async (rule, options) => {
34
- const runOptions = {};
118
+ cli.command("explain <rule>", "Explain a Doctor rule.").option("--format <format>", "Machine output: json or sarif.").option("--framework <framework>", "Framework override.").action(async (rule, options) => {
119
+ const runOptions = { root: cwd };
35
120
  applyDoctorOptions(runOptions, options);
36
121
  process.stdout.write(explainRule(await viteDoctorRulePacks(runOptions), rule, runOptions.format));
37
122
  });
@@ -60,11 +145,11 @@ async function main(args = process.argv.slice(2), cwd = process.cwd()) {
60
145
  }
61
146
  }
62
147
  function addScanCommand(cli, name, cwd, setExitCode) {
63
- cli.command(`${name} [path]`, `Run ${name} diagnostics.`).option("--changed", "Only scan changed files.").option("--types", "Enable type-aware checks.").option("--threads <threads>", "Thread count.").option("--analyses <analyses>", "Analyses to run.").option("--profile", "Include timings.").option("--new-only", "Only report new diagnostics.").option("--cache", "Use cache.").option("--no-cache", "Disable cache.").option("--fix", "Apply safe fixes.").option("--unsafe-fix", "Apply unsafe fixes.").option("--max-warnings <count>", "Maximum warnings.").option("--framework <framework>", "Framework override.").option("--rules <rules>", "Rule selector.").option("--severity <severity>", "Minimum severity.").option("--preset <preset>", "Rule preset.").option("--since <ref>", "Git base ref.").option("--baseline <file>", "Baseline file.").option("--format <format>", "Output format.").option("--config", "Unsupported in vite-doctor.").option("--trusted-config", "Unsupported in vite-doctor.").action(async (path = ".", options) => {
148
+ cli.command(`${name} [path]`, `Run ${name} diagnostics.`).option("--changed", "Only scan changed files.").option("--types", "Enable type-aware checks.").option("--threads <threads>", "Thread count.").option("--analyses <analyses>", "Analyses to run.").option("--profile", "Include timings.").option("--new-only", "Only report new diagnostics.").option("--cache", "Use cache.").option("--no-cache", "Disable cache.").option("--fix", "Apply safe fixes.").option("--unsafe-fix", "Apply unsafe fixes.").option("--max-warnings <count>", "Maximum warnings.").option("--framework <framework>", "Framework override.").option("--rules <rules>", "Rule selector.").option("--severity <severity>", "Minimum severity.").option("--extends <extends>", "Comma-separated rule-pack presets.").option("--since <ref>", "Git base ref.").option("--baseline <file>", "Baseline file.").option("--format <format>", "Machine output: json or sarif.").option("--config", "Unsupported in vite-doctor.").option("--trusted-config", "Unsupported in vite-doctor.").action(async (path = ".", options) => {
64
149
  const parsed = parseDoctorArgs([path]);
65
150
  applyDoctorOptions(parsed.options, options);
66
151
  if (options.config || options.trustedConfig) {
67
- errorHuman("Executable config loading was removed from vite-doctor. Use vue-doctor, nuxt-doctor, or @vue-doctor/core/config for trusted config files.");
152
+ errorHuman("Executable config loading was removed from vite-doctor. Use built-in framework auto-activation or vite-doctor/config for trusted config files.");
68
153
  setExitCode(1);
69
154
  return;
70
155
  }
@@ -88,6 +173,8 @@ function errorHuman(message) {
88
173
  consola.error(message);
89
174
  if (process.env.VITEST_WORKER_ID) console.error(message);
90
175
  }
176
+ //#endregion
177
+ //#region src/cli.ts
91
178
  const currentFile = fileURLToPath(import.meta.url);
92
179
  if (process.argv[1] && realpathSync(process.argv[1]) === currentFile) process.exitCode = await main();
93
180
  //#endregion
@@ -0,0 +1,44 @@
1
+ import { i as DoctorSerializableConfig, n as DoctorFramework, t as DoctorExtension } from "./primitives-mLCLAmZ3.mjs";
2
+
3
+ //#region src/core/config.d.ts
4
+ interface DoctorConfig extends DoctorSerializableConfig {
5
+ extensions?: DoctorExtension[];
6
+ }
7
+ interface DoctorRunOptions {
8
+ root?: string;
9
+ /** Already-loaded Doctor config. */
10
+ config?: DoctorConfig;
11
+ framework?: "auto" | DoctorFramework;
12
+ extends?: "auto" | string[];
13
+ changed?: boolean;
14
+ since?: string;
15
+ format?: string;
16
+ baseline?: string;
17
+ updateBaseline?: boolean;
18
+ newOnly?: boolean;
19
+ severity?: "error" | "warn" | "info";
20
+ rules?: string;
21
+ types?: boolean;
22
+ threads?: number;
23
+ coverage?: string;
24
+ runtimeEvidence?: string;
25
+ analyses?: string;
26
+ emitGraph?: boolean;
27
+ confidenceMin?: string;
28
+ structuralReview?: boolean;
29
+ profile?: boolean;
30
+ cache?: boolean;
31
+ fix?: boolean;
32
+ unsafeFix?: boolean;
33
+ scoreOnly?: boolean;
34
+ maxWarnings?: number;
35
+ extensions?: DoctorExtension[];
36
+ }
37
+ declare function defineDoctorConfig(config: DoctorConfig): DoctorConfig;
38
+ interface LoadDoctorConfigOptions {
39
+ cwd: string;
40
+ defaults?: DoctorConfig;
41
+ }
42
+ declare function loadDoctorConfig(options: LoadDoctorConfigOptions): Promise<DoctorConfig>;
43
+ //#endregion
44
+ export { loadDoctorConfig as a, defineDoctorConfig as i, DoctorRunOptions as n, LoadDoctorConfigOptions as r, DoctorConfig as t };
@@ -0,0 +1,17 @@
1
+ import { loadConfig } from "c12";
2
+ import { defu } from "defu";
3
+ //#region src/core/config.ts
4
+ function defineDoctorConfig(config) {
5
+ return config;
6
+ }
7
+ async function loadDoctorConfig(options) {
8
+ return defu((await loadConfig({
9
+ configFile: "doctor.config",
10
+ cwd: options.cwd,
11
+ dotenv: false,
12
+ globalRc: false,
13
+ name: "doctor"
14
+ })).config ?? {}, options.defaults ?? {});
15
+ }
16
+ //#endregion
17
+ export { loadDoctorConfig as n, defineDoctorConfig as t };
@@ -0,0 +1,2 @@
1
+ import { a as loadDoctorConfig, i as defineDoctorConfig, n as DoctorRunOptions, r as LoadDoctorConfigOptions, t as DoctorConfig } from "./config-B96z9mkv.mjs";
2
+ export { type DoctorConfig, type DoctorRunOptions, type LoadDoctorConfigOptions, defineDoctorConfig, loadDoctorConfig };
@@ -0,0 +1,2 @@
1
+ import { n as loadDoctorConfig, t as defineDoctorConfig } from "./config-Dnzvhp-h.mjs";
2
+ export { defineDoctorConfig, loadDoctorConfig };