vite-doctor 0.0.9 → 0.0.11

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 (70) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +10 -0
  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-5H46uz1F.mjs} +93 -152
  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-B958tLHH.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-B7XDlLUv.d.mts} +5 -2
  16. package/dist/{index-Dw9aENZG.d.mts → index-BfWPREhz.d.mts} +14 -2
  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-2_e5b-LZ.d.mts → module-Cm_Da1lK.d.mts} +3 -3
  23. package/dist/{module-DVHJKJkW.mjs → module-DFUEExm6.mjs} +0 -1
  24. package/dist/nitro-EqEXN3xl.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-CHGOylSB.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 +2 -2
  43. package/dist/rule-packs/typescript/index.mjs +3 -3
  44. package/dist/rule-packs/typescript/rules/index.d.mts +2 -2
  45. package/dist/rule-packs/typescript/rules/index.mjs +2 -2
  46. package/dist/rule-packs/vite/index.d.mts +2 -2
  47. package/dist/rule-packs/vite/index.mjs +2 -2
  48. package/dist/rule-packs/vite/rules/index.d.mts +2 -2
  49. package/dist/rule-packs/vite/rules/index.mjs +2 -2
  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-Cc1_NZ7P.mjs → rules-3_HzDOVa.mjs} +56 -4
  55. package/dist/rules-BGNn6i06.mjs +1388 -0
  56. package/dist/{rules-22ICiQaK.mjs → rules-BVgdxeWW.mjs} +5 -4
  57. package/dist/{rules-htM7saRv.d.mts → rules-BhptD0Ul.d.mts} +2 -1
  58. package/dist/{rules-BKTr-IUz.mjs → rules-C84ec1qL.mjs} +2 -1
  59. package/dist/{rules-Bq9PexjC.mjs → rules-Cljb26cQ.mjs} +2 -1
  60. package/dist/rules-D6_7S4VU.mjs +2 -0
  61. package/dist/rules.d.mts +2 -2
  62. package/dist/rules.mjs +3 -3
  63. package/dist/typescript-CkZ5kHgI.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/rules-D3X57pir.mjs +0 -634
  70. 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
@@ -153,6 +153,16 @@ export default defineNuxtConfig({
153
153
  });
154
154
  ```
155
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
+
156
166
  ## Development
157
167
 
158
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, i as explainRule, l as detectProject, n as createReport, o as cleanCache, r as createRulesReport, s as evaluateRuleApplicability } from "./core-5H46uz1F.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-B958tLHH.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";
@@ -15,10 +16,11 @@ import pc from "picocolors";
15
16
  //#region src/core/internal/script.ts
16
17
  function parseScript(file, source, lang = langFromFile(file)) {
17
18
  try {
18
- return parseSync(file, source, {
19
+ const result = parseSync(file, source, {
19
20
  sourceType: "module",
20
21
  lang
21
- }).program;
22
+ });
23
+ return Object.assign(result.program, { comments: result.comments });
22
24
  } catch {
23
25
  return null;
24
26
  }
@@ -123,70 +125,6 @@ function sha256$1(input) {
123
125
  return createHash("sha256").update(input).digest("hex");
124
126
  }
125
127
  //#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
128
  //#region src/core/internal/nuxt-inventory.ts
191
129
  function createNuxtProjectInventory(root, manifest, manifestPath, fallbackImportsDirs = []) {
192
130
  return {
@@ -802,7 +740,9 @@ async function collectGitChangeInventory(root, since, includePath = () => true)
802
740
  });
803
741
  }
804
742
  for (const path of untracked.paths.filter(includePath)) {
805
- const lineCount = currentLineCount(resolve(root, path));
743
+ const absolute = resolve(root, path);
744
+ if (!statSync(absolute, { throwIfNoEntry: false })?.isFile()) continue;
745
+ const lineCount = currentLineCount(absolute);
806
746
  changes.push({
807
747
  kind: "untracked",
808
748
  path,
@@ -898,8 +838,10 @@ async function collectFileHunks(root, base, path, previousPath, ref) {
898
838
  const result = await runGit(root, [
899
839
  "diff",
900
840
  "--unified=0",
841
+ "--inter-hunk-context=0",
901
842
  "--no-color",
902
843
  "--no-ext-diff",
844
+ "--no-textconv",
903
845
  base,
904
846
  "--",
905
847
  ...previousPath ? [previousPath] : [],
@@ -1705,7 +1647,7 @@ async function createScanSession(options) {
1705
1647
  const registry = await collectRulePacks([...config.extensions ?? [], ...options.extensions ?? []]);
1706
1648
  await applyProjectContributions(project, registry);
1707
1649
  const ruleConfigs = resolveRuleConfigs(config);
1708
- const enabledRules = selectRules(registry, ruleConfigs, options, project);
1650
+ const enabledRules = selectRules(registry, ruleConfigs, options, config, project);
1709
1651
  markSession(sessionBase, "project", started);
1710
1652
  started = performance.now();
1711
1653
  const sourceInventory = await selectSourceInventory(root, config, options, project);
@@ -1775,15 +1717,12 @@ async function collectRulePacks(extensions) {
1775
1717
  registerRulePack(pack) {
1776
1718
  registeredPacks.push(pack);
1777
1719
  },
1778
- registerReporter() {},
1779
- registerProjectDetector() {},
1780
1720
  registerProjectInventoryContributor(contributor) {
1781
1721
  inventoryContributors.push(contributor);
1782
1722
  },
1783
1723
  registerRuntimeEvidenceContributor(contributor) {
1784
1724
  runtimeEvidenceContributors.push(contributor);
1785
- },
1786
- registerNuxtManifestContributor() {}
1725
+ }
1787
1726
  });
1788
1727
  const packs = [...extensions.flatMap((extension) => extension.rulePacks ?? []), ...registeredPacks].map((pack) => defineRulePack(pack));
1789
1728
  return {
@@ -1809,16 +1748,15 @@ async function applyProjectContributions(project, registry) {
1809
1748
  };
1810
1749
  }
1811
1750
  }
1812
- function selectRules(registry, ruleConfigs, options, project) {
1751
+ function selectRules(registry, ruleConfigs, options, config, project) {
1813
1752
  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) => ({
1753
+ const selectedRules = resolveExtends(registry.packs, options.extends ?? config.extends, project);
1754
+ 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
1755
  rule,
1817
1756
  applicability: evaluateRuleApplicability(rule, project)
1818
1757
  })).filter((item) => item.applicability.state === "active").map((item) => item.rule);
1819
1758
  }
1820
- function resolveExtends(packs, options, project) {
1821
- const requested = options.extends ?? options.config?.extends ?? "auto";
1759
+ function resolveExtends(packs, requested = "auto", project) {
1822
1760
  if (requested === "auto") return new Set(packs.filter((pack) => evaluatePackActivation(pack, project).state === "active").flatMap((pack) => pack.presets.recommended));
1823
1761
  const selected = /* @__PURE__ */ new Set();
1824
1762
  for (const entry of requested) {
@@ -1904,6 +1842,7 @@ function safeCacheKey(key) {
1904
1842
  }
1905
1843
  //#endregion
1906
1844
  //#region src/core/internal/facts.ts
1845
+ const FILE_FACTS_VERSION = 2;
1907
1846
  async function parseSourceFiles(session) {
1908
1847
  const started = performance.now();
1909
1848
  let fileId = 0;
@@ -1918,7 +1857,7 @@ async function parseSourceFile(session, file, fileId) {
1918
1857
  const absolute = file.path;
1919
1858
  const text = readFileSync(absolute, "utf8");
1920
1859
  const hash = sha256(text);
1921
- const cacheKey = createCacheKey(session, "fileFacts", `${absolute}:${hash}`);
1860
+ const cacheKey = createCacheKey(session, "fileFacts", `${FILE_FACTS_VERSION}:${absolute}:${hash}`);
1922
1861
  const cachedFacts = session.cache.get(cacheKey);
1923
1862
  const isVueSfc = absolute.endsWith(".vue");
1924
1863
  const sfc = isVueSfc ? await parseOptionalSfc(absolute, text, hash) : void 0;
@@ -2002,6 +1941,10 @@ function createFileFacts(session, file, fileId, text, hash, scriptAst, templateA
2002
1941
  source: String(node.source?.value ?? ""),
2003
1942
  range: nodeRange(session, file.path, text, node)
2004
1943
  });
1944
+ else if (node.type === "ImportExpression") dynamicImports.push({
1945
+ source: typeof node.source?.value === "string" ? node.source.value : null,
1946
+ range: nodeRange(session, file.path, text, node)
1947
+ });
2005
1948
  else if (node.type === "CallExpression") {
2006
1949
  const name = session.helpers.getCalleeName(node);
2007
1950
  if (name) {
@@ -2138,11 +2081,11 @@ function createTokenFacts(text) {
2138
2081
  //#region src/core/internal/rule-runner.ts
2139
2082
  async function runVisitor(visitor, file) {
2140
2083
  if (file.sfc) await visitor.SFC?.(file.sfc);
2141
- if (file.scriptAst) walkScript(file.scriptAst, (node) => {
2084
+ if (file.scriptAst && (visitor.ScriptNode || visitor.ImportDeclaration)) walkScript(file.scriptAst, (node) => {
2142
2085
  visitor.ScriptNode?.(node);
2143
2086
  if (node.type === "ImportDeclaration") visitor.ImportDeclaration?.(node);
2144
2087
  });
2145
- if (file.templateAst) walkTemplate(file.templateAst, (node) => visitor.TemplateNode?.(node));
2088
+ if (file.templateAst && visitor.TemplateNode) walkTemplate(file.templateAst, (node) => visitor.TemplateNode?.(node));
2146
2089
  }
2147
2090
  function walkScript(node, visit, parent) {
2148
2091
  if (!node || typeof node !== "object") return;
@@ -2180,10 +2123,11 @@ function walkTemplate(node, visit) {
2180
2123
  //#region src/core/internal/diagnostic-policy.ts
2181
2124
  function applyDiagnosticPolicy(input) {
2182
2125
  const suppressed = [];
2126
+ const sourceLines = /* @__PURE__ */ new Map();
2183
2127
  const baseline = readBaseline(input.root, input.options.baseline);
2184
2128
  const nextDiagnostics = [];
2185
2129
  for (const diagnostic of input.diagnostics) {
2186
- const suppression = findSuppression(input.root, input.config, diagnostic);
2130
+ const suppression = findSuppression(input.root, input.config, diagnostic, sourceLines);
2187
2131
  const inBaseline = baseline.has(diagnostic.fingerprint ?? "");
2188
2132
  if (suppression || input.options.newOnly && inBaseline) {
2189
2133
  suppressed.push({
@@ -2234,7 +2178,7 @@ function writeBaseline(root, baseline, diagnostics) {
2234
2178
  })).sort((a, b) => `${a.ruleId}:${a.file}:${a.fingerprint}`.localeCompare(`${b.ruleId}:${b.file}:${b.fingerprint}`))
2235
2179
  }, null, 2)}\n`);
2236
2180
  }
2237
- function findSuppression(root, config, diagnostic) {
2181
+ function findSuppression(root, config, diagnostic, sourceLines) {
2238
2182
  const configured = config.suppressions?.find((suppression) => {
2239
2183
  if (suppression.ruleId && suppression.ruleId !== diagnostic.ruleId) return false;
2240
2184
  if (suppression.fingerprint && suppression.fingerprint !== diagnostic.fingerprint) return false;
@@ -2242,14 +2186,26 @@ function findSuppression(root, config, diagnostic) {
2242
2186
  return true;
2243
2187
  });
2244
2188
  if (configured) return configured.reason;
2245
- const text = readFileSync(diagnostic.file, "utf8");
2189
+ let lines = sourceLines.get(diagnostic.file);
2190
+ if (!lines) {
2191
+ try {
2192
+ lines = readFileSync(diagnostic.file, "utf8").split(/\r?\n/);
2193
+ } catch {
2194
+ lines = [];
2195
+ }
2196
+ sourceLines.set(diagnostic.file, lines);
2197
+ }
2246
2198
  const line = diagnostic.range?.line;
2247
- const lines = text.split(/\r?\n/);
2248
- const inline = (line ? lines.slice(Math.max(0, line - 3), line + 1).join("\n") : text).match(/doctor-disable(?:-next-line)?\s+([^\s]+)(?:\s+--\s+(.+)|\s+(.+))?/);
2249
- if (!inline) return null;
2250
- const rules = inline[1].split(",").map((item) => item.trim());
2251
- if (!rules.includes(diagnostic.ruleId) && !rules.includes("*")) return null;
2252
- return (inline[2] ?? inline[3] ?? "").trim() || "missing suppression reason";
2199
+ const start = line ? Math.max(0, line - 3) : 0;
2200
+ const end = line ? Math.min(lines.length, line + 1) : lines.length;
2201
+ for (let index = start; index < end; index++) {
2202
+ const inline = lines[index].match(/doctor-disable(-next-line)?\s+([^\s]+)(?:\s+--\s+(.+)|\s+(.+))?/);
2203
+ if (!inline || inline[1] && line !== index + 2) continue;
2204
+ const rules = inline[2].split(",").map((item) => item.trim());
2205
+ if (!rules.includes(diagnostic.ruleId) && !rules.includes("*")) continue;
2206
+ return (inline[3] ?? inline[4] ?? "").trim() || "missing suppression reason";
2207
+ }
2208
+ return null;
2253
2209
  }
2254
2210
  function nativeMatch(value, pattern) {
2255
2211
  if (pattern === value) return true;
@@ -2300,42 +2256,6 @@ function diagnosticPenalty(summary, weights) {
2300
2256
  return Math.min(100, blockerPenalty + errorPenalty + warnPenalty + infoPenalty);
2301
2257
  }
2302
2258
  //#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
2259
  //#region src/core/diagnostic-code-map.ts
2340
2260
  const allDoctorDiagnosticRegistry = defineDoctorDiagnostics([
2341
2261
  {
@@ -2624,6 +2544,10 @@ const allDoctorDiagnosticRegistry = defineDoctorDiagnostics([
2624
2544
  code: "VITE0021",
2625
2545
  ruleId: "vite/worker/require-worker-url-pattern"
2626
2546
  },
2547
+ {
2548
+ code: "VITE0022",
2549
+ ruleId: "vite/imports/require-static-glob-pattern"
2550
+ },
2627
2551
  {
2628
2552
  code: "TS0001",
2629
2553
  ruleId: "typescript/evidence/no-chained-type-assertions"
@@ -2656,6 +2580,10 @@ const allDoctorDiagnosticRegistry = defineDoctorDiagnostics([
2656
2580
  code: "TS0008",
2657
2581
  ruleId: "typescript/strict/require-safety-comment-for-type-assertion"
2658
2582
  },
2583
+ {
2584
+ code: "TS0012",
2585
+ ruleId: "typescript/performance/no-array-filter-map"
2586
+ },
2659
2587
  {
2660
2588
  code: "NITRO0001",
2661
2589
  ruleId: "nitro/context/no-navigateto-in-nitro"
@@ -3136,7 +3064,7 @@ function createResult(project, root, diagnostics, suppressedDiagnostics, config,
3136
3064
  function createDiagnosticFingerprint(root, diagnostic, file) {
3137
3065
  const rel = relative(root, diagnostic.file);
3138
3066
  const anchor = nearestAnchor(file.text, diagnostic.range?.start ?? 0);
3139
- const message = diagnostic.why.replace(/\s+/g, " ").replace(/['"`][^'"`]+['"`]/g, "\"\"");
3067
+ const message = diagnostic.why.replace(/\s+/g, " ");
3140
3068
  return sha256(`${diagnostic.ruleId}:${rel}:${anchor}:${message}`);
3141
3069
  }
3142
3070
  function normalizeDiagnostic(input) {
@@ -3241,7 +3169,6 @@ function reportRuntimeInventoryUnknown(session) {
3241
3169
  }
3242
3170
  function defaultConfidenceForPhase(phase) {
3243
3171
  if (phase === "graph") return "proven";
3244
- if (phase === "type") return "type-backed";
3245
3172
  if (phase === "manifest") return "manifest-backed";
3246
3173
  if (phase === "duplication" || phase === "health") return "heuristic-high";
3247
3174
  return "heuristic-medium";
@@ -3250,7 +3177,6 @@ function evidenceKindForPhase(phase) {
3250
3177
  if (phase === "file") return "ast";
3251
3178
  if (phase === "manifest") return "manifest";
3252
3179
  if (phase === "graph" || phase === "workspace") return "graph";
3253
- if (phase === "type") return "types";
3254
3180
  if (phase === "duplication" || phase === "health") return "facts";
3255
3181
  return "facts";
3256
3182
  }
@@ -3303,11 +3229,6 @@ function buildWorkspaceGraph(session) {
3303
3229
  specifier: item.source,
3304
3230
  kind: item.kind === "type" ? "type-import" : "import"
3305
3231
  });
3306
- if (target !== void 0) {
3307
- const importers = importersByFile.get(target) ?? [];
3308
- importers.push(fact.fileId);
3309
- importersByFile.set(target, importers);
3310
- }
3311
3232
  for (const specifier of item.specifiers) {
3312
3233
  const refs = refsByExport.get(specifier) ?? [];
3313
3234
  refs.push({
@@ -3317,6 +3238,15 @@ function buildWorkspaceGraph(session) {
3317
3238
  refsByExport.set(specifier, refs);
3318
3239
  }
3319
3240
  }
3241
+ for (const item of fact.dynamicImports) {
3242
+ if (item.source === null) continue;
3243
+ importEdges.push({
3244
+ from: fact.fileId,
3245
+ to: resolveImportTarget(session, fact, item.source, byRelativePath),
3246
+ specifier: item.source,
3247
+ kind: "dynamic-import"
3248
+ });
3249
+ }
3320
3250
  for (const item of fact.calls) {
3321
3251
  const refs = refsByExport.get(item.name) ?? [];
3322
3252
  refs.push({
@@ -3326,6 +3256,12 @@ function buildWorkspaceGraph(session) {
3326
3256
  refsByExport.set(item.name, refs);
3327
3257
  }
3328
3258
  }
3259
+ for (const edge of [...importEdges, ...exportEdges]) {
3260
+ if (edge.to === void 0) continue;
3261
+ const importers = importersByFile.get(edge.to) ?? [];
3262
+ importers.push(edge.from);
3263
+ importersByFile.set(edge.to, importers);
3264
+ }
3329
3265
  const virtualRoots = createVirtualRoots(session, fileIdsByPath);
3330
3266
  for (const root of virtualRoots) {
3331
3267
  if (root.fileId === void 0) continue;
@@ -3347,7 +3283,7 @@ function buildWorkspaceGraph(session) {
3347
3283
  refsByExport,
3348
3284
  exportsByName
3349
3285
  },
3350
- sccs: computeSccs(session.facts.map((fact) => fact.fileId), importEdges)
3286
+ sccs: computeSccs(session.facts.map((fact) => fact.fileId), [...importEdges.filter((edge) => edge.kind !== "dynamic-import"), ...exportEdges])
3351
3287
  };
3352
3288
  }
3353
3289
  function createVirtualRoots(session, fileIdsByPath) {
@@ -3471,9 +3407,15 @@ function runDeadCodeRules(session, graph) {
3471
3407
  const live = reachableFiles(graph);
3472
3408
  const packageDeps = readPackageDeps(session.root);
3473
3409
  const importedPackages = /* @__PURE__ */ new Set();
3474
- for (const fact of session.facts) for (const item of fact.imports) {
3410
+ const byRelativePath = new Map(session.facts.map((fact) => [fact.relativePath, fact.fileId]));
3411
+ for (const fact of session.facts) for (const item of [
3412
+ ...fact.imports,
3413
+ ...fact.exports,
3414
+ ...fact.dynamicImports
3415
+ ]) {
3416
+ if (!item.source) continue;
3475
3417
  if (!item.source.startsWith(".") && !item.source.startsWith("~/") && !item.source.startsWith("@/") && !item.source.startsWith("~~/")) importedPackages.add(packageNameFromSpecifier(item.source));
3476
- if (isLocalSpecifier(item.source) && !isGeneratedOrAssetImport(item.source) && !isLikelyForeignFrameworkFile(session, fact.relativePath, packageDeps) && resolveImportTarget(session, fact, item.source, new Map(session.facts.map((f) => [f.relativePath, f.fileId]))) === void 0) pushDiagnostic(session, {
3418
+ if (isLocalSpecifier(item.source) && !isGeneratedOrAssetImport(item.source) && !isLikelyForeignFrameworkFile(session, fact.relativePath, packageDeps) && resolveImportTarget(session, fact, item.source, byRelativePath) === void 0) pushDiagnostic(session, {
3477
3419
  ruleId: "workspace/dead-code/unresolved-import",
3478
3420
  severity: "error",
3479
3421
  category: "dead-code",
@@ -3667,13 +3609,20 @@ function selectedAnalyses(session) {
3667
3609
  }
3668
3610
  function reachableFiles(graph) {
3669
3611
  const live = /* @__PURE__ */ new Set();
3612
+ const targetsByFile = /* @__PURE__ */ new Map();
3613
+ for (const edge of [...graph.importEdges, ...graph.exportEdges]) {
3614
+ if (edge.to === void 0) continue;
3615
+ const targets = targetsByFile.get(edge.from) ?? [];
3616
+ targets.push(edge.to);
3617
+ targetsByFile.set(edge.from, targets);
3618
+ }
3670
3619
  const queue = graph.virtualRoots.flatMap((root) => root.fileId === void 0 ? [] : [root.fileId]);
3671
3620
  for (const fact of graph.files.values()) if (fact.exports.some((item) => graph.reverseIndex.refsByExport.has(item.name))) queue.push(fact.fileId);
3672
- while (queue.length) {
3673
- const id = queue.shift();
3621
+ for (let index = 0; index < queue.length; index++) {
3622
+ const id = queue[index];
3674
3623
  if (live.has(id)) continue;
3675
3624
  live.add(id);
3676
- for (const edge of graph.importEdges) if (edge.from === id && edge.to !== void 0 && !live.has(edge.to)) queue.push(edge.to);
3625
+ for (const target of targetsByFile.get(id) ?? []) if (!live.has(target)) queue.push(target);
3677
3626
  }
3678
3627
  return live;
3679
3628
  }
@@ -3853,7 +3802,7 @@ async function runFileRules(session) {
3853
3802
  for (const rule of session.enabledRules) {
3854
3803
  if ((rule.meta.execution ?? "file") !== "file") continue;
3855
3804
  for (const file of session.handles) {
3856
- if (!canRunRuleOnFile(rule, file, session.options)) continue;
3805
+ if (!canRunRuleOnFile(rule, file)) continue;
3857
3806
  const visitor = await rule.create(createRuleContext(session, file, rule));
3858
3807
  if (!visitor) continue;
3859
3808
  await runVisitor(visitor, file);
@@ -3882,11 +3831,6 @@ async function runGraphRules(session) {
3882
3831
  if (!session.graph) return;
3883
3832
  runStructuralGraphRules(session, session.graph);
3884
3833
  }
3885
- async function buildTypeGraphPhase(session) {
3886
- if (!session.options.types) return;
3887
- session.timings.typeGraphStatus = 0;
3888
- }
3889
- async function runTypeRules(_session) {}
3890
3834
  async function runDuplicationPhase(session) {
3891
3835
  runDuplicationRules(session);
3892
3836
  }
@@ -3982,14 +3926,13 @@ function createEmptySourceFileHandle(session) {
3982
3926
  }
3983
3927
  };
3984
3928
  }
3985
- function canRunRuleOnFile(rule, file, options) {
3929
+ function canRunRuleOnFile(rule, file) {
3986
3930
  if (rule.meta.sourceKinds && !rule.meta.sourceKinds.includes(file.sourceKind)) return false;
3987
3931
  const requires = rule.meta.requires;
3988
3932
  if (!requires) return true;
3989
3933
  if (requires.sfc && !file.sfc) return false;
3990
3934
  if (requires.template && !file.templateAst) return false;
3991
3935
  if (requires.script && !file.scriptAst) return false;
3992
- if (requires.types && !options.types) return false;
3993
3936
  return true;
3994
3937
  }
3995
3938
  //#endregion
@@ -4482,8 +4425,6 @@ async function executeDoctorRun(options) {
4482
4425
  await runPhase(session, "manifestRules", () => runManifestRules(session));
4483
4426
  await runPhase(session, "workspaceGraph", () => buildGraphPhase(session));
4484
4427
  await runPhase(session, "graphRules", () => runGraphRules(session));
4485
- await runPhase(session, "typeGraph", () => buildTypeGraphPhase(session));
4486
- await runPhase(session, "typeRules", () => /* @__PURE__ */ runTypeRules(session));
4487
4428
  await runPhase(session, "duplication", () => runDuplicationPhase(session));
4488
4429
  await runPhase(session, "health", () => runHealthPhase(session));
4489
4430
  applyPolicyFilters(session);
@@ -4506,4 +4447,4 @@ async function executeDoctorRun(options) {
4506
4447
  return result;
4507
4448
  }
4508
4449
  //#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 };
4450
+ export { reportStatus as a, getNodeVisitorKeys as c, explainRule as i, detectProject as l, 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 };