vite-doctor 0.0.8 → 0.0.10

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 (69) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +16 -12
  3. package/dist/cli.mjs +4 -10
  4. package/dist/{config-BX26IYzh.mjs → config-CaJ0DqB3.mjs} +1 -0
  5. package/dist/{config-BF-tCiTu.d.mts → config-DWmchdeh.d.mts} +1 -7
  6. package/dist/config.d.mts +1 -1
  7. package/dist/config.mjs +1 -1
  8. package/dist/{core-DLeqgOx5.mjs → core-CztxQ3dO.mjs} +12 -125
  9. package/dist/diagnostics-DYlg2f-e.d.mts +21 -0
  10. package/dist/diagnostics-OWBdo3Uc.mjs +102 -0
  11. package/dist/{doctor-CwNKe5uB.mjs → doctor-DZThqTQg.mjs} +11 -15
  12. package/dist/extension-DyFj4vXT.d.mts +2 -0
  13. package/dist/extension.d.mts +4 -0
  14. package/dist/extension.mjs +2 -0
  15. package/dist/{index-vpjcMmhA.d.mts → index-BjF8I0Dg.d.mts} +1 -1
  16. package/dist/{index-Dw9aENZG.d.mts → index-CzHsaAnb.d.mts} +1 -1
  17. package/dist/{index-BJU56z7q.d.mts → index-DLp2anMW.d.mts} +2 -1
  18. package/dist/index-Dx-JzQ3s.d.mts +3 -0
  19. package/dist/index-OV2dDmkX.d.mts +1 -0
  20. package/dist/index.d.mts +2 -2
  21. package/dist/index.mjs +2 -2
  22. package/dist/{module-DWXrUl_H.d.mts → module-Cm_Da1lK.d.mts} +6 -9
  23. package/dist/{module--Dgf9XPW.mjs → module-DFUEExm6.mjs} +13 -9
  24. package/dist/nitro-FnvPw8Up.mjs +2 -0
  25. package/dist/nuxt.d.mts +1 -1
  26. package/dist/nuxt.mjs +1 -1
  27. package/dist/{plugin-BKNEtcVs.d.mts → plugin-B97s20vt.d.mts} +3 -3
  28. package/dist/{plugin-BCCA3oXP.mjs → plugin-DXJRUrg6.mjs} +3 -2
  29. package/dist/plugin.d.mts +1 -1
  30. package/dist/plugin.mjs +1 -1
  31. package/dist/{primitives-3i5qmm5e.d.mts → primitives-8DoGel1u.d.mts} +7 -77
  32. package/dist/rule-packs/nitro/index.d.mts +2 -2
  33. package/dist/rule-packs/nitro/index.mjs +2 -2
  34. package/dist/rule-packs/nitro/rules.d.mts +1 -1
  35. package/dist/rule-packs/nitro/rules.mjs +1 -1
  36. package/dist/rule-packs/nuxt/index.d.mts +2 -2
  37. package/dist/rule-packs/nuxt/index.mjs +1 -1
  38. package/dist/rule-packs/nuxt/module.d.mts +2 -2
  39. package/dist/rule-packs/nuxt/module.mjs +1 -1
  40. package/dist/rule-packs/nuxt/rules/index.d.mts +5 -4
  41. package/dist/rule-packs/nuxt/rules/index.mjs +2 -2
  42. package/dist/rule-packs/typescript/index.d.mts +1 -1
  43. package/dist/rule-packs/typescript/index.mjs +2 -2
  44. package/dist/rule-packs/typescript/rules/index.d.mts +1 -1
  45. package/dist/rule-packs/typescript/rules/index.mjs +1 -1
  46. package/dist/rule-packs/vite/index.d.mts +1 -1
  47. package/dist/rule-packs/vite/index.mjs +1 -1
  48. package/dist/rule-packs/vite/rules/index.d.mts +1 -1
  49. package/dist/rule-packs/vite/rules/index.mjs +1 -1
  50. package/dist/rule-packs/vue/index.d.mts +1 -1
  51. package/dist/rule-packs/vue/index.mjs +1 -1
  52. package/dist/rule-packs/vue/rules.d.mts +1 -1
  53. package/dist/rule-packs/vue/rules.mjs +1 -1
  54. package/dist/{rules-D3X57pir.mjs → rules-03OSDgOR.mjs} +2 -1
  55. package/dist/{rules-BKTr-IUz.mjs → rules-298lNPbq.mjs} +2 -1
  56. package/dist/{rules-Bq9PexjC.mjs → rules-BfmRH-w3.mjs} +2 -1
  57. package/dist/{rules-htM7saRv.d.mts → rules-BhptD0Ul.d.mts} +2 -1
  58. package/dist/{rules-22ICiQaK.mjs → rules-Cg6CMffp.mjs} +5 -4
  59. package/dist/{rules-Cc1_NZ7P.mjs → rules-D228x7hu.mjs} +2 -1
  60. package/dist/rules-htE_WDPD.mjs +2 -0
  61. package/dist/rules.d.mts +1 -1
  62. package/dist/rules.mjs +2 -2
  63. package/dist/typescript-etB5nu2i.mjs +2 -0
  64. package/package.json +6 -3
  65. package/dist/index-B6nzQEFO.d.mts +0 -3
  66. package/dist/index-DgRcIdSA.d.mts +0 -1
  67. package/dist/nitro-aRdLgPkY.mjs +0 -2
  68. package/dist/rules-BkrZ1R0E.mjs +0 -2
  69. package/dist/typescript-Br-J4sLq.mjs +0 -2
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 onmax
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -144,21 +144,25 @@ Use the Nuxt module surface for Nuxt-specific configuration:
144
144
  ```ts
145
145
  // nuxt.config.ts
146
146
  export default defineNuxtConfig({
147
- modules: [
148
- [
149
- "vite-doctor/nuxt",
150
- {
151
- config: {
152
- rules: {
153
- "nuxt/routing/prefer-nuxt-useroute": "error",
154
- },
155
- },
156
- },
157
- ],
158
- ],
147
+ modules: ["vite-doctor/nuxt"],
148
+ doctor: {
149
+ rules: {
150
+ "nuxt/routing/prefer-nuxt-useroute": "error",
151
+ },
152
+ },
159
153
  });
160
154
  ```
161
155
 
156
+ ### Removed run options
157
+
158
+ Remove `coverage`, `runtimeEvidence`, `emitGraph`, `confidenceMin`, and `scoreOnly` from `DoctorRunOptions` objects. These options had no effect on Doctor Runs; their removal is a breaking TypeScript API change. Runtime Evidence contributors, graph reports, diagnostic confidence, and scoring remain supported.
159
+
160
+ ## Doctor extensions
161
+
162
+ Library authors can import `createRule`, `defineRulePack`, `defineDoctorExtension`, and
163
+ `defineDoctorDiagnostics` from `vite-doctor/extension`. The same entrypoint exports their
164
+ authoring types.
165
+
162
166
  ## Development
163
167
 
164
168
  ```bash
package/dist/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
- import { a as reportStatus, d as detectProject, i as explainRule, l as cleanCache, n as createReport, r as createRulesReport, u as evaluateRuleApplicability } from "./core-DLeqgOx5.mjs";
3
- import { n as loadDoctorConfig } from "./config-BX26IYzh.mjs";
4
- import { i as viteDoctorVersion, n as shouldFailDoctorRun, r as viteDoctorRulePacks, t as runViteDoctor } from "./doctor-CwNKe5uB.mjs";
2
+ import { a as reportStatus, c as detectProject, i as explainRule, n as createReport, o as cleanCache, r as createRulesReport, s as evaluateRuleApplicability } from "./core-CztxQ3dO.mjs";
3
+ import { n as loadDoctorConfig } from "./config-CaJ0DqB3.mjs";
4
+ import { i as viteDoctorVersion, n as shouldFailDoctorRun, r as viteDoctorRulePacks, t as runViteDoctor } from "./doctor-DZThqTQg.mjs";
5
5
  import { relative, resolve } from "pathe";
6
6
  import { existsSync, readFileSync, realpathSync, statSync } from "node:fs";
7
7
  import { fileURLToPath } from "node:url";
@@ -41,14 +41,8 @@ async function selectDoctorPresentation(explicitFormat, runtime = currentRuntime
41
41
  //#region src/core/internal/cli.ts
42
42
  function applyDoctorOptions(options, flags) {
43
43
  if (flags.changed) options.changed = true;
44
- if (flags.types) options.types = true;
45
- options.coverage = stringFlag(flags.coverage) ?? options.coverage;
46
- options.runtimeEvidence = stringFlag(flags.runtimeEvidence) ?? options.runtimeEvidence;
47
44
  options.analyses = stringFlag(flags.analyses) ?? options.analyses;
48
- if (flags.emitGraph) options.emitGraph = true;
49
- options.confidenceMin = stringFlag(flags.confidenceMin) ?? options.confidenceMin;
50
45
  if (flags.structuralReview) options.structuralReview = true;
51
- if (flags.types === false) options.types = false;
52
46
  if (flags.profile) options.profile = true;
53
47
  if (flags.newOnly) options.newOnly = true;
54
48
  if (flags.updateBaseline) options.updateBaseline = true;
@@ -391,7 +385,7 @@ async function main(args = process.argv.slice(2), cwd = process.cwd()) {
391
385
  }
392
386
  }
393
387
  function addDoctorRunCommand(cli, cwd, setExitCode) {
394
- cli.command("[path]", "Run Doctor diagnostics.").option("--changed", "Report diagnostics on changed lines.").option("--types", "Enable type-aware rules.").option("--analyses <analyses>", "Comma-separated analyses: dead-code, graph, dupes, or health.").option("--profile", "Include timings.").option("--new-only", "Only report diagnostics absent from the baseline.").option("--cache", "Use the analysis cache.").option("--no-cache", "Disable the analysis cache.").option("--fix", "Apply safe edit plans and verify the result.").option("--unsafe-fix", "Apply unsafe edit plans and verify the result.").option("--max-warnings <count>", "Maximum warnings before failure.").option("--framework <framework>", "Framework override: vite, vue, nitro, or nuxt.").option("--rules <rules>", "Comma-separated Rule selectors.").option("--severity <severity>", "Minimum severity: error, warn, or info.").option("--extends <extends>", "Comma-separated rule-pack presets.").option("--since <ref>", "Report diagnostics on lines changed since a Git ref.").option("--baseline <file>", "Diagnostic baseline file.").option("--format <format>", "Output: text, json, sarif, or agent.").option("--config <path>", "Explicitly load an executable Doctor config.").action(async (path = ".", options) => {
388
+ cli.command("[path]", "Run Doctor diagnostics.").option("--changed", "Report diagnostics on changed lines.").option("--analyses <analyses>", "Comma-separated analyses: dead-code, graph, dupes, or health.").option("--profile", "Include timings.").option("--new-only", "Only report diagnostics absent from the baseline.").option("--cache", "Use the analysis cache.").option("--no-cache", "Disable the analysis cache.").option("--fix", "Apply safe edit plans and verify the result.").option("--unsafe-fix", "Apply unsafe edit plans and verify the result.").option("--max-warnings <count>", "Maximum warnings before failure.").option("--framework <framework>", "Framework override: vite, vue, nitro, or nuxt.").option("--rules <rules>", "Comma-separated Rule selectors.").option("--severity <severity>", "Minimum severity: error, warn, or info.").option("--extends <extends>", "Comma-separated rule-pack presets.").option("--since <ref>", "Report diagnostics on lines changed since a Git ref.").option("--baseline <file>", "Diagnostic baseline file.").option("--format <format>", "Output: text, json, sarif, or agent.").option("--config <path>", "Explicitly load an executable Doctor config.").action(async (path = ".", options) => {
395
389
  const format = await presentationFormat(options.format, reportFormats);
396
390
  const root = resolve(cwd, path);
397
391
  if (!isDirectory(root)) {
@@ -11,6 +11,7 @@ async function loadDoctorConfig(options) {
11
11
  cwd: options.cwd,
12
12
  dotenv: false,
13
13
  globalRc: false,
14
+ extend: false,
14
15
  name: "doctor"
15
16
  });
16
17
  return defu(result.config ?? {}, options.defaults ?? {});
@@ -1,4 +1,4 @@
1
- import { a as DoctorSerializableConfig, c as RuntimeTarget, n as DoctorFramework, r as DoctorReportFormat, t as DoctorExtension } from "./primitives-3i5qmm5e.mjs";
1
+ import { i as DoctorReportFormat, m as RuntimeTarget, o as DoctorSerializableConfig, r as DoctorFramework, t as DoctorExtension } from "./primitives-8DoGel1u.mjs";
2
2
  //#region src/core/config.d.ts
3
3
  interface DoctorConfig extends DoctorSerializableConfig {
4
4
  extensions?: DoctorExtension[];
@@ -17,18 +17,12 @@ interface DoctorRunOptions {
17
17
  newOnly?: boolean;
18
18
  severity?: "error" | "warn" | "info";
19
19
  rules?: string;
20
- types?: boolean;
21
- coverage?: string;
22
- runtimeEvidence?: string;
23
20
  analyses?: string;
24
- emitGraph?: boolean;
25
- confidenceMin?: string;
26
21
  structuralReview?: boolean;
27
22
  profile?: boolean;
28
23
  cache?: boolean;
29
24
  fix?: boolean;
30
25
  unsafeFix?: boolean;
31
- scoreOnly?: boolean;
32
26
  maxWarnings?: number;
33
27
  extensions?: DoctorExtension[];
34
28
  runtimeTarget?: RuntimeTarget;
package/dist/config.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as loadDoctorConfig, i as defineDoctorConfig, n as DoctorRunOptions, r as LoadDoctorConfigOptions, t as DoctorConfig } from "./config-BF-tCiTu.mjs";
1
+ import { a as loadDoctorConfig, i as defineDoctorConfig, n as DoctorRunOptions, r as LoadDoctorConfigOptions, t as DoctorConfig } from "./config-DWmchdeh.mjs";
2
2
  export { type DoctorConfig, type DoctorRunOptions, type LoadDoctorConfigOptions, defineDoctorConfig, loadDoctorConfig };
package/dist/config.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as loadDoctorConfig, t as defineDoctorConfig } from "./config-BX26IYzh.mjs";
1
+ import { n as loadDoctorConfig, t as defineDoctorConfig } from "./config-CaJ0DqB3.mjs";
2
2
  export { defineDoctorConfig, loadDoctorConfig };
@@ -1,11 +1,12 @@
1
- import "./config-BX26IYzh.mjs";
1
+ import { c as DOCTOR_DIAGNOSTICS_DOCS_BASE, i as doctorDiagnosticsHost, l as doctorInternalDiagnostics, n as defineDoctorDiagnostics, r as diagnosticForCode, s as defineRulePack, t as codeForRuleId } from "./diagnostics-OWBdo3Uc.mjs";
2
+ import "./config-CaJ0DqB3.mjs";
2
3
  import { createRequire } from "node:module";
3
4
  import { dirname, join, relative, resolve } from "pathe";
4
5
  import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
5
6
  import { createHash, randomUUID } from "node:crypto";
6
7
  import * as oxcParser from "oxc-parser";
7
8
  import { parseSync } from "oxc-parser";
8
- import { defineDiagnostics, formatDiagnostic } from "nostics";
9
+ import { formatDiagnostic } from "nostics";
9
10
  import { glob } from "node:fs/promises";
10
11
  import { satisfies, valid, validRange } from "semver";
11
12
  import { matchesGlob } from "node:path";
@@ -123,70 +124,6 @@ function sha256$1(input) {
123
124
  return createHash("sha256").update(input).digest("hex");
124
125
  }
125
126
  //#endregion
126
- //#region src/core/internal-diagnostic-handles.ts
127
- const doctorInternalDiagnostics = defineDiagnostics({ codes: {
128
- DOC0012: {
129
- why: (params) => `Duplicate Doctor diagnostic code "${params.code}".`,
130
- fix: (params) => `Assign a unique Diagnostic Code instead of registering "${params.code}" twice.`
131
- },
132
- DOC0013: {
133
- why: (params) => params.code ? `No Doctor diagnostic handle is registered for rule "${params.ruleId}" and code "${params.code}".` : `No Doctor diagnostic code is registered for rule "${params.ruleId}".`,
134
- fix: "Register a Diagnostic Code for the rule before it can report diagnostics."
135
- },
136
- DOC0014: {
137
- why: (params) => `Rule "${params.ruleId}" reported a diagnostic without a nostics name/code.`,
138
- fix: "Report diagnostics through a registered Doctor nostics handle."
139
- },
140
- DOC0015: {
141
- why: (params) => `Rule pack "${params.pack}" must define a non-empty recommended preset.`,
142
- fix: "Add at least one rule ID to the rule pack recommended preset."
143
- },
144
- DOC0016: {
145
- why: (params) => `Invalid Config Extends entry "${params.entry}". Use "pack/preset".`,
146
- fix: "Use a rule-pack-qualified preset such as \"vite-doctor/vue/recommended\"."
147
- },
148
- DOC0017: {
149
- why: (params) => `Unknown Rule Pack "${params.pack}" in Config Extends entry "${params.entry}".`,
150
- fix: "Use an installed Rule Pack name or remove the Config Extends entry."
151
- },
152
- DOC0018: {
153
- why: (params) => `Unknown Preset "${params.preset}" for Rule Pack "${params.pack}" in Config Extends entry "${params.entry}".`,
154
- fix: "Use a Preset exposed by the selected Rule Pack."
155
- },
156
- DOC0019: {
157
- why: (params) => `Invalid severity for rule "${params.ruleId}": ${params.severity}.`,
158
- fix: "Use \"blocker\", \"error\", \"warn\", \"info\", or \"off\"."
159
- },
160
- DOC0020: {
161
- why: (params) => `Invalid config for rule "${params.ruleId}".`,
162
- fix: "Use \"off\", a severity string, or a [severity, options] tuple."
163
- },
164
- DOC0021: {
165
- why: (params) => params.code ? `Diagnostic "${params.code}" for rule "${params.ruleId}" is missing a fix.` : `Rule "${params.ruleId}" reported a diagnostic without a fix.`,
166
- fix: "Provide actionable nostics fix text for every Doctor diagnostic."
167
- },
168
- DOC0022: {
169
- why: (params) => `Doctor could not resolve the governing runtime graph: ${params.details}`,
170
- fix: "Install project dependencies and run Doctor from the target project package. For computed Nuxt config, make future.compatibilityVersion statically provable or run pnpm nuxt doctor so the Nuxt integration can record the resolved value."
171
- }
172
- } });
173
- //#endregion
174
- //#region src/core/diagnostic-constants.ts
175
- const DOCTOR_DIAGNOSTICS_DOCS_BASE = "https://vite-doctor.onmax.me/diagnostics";
176
- //#endregion
177
- //#region src/core/primitives.ts
178
- function createRule(rule) {
179
- return rule;
180
- }
181
- function defineRulePack(pack) {
182
- if (!pack.presets?.recommended?.length) throw doctorInternalDiagnostics.DOC0015({ pack: pack.name });
183
- return pack;
184
- }
185
- function defineDoctorExtension(extension) {
186
- for (const pack of extension.rulePacks ?? []) defineRulePack(pack);
187
- return extension;
188
- }
189
- //#endregion
190
127
  //#region src/core/internal/nuxt-inventory.ts
191
128
  function createNuxtProjectInventory(root, manifest, manifestPath, fallbackImportsDirs = []) {
192
129
  return {
@@ -1705,7 +1642,7 @@ async function createScanSession(options) {
1705
1642
  const registry = await collectRulePacks([...config.extensions ?? [], ...options.extensions ?? []]);
1706
1643
  await applyProjectContributions(project, registry);
1707
1644
  const ruleConfigs = resolveRuleConfigs(config);
1708
- const enabledRules = selectRules(registry, ruleConfigs, options, project);
1645
+ const enabledRules = selectRules(registry, ruleConfigs, options, config, project);
1709
1646
  markSession(sessionBase, "project", started);
1710
1647
  started = performance.now();
1711
1648
  const sourceInventory = await selectSourceInventory(root, config, options, project);
@@ -1775,15 +1712,12 @@ async function collectRulePacks(extensions) {
1775
1712
  registerRulePack(pack) {
1776
1713
  registeredPacks.push(pack);
1777
1714
  },
1778
- registerReporter() {},
1779
- registerProjectDetector() {},
1780
1715
  registerProjectInventoryContributor(contributor) {
1781
1716
  inventoryContributors.push(contributor);
1782
1717
  },
1783
1718
  registerRuntimeEvidenceContributor(contributor) {
1784
1719
  runtimeEvidenceContributors.push(contributor);
1785
- },
1786
- registerNuxtManifestContributor() {}
1720
+ }
1787
1721
  });
1788
1722
  const packs = [...extensions.flatMap((extension) => extension.rulePacks ?? []), ...registeredPacks].map((pack) => defineRulePack(pack));
1789
1723
  return {
@@ -1809,16 +1743,15 @@ async function applyProjectContributions(project, registry) {
1809
1743
  };
1810
1744
  }
1811
1745
  }
1812
- function selectRules(registry, ruleConfigs, options, project) {
1746
+ function selectRules(registry, ruleConfigs, options, config, project) {
1813
1747
  const wanted = options.rules?.split(",").map((item) => item.trim()).filter(Boolean);
1814
- const selectedRules = resolveExtends(registry.packs, options, project);
1815
- return registry.rules.filter((rule) => selectedRules.has(rule.meta.id)).filter((rule) => !rule.meta.requires?.nuxt || project.framework === "nuxt").filter((rule) => !rule.meta.requires?.nitro || project.framework === "nitro" || project.framework === "nuxt").filter((rule) => !rule.meta.requires?.vue || project.framework === "vue" || project.framework === "nuxt").filter((rule) => !rule.meta.requires?.types || options.types).filter((rule) => !wanted?.length || wanted.some((pattern) => nativeMatch$1(rule.meta.id, pattern))).filter((rule) => resolvedConfig(ruleConfigs, rule.meta.id).enabled).map((rule) => ({
1748
+ const selectedRules = resolveExtends(registry.packs, options.extends ?? config.extends, project);
1749
+ return registry.rules.filter((rule) => selectedRules.has(rule.meta.id)).filter((rule) => !rule.meta.requires?.nuxt || project.framework === "nuxt").filter((rule) => !rule.meta.requires?.nitro || project.framework === "nitro" || project.framework === "nuxt").filter((rule) => !rule.meta.requires?.vue || project.framework === "vue" || project.framework === "nuxt").filter((rule) => !wanted?.length || wanted.some((pattern) => nativeMatch$1(rule.meta.id, pattern))).filter((rule) => resolvedConfig(ruleConfigs, rule.meta.id).enabled).map((rule) => ({
1816
1750
  rule,
1817
1751
  applicability: evaluateRuleApplicability(rule, project)
1818
1752
  })).filter((item) => item.applicability.state === "active").map((item) => item.rule);
1819
1753
  }
1820
- function resolveExtends(packs, options, project) {
1821
- const requested = options.extends ?? options.config?.extends ?? "auto";
1754
+ function resolveExtends(packs, requested = "auto", project) {
1822
1755
  if (requested === "auto") return new Set(packs.filter((pack) => evaluatePackActivation(pack, project).state === "active").flatMap((pack) => pack.presets.recommended));
1823
1756
  const selected = /* @__PURE__ */ new Set();
1824
1757
  for (const entry of requested) {
@@ -2300,42 +2233,6 @@ function diagnosticPenalty(summary, weights) {
2300
2233
  return Math.min(100, blockerPenalty + errorPenalty + warnPenalty + infoPenalty);
2301
2234
  }
2302
2235
  //#endregion
2303
- //#region src/core/diagnostics.ts
2304
- function createDoctorDiagnosticsHost() {
2305
- const logger = {};
2306
- return {
2307
- defineDiagnostics: defineDoctorDiagnostics,
2308
- register(registry) {
2309
- for (const [code, handle] of Object.entries(registry.diagnostics)) {
2310
- if (logger[code]) throw doctorInternalDiagnostics.DOC0012({ code });
2311
- logger[code] = handle;
2312
- }
2313
- },
2314
- logger
2315
- };
2316
- }
2317
- const doctorDiagnosticsHost = createDoctorDiagnosticsHost();
2318
- function codeForRuleId(codesByRuleId, ruleId) {
2319
- return codesByRuleId[ruleId];
2320
- }
2321
- function diagnosticForCode(diagnostics, code) {
2322
- return code ? diagnostics[code] : void 0;
2323
- }
2324
- function defineDoctorDiagnostics(entries) {
2325
- const codes = Object.fromEntries(entries.map((entry) => [entry.code, {
2326
- why: (params) => params.why,
2327
- fix: (params) => params.fix,
2328
- ...entry.docs === void 0 ? {} : { docs: entry.docs }
2329
- }]));
2330
- return {
2331
- codesByRuleId: Object.fromEntries(entries.map((entry) => [entry.ruleId, entry.code])),
2332
- diagnostics: defineDiagnostics({
2333
- docsBase: (code) => `${DOCTOR_DIAGNOSTICS_DOCS_BASE}/${String(code)}`,
2334
- codes
2335
- })
2336
- };
2337
- }
2338
- //#endregion
2339
2236
  //#region src/core/diagnostic-code-map.ts
2340
2237
  const allDoctorDiagnosticRegistry = defineDoctorDiagnostics([
2341
2238
  {
@@ -3241,7 +3138,6 @@ function reportRuntimeInventoryUnknown(session) {
3241
3138
  }
3242
3139
  function defaultConfidenceForPhase(phase) {
3243
3140
  if (phase === "graph") return "proven";
3244
- if (phase === "type") return "type-backed";
3245
3141
  if (phase === "manifest") return "manifest-backed";
3246
3142
  if (phase === "duplication" || phase === "health") return "heuristic-high";
3247
3143
  return "heuristic-medium";
@@ -3250,7 +3146,6 @@ function evidenceKindForPhase(phase) {
3250
3146
  if (phase === "file") return "ast";
3251
3147
  if (phase === "manifest") return "manifest";
3252
3148
  if (phase === "graph" || phase === "workspace") return "graph";
3253
- if (phase === "type") return "types";
3254
3149
  if (phase === "duplication" || phase === "health") return "facts";
3255
3150
  return "facts";
3256
3151
  }
@@ -3853,7 +3748,7 @@ async function runFileRules(session) {
3853
3748
  for (const rule of session.enabledRules) {
3854
3749
  if ((rule.meta.execution ?? "file") !== "file") continue;
3855
3750
  for (const file of session.handles) {
3856
- if (!canRunRuleOnFile(rule, file, session.options)) continue;
3751
+ if (!canRunRuleOnFile(rule, file)) continue;
3857
3752
  const visitor = await rule.create(createRuleContext(session, file, rule));
3858
3753
  if (!visitor) continue;
3859
3754
  await runVisitor(visitor, file);
@@ -3882,11 +3777,6 @@ async function runGraphRules(session) {
3882
3777
  if (!session.graph) return;
3883
3778
  runStructuralGraphRules(session, session.graph);
3884
3779
  }
3885
- async function buildTypeGraphPhase(session) {
3886
- if (!session.options.types) return;
3887
- session.timings.typeGraphStatus = 0;
3888
- }
3889
- async function runTypeRules(_session) {}
3890
3780
  async function runDuplicationPhase(session) {
3891
3781
  runDuplicationRules(session);
3892
3782
  }
@@ -3982,14 +3872,13 @@ function createEmptySourceFileHandle(session) {
3982
3872
  }
3983
3873
  };
3984
3874
  }
3985
- function canRunRuleOnFile(rule, file, options) {
3875
+ function canRunRuleOnFile(rule, file) {
3986
3876
  if (rule.meta.sourceKinds && !rule.meta.sourceKinds.includes(file.sourceKind)) return false;
3987
3877
  const requires = rule.meta.requires;
3988
3878
  if (!requires) return true;
3989
3879
  if (requires.sfc && !file.sfc) return false;
3990
3880
  if (requires.template && !file.templateAst) return false;
3991
3881
  if (requires.script && !file.scriptAst) return false;
3992
- if (requires.types && !options.types) return false;
3993
3882
  return true;
3994
3883
  }
3995
3884
  //#endregion
@@ -4482,8 +4371,6 @@ async function executeDoctorRun(options) {
4482
4371
  await runPhase(session, "manifestRules", () => runManifestRules(session));
4483
4372
  await runPhase(session, "workspaceGraph", () => buildGraphPhase(session));
4484
4373
  await runPhase(session, "graphRules", () => runGraphRules(session));
4485
- await runPhase(session, "typeGraph", () => buildTypeGraphPhase(session));
4486
- await runPhase(session, "typeRules", () => /* @__PURE__ */ runTypeRules(session));
4487
4374
  await runPhase(session, "duplication", () => runDuplicationPhase(session));
4488
4375
  await runPhase(session, "health", () => runHealthPhase(session));
4489
4376
  applyPolicyFilters(session);
@@ -4506,4 +4393,4 @@ async function executeDoctorRun(options) {
4506
4393
  return result;
4507
4394
  }
4508
4395
  //#endregion
4509
- export { reportStatus as a, diagnosticForCode as c, detectProject as d, createRule as f, doctorInternalDiagnostics as h, explainRule as i, cleanCache as l, defineRulePack as m, createReport as n, codeForRuleId as o, defineDoctorExtension as p, createRulesReport as r, defineDoctorDiagnostics as s, runDoctor as t, evaluateRuleApplicability as u };
4396
+ export { reportStatus as a, detectProject as c, explainRule as i, createReport as n, cleanCache as o, createRulesReport as r, evaluateRuleApplicability as s, runDoctor as t };
@@ -0,0 +1,21 @@
1
+ import { DiagnosticHandle } from "nostics";
2
+ //#region src/core/diagnostics.d.ts
3
+ interface DoctorDiagnosticCodeEntry {
4
+ code: string;
5
+ ruleId: string;
6
+ docs?: string | false;
7
+ }
8
+ interface DoctorDiagnosticParams {
9
+ why: string;
10
+ fix: string;
11
+ sources?: string[];
12
+ cause?: unknown;
13
+ }
14
+ type DoctorDiagnosticHandle = DiagnosticHandle<DoctorDiagnosticParams, {}>;
15
+ type DoctorDiagnosticRegistry<Code extends string = string, RuleId extends string = string> = {
16
+ codesByRuleId: Record<RuleId, Code>;
17
+ diagnostics: { readonly [Key in Code]: DoctorDiagnosticHandle; };
18
+ };
19
+ declare function defineDoctorDiagnostics<const Entries extends readonly DoctorDiagnosticCodeEntry[]>(entries: Entries): DoctorDiagnosticRegistry<Entries[number]["code"], Entries[number]["ruleId"]>;
20
+ //#endregion
21
+ export { defineDoctorDiagnostics as a, DoctorDiagnosticRegistry as i, DoctorDiagnosticHandle as n, DoctorDiagnosticParams as r, DoctorDiagnosticCodeEntry as t };
@@ -0,0 +1,102 @@
1
+ import { defineDiagnostics } from "nostics";
2
+ //#region src/core/internal-diagnostic-handles.ts
3
+ const doctorInternalDiagnostics = defineDiagnostics({ codes: {
4
+ DOC0012: {
5
+ why: (params) => `Duplicate Doctor diagnostic code "${params.code}".`,
6
+ fix: (params) => `Assign a unique Diagnostic Code instead of registering "${params.code}" twice.`
7
+ },
8
+ DOC0013: {
9
+ why: (params) => params.code ? `No Doctor diagnostic handle is registered for rule "${params.ruleId}" and code "${params.code}".` : `No Doctor diagnostic code is registered for rule "${params.ruleId}".`,
10
+ fix: "Register a Diagnostic Code for the rule before it can report diagnostics."
11
+ },
12
+ DOC0014: {
13
+ why: (params) => `Rule "${params.ruleId}" reported a diagnostic without a nostics name/code.`,
14
+ fix: "Report diagnostics through a registered Doctor nostics handle."
15
+ },
16
+ DOC0015: {
17
+ why: (params) => `Rule pack "${params.pack}" must define a non-empty recommended preset.`,
18
+ fix: "Add at least one rule ID to the rule pack recommended preset."
19
+ },
20
+ DOC0016: {
21
+ why: (params) => `Invalid Config Extends entry "${params.entry}". Use "pack/preset".`,
22
+ fix: "Use a rule-pack-qualified preset such as \"vite-doctor/vue/recommended\"."
23
+ },
24
+ DOC0017: {
25
+ why: (params) => `Unknown Rule Pack "${params.pack}" in Config Extends entry "${params.entry}".`,
26
+ fix: "Use an installed Rule Pack name or remove the Config Extends entry."
27
+ },
28
+ DOC0018: {
29
+ why: (params) => `Unknown Preset "${params.preset}" for Rule Pack "${params.pack}" in Config Extends entry "${params.entry}".`,
30
+ fix: "Use a Preset exposed by the selected Rule Pack."
31
+ },
32
+ DOC0019: {
33
+ why: (params) => `Invalid severity for rule "${params.ruleId}": ${params.severity}.`,
34
+ fix: "Use \"blocker\", \"error\", \"warn\", \"info\", or \"off\"."
35
+ },
36
+ DOC0020: {
37
+ why: (params) => `Invalid config for rule "${params.ruleId}".`,
38
+ fix: "Use \"off\", a severity string, or a [severity, options] tuple."
39
+ },
40
+ DOC0021: {
41
+ why: (params) => params.code ? `Diagnostic "${params.code}" for rule "${params.ruleId}" is missing a fix.` : `Rule "${params.ruleId}" reported a diagnostic without a fix.`,
42
+ fix: "Provide actionable nostics fix text for every Doctor diagnostic."
43
+ },
44
+ DOC0022: {
45
+ why: (params) => `Doctor could not resolve the governing runtime graph: ${params.details}`,
46
+ fix: "Install project dependencies and run Doctor from the target project package. For computed Nuxt config, make future.compatibilityVersion statically provable or run pnpm nuxt doctor so the Nuxt integration can record the resolved value."
47
+ }
48
+ } });
49
+ //#endregion
50
+ //#region src/core/diagnostic-constants.ts
51
+ const DOCTOR_DIAGNOSTICS_DOCS_BASE = "https://vite-doctor.onmax.me/diagnostics";
52
+ //#endregion
53
+ //#region src/core/primitives.ts
54
+ function createRule(rule) {
55
+ return rule;
56
+ }
57
+ function defineRulePack(pack) {
58
+ if (!pack.presets?.recommended?.length) throw doctorInternalDiagnostics.DOC0015({ pack: pack.name });
59
+ return pack;
60
+ }
61
+ function defineDoctorExtension(extension) {
62
+ for (const pack of extension.rulePacks ?? []) defineRulePack(pack);
63
+ return extension;
64
+ }
65
+ //#endregion
66
+ //#region src/core/diagnostics.ts
67
+ function createDoctorDiagnosticsHost() {
68
+ const logger = {};
69
+ return {
70
+ defineDiagnostics: defineDoctorDiagnostics,
71
+ register(registry) {
72
+ for (const [code, handle] of Object.entries(registry.diagnostics)) {
73
+ if (logger[code]) throw doctorInternalDiagnostics.DOC0012({ code });
74
+ logger[code] = handle;
75
+ }
76
+ },
77
+ logger
78
+ };
79
+ }
80
+ const doctorDiagnosticsHost = createDoctorDiagnosticsHost();
81
+ function codeForRuleId(codesByRuleId, ruleId) {
82
+ return codesByRuleId[ruleId];
83
+ }
84
+ function diagnosticForCode(diagnostics, code) {
85
+ return code ? diagnostics[code] : void 0;
86
+ }
87
+ function defineDoctorDiagnostics(entries) {
88
+ const codes = Object.fromEntries(entries.map((entry) => [entry.code, {
89
+ why: (params) => params.why,
90
+ fix: (params) => params.fix,
91
+ ...entry.docs === void 0 ? {} : { docs: entry.docs }
92
+ }]));
93
+ return {
94
+ codesByRuleId: Object.fromEntries(entries.map((entry) => [entry.ruleId, entry.code])),
95
+ diagnostics: defineDiagnostics({
96
+ docsBase: (code) => `${DOCTOR_DIAGNOSTICS_DOCS_BASE}/${String(code)}`,
97
+ codes
98
+ })
99
+ };
100
+ }
101
+ //#endregion
102
+ export { createRule as a, DOCTOR_DIAGNOSTICS_DOCS_BASE as c, doctorDiagnosticsHost as i, doctorInternalDiagnostics as l, defineDoctorDiagnostics as n, defineDoctorExtension as o, diagnosticForCode as r, defineRulePack as s, codeForRuleId as t };
@@ -1,12 +1,13 @@
1
- import { p as defineDoctorExtension, t as runDoctor } from "./core-DLeqgOx5.mjs";
2
- import { t as nitroRulePack } from "./rules-Bq9PexjC.mjs";
3
- import "./nitro-aRdLgPkY.mjs";
4
- import { t as vueRulePack } from "./rules-BKTr-IUz.mjs";
5
- import { n as nuxtRulePacks, t as nuxtDoctorExtensions } from "./rules-22ICiQaK.mjs";
6
- import { t as viteRulePack } from "./rules-Cc1_NZ7P.mjs";
7
- import "./rules-BkrZ1R0E.mjs";
8
- import { t as typescriptRulePack } from "./rules-D3X57pir.mjs";
9
- import "./typescript-Br-J4sLq.mjs";
1
+ import { t as runDoctor } from "./core-CztxQ3dO.mjs";
2
+ import { o as defineDoctorExtension } from "./diagnostics-OWBdo3Uc.mjs";
3
+ import { t as nitroRulePack } from "./rules-BfmRH-w3.mjs";
4
+ import "./nitro-FnvPw8Up.mjs";
5
+ import { t as vueRulePack } from "./rules-298lNPbq.mjs";
6
+ import { t as nuxtDoctorExtensions } from "./rules-Cg6CMffp.mjs";
7
+ import { t as viteRulePack } from "./rules-D228x7hu.mjs";
8
+ import "./rules-htE_WDPD.mjs";
9
+ import { t as typescriptRulePack } from "./rules-03OSDgOR.mjs";
10
+ import "./typescript-etB5nu2i.mjs";
10
11
  import { join } from "pathe";
11
12
  import { existsSync, readFileSync } from "node:fs";
12
13
  //#region src/version.ts
@@ -22,12 +23,7 @@ function readPackageVersion() {
22
23
  //#endregion
23
24
  //#region src/doctor.ts
24
25
  async function viteDoctorRulePacks(options = {}) {
25
- const framework = detectRequestedFramework(options);
26
- const packs = [viteRulePack, typescriptRulePack];
27
- if (framework === "vue") packs.push(vueRulePack);
28
- if (framework === "nitro") packs.push(nitroRulePack);
29
- if (framework === "nuxt") packs.push(...nuxtRulePacks());
30
- return packs.map(withDistributionVersion);
26
+ return (await viteDoctorExtensions(options)).flatMap((extension) => extension.rulePacks ?? []);
31
27
  }
32
28
  async function viteDoctorExtensions(options = {}) {
33
29
  const framework = detectRequestedFramework(options);
@@ -0,0 +1,2 @@
1
+ import "./primitives-8DoGel1u.mjs";
2
+ import "./diagnostics-DYlg2f-e.mjs";
@@ -0,0 +1,4 @@
1
+ import { _ as createRule, a as DoctorRule, c as ProjectInventoryContributor, d as RulePack, f as RuleVisitor, g as SourceRange, h as SourceFileHandle, l as RuleContext, n as DoctorExtensionApi, p as RuntimeEvidenceContributor, t as DoctorExtension, u as RuleMeta, v as defineDoctorExtension, y as defineRulePack } from "./primitives-8DoGel1u.mjs";
2
+ import { a as defineDoctorDiagnostics, i as DoctorDiagnosticRegistry, n as DoctorDiagnosticHandle, r as DoctorDiagnosticParams, t as DoctorDiagnosticCodeEntry } from "./diagnostics-DYlg2f-e.mjs";
3
+ import "./extension-DyFj4vXT.mjs";
4
+ export { type DoctorDiagnosticCodeEntry, type DoctorDiagnosticHandle, type DoctorDiagnosticParams, type DoctorDiagnosticRegistry, type DoctorExtension, type DoctorExtensionApi, type DoctorRule, type ProjectInventoryContributor, type RuleContext, type RuleMeta, type RulePack, type RuleVisitor, type RuntimeEvidenceContributor, type SourceFileHandle, type SourceRange, createRule, defineDoctorDiagnostics, defineDoctorExtension, defineRulePack };
@@ -0,0 +1,2 @@
1
+ import { a as createRule, n as defineDoctorDiagnostics, o as defineDoctorExtension, s as defineRulePack } from "./diagnostics-OWBdo3Uc.mjs";
2
+ export { createRule, defineDoctorDiagnostics, defineDoctorExtension, defineRulePack };
@@ -1,4 +1,4 @@
1
- import { i as DoctorRule, s as RulePack } from "./primitives-3i5qmm5e.mjs";
1
+ import { a as DoctorRule, d as RulePack } from "./primitives-8DoGel1u.mjs";
2
2
  //#region src/rule-packs/vite/rules/define.d.ts
3
3
  declare const noUnusedDefine: DoctorRule;
4
4
  declare const noUntypedDefine: DoctorRule;
@@ -1,4 +1,4 @@
1
- import { i as DoctorRule, s as RulePack } from "./primitives-3i5qmm5e.mjs";
1
+ import { a as DoctorRule, d as RulePack } from "./primitives-8DoGel1u.mjs";
2
2
  //#region src/rule-packs/typescript/rules/no-caller-chosen-result-type.d.ts
3
3
  declare const noCallerChosenResultType: DoctorRule;
4
4
  //#endregion
@@ -1,4 +1,5 @@
1
- import { i as DoctorRule, s as RulePack } from "./primitives-3i5qmm5e.mjs";
1
+ import { a as DoctorRule, d as RulePack } from "./primitives-8DoGel1u.mjs";
2
+ import "./extension-DyFj4vXT.mjs";
2
3
  //#region src/rule-packs/nitro/rules/no-use-nuxt-app-in-nitro.d.ts
3
4
  declare const noUseNuxtAppInNitro: DoctorRule;
4
5
  //#endregion
@@ -0,0 +1,3 @@
1
+ import "./primitives-8DoGel1u.mjs";
2
+ import "./config-DWmchdeh.mjs";
3
+ import "./diagnostics-DYlg2f-e.mjs";
@@ -0,0 +1 @@
1
+ import "./index-DLp2anMW.mjs";
package/dist/index.d.mts CHANGED
@@ -1,3 +1,3 @@
1
- import { i as defineDoctorConfig, n as DoctorRunOptions, t as DoctorConfig } from "./config-BF-tCiTu.mjs";
2
- import { n as doctor, t as ViteDoctorSurfaceOptions } from "./plugin-BKNEtcVs.mjs";
1
+ import { i as defineDoctorConfig, n as DoctorRunOptions, t as DoctorConfig } from "./config-DWmchdeh.mjs";
2
+ import { n as doctor, t as ViteDoctorSurfaceOptions } from "./plugin-B97s20vt.mjs";
3
3
  export { type DoctorConfig, type DoctorRunOptions, type ViteDoctorSurfaceOptions, defineDoctorConfig, doctor };
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import { t as defineDoctorConfig } from "./config-BX26IYzh.mjs";
2
- import { t as doctor } from "./plugin-BCCA3oXP.mjs";
1
+ import { t as defineDoctorConfig } from "./config-CaJ0DqB3.mjs";
2
+ import { t as doctor } from "./plugin-DXJRUrg6.mjs";
3
3
  export { defineDoctorConfig, doctor };
@@ -1,12 +1,9 @@
1
- import { o as NuxtDoctorManifest, s as RulePack, t as DoctorExtension } from "./primitives-3i5qmm5e.mjs";
2
- import { t as DoctorConfig } from "./config-BF-tCiTu.mjs";
3
- import "./index-B6nzQEFO.mjs";
1
+ import { d as RulePack, s as NuxtDoctorManifest, t as DoctorExtension } from "./primitives-8DoGel1u.mjs";
2
+ import { t as DoctorConfig } from "./config-DWmchdeh.mjs";
3
+ import "./index-Dx-JzQ3s.mjs";
4
+ import { NuxtModule } from "nuxt/schema";
4
5
  //#region src/rule-packs/nuxt/module.d.ts
5
- interface NuxtDoctorModuleOptions {
6
- config?: DoctorConfig;
7
- extends?: "auto" | string[];
8
- extensions?: DoctorExtension[];
9
- }
6
+ type NuxtDoctorModuleOptions = DoctorConfig;
10
7
  type EvidenceBuildManifest = {
11
8
  hasBuildManifest: boolean;
12
9
  chunks: Array<{
@@ -31,7 +28,7 @@ type NuxtDoctorEvidence = {
31
28
  importDirs?: unknown[];
32
29
  autoImportContext?: NuxtAutoImportContext;
33
30
  };
34
- declare function nuxtDoctorModule(options: NuxtDoctorModuleOptions | undefined, nuxt: any): Promise<void>;
31
+ declare const nuxtDoctorModule: NuxtModule<NuxtDoctorModuleOptions>;
35
32
  declare function collectNuxtDoctorRulePacks(nuxt: any): Promise<RulePack[]>;
36
33
  declare function collectNuxtDoctorExtensions(nuxt: any): Promise<DoctorExtension[]>;
37
34
  declare function writeManifest(nuxt: any, evidence?: NuxtDoctorEvidence): Promise<NuxtDoctorManifest>;