@remylagerweij/vue-doctor 2.1.0 → 2.1.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.
- package/README.md +3 -3
- package/dist/{baseline-zPvaJyGF.js → baseline-S73VL2i1.js} +1 -1
- package/dist/{baseline-BgcqUbRB.js → baseline-ekG8ZnQz.js} +1 -1
- package/dist/cli.js +59 -50
- package/dist/diagnose-20sE9_pC.js +2 -0
- package/dist/{diagnose-B3lL2Qo2.js → diagnose-aMh5eWWF.js} +69 -10
- package/dist/{discover-project-Cj2k7pUX.js → discover-project-Bfc9urYw.js} +1 -1
- package/dist/{discover-project-B1uzc9aU.js → discover-project-DdngEZRq.js} +2 -2
- package/dist/index.d.ts +6 -0
- package/dist/index.js +3 -3
- package/dist/{rule-ids-BrYqJT7o.js → rule-ids-BloekNcu.js} +151 -174
- package/dist/{rule-options-DKLnjGap.js → rule-options-DuZJJ_Sn.js} +150 -173
- package/dist/{rule-options-dyUSlzk0.js → rule-options-DxpXX5-D.js} +1 -1
- package/dist/{rules-CkC009c7.js → rules-D5a-iMzD.js} +3 -3
- package/dist/runner-DfuzuZYa.js +595 -0
- package/dist/{server-KeUQYFzs.js → server--meyU6b-.js} +5 -5
- package/dist/{validate-rule-options-CntwdX24.js → validate-rule-options-Du_YeG6D.js} +1 -1
- package/dist/{validate-rule-options-0hIH4ndj.js → validate-rule-options-r01B-gA_.js} +1 -1
- package/dist/vue-doctor-plugin.js +150 -173
- package/package.json +10 -10
- package/dist/diagnose-9mGhh_uH.js +0 -2
- package/dist/list-source-files-Uf11_Lde.js +0 -65
- package/dist/runner-DqcMoZQY.js +0 -178
- package/dist/{model-FBOYc7PC.js → model-eTvTct_Z.js} +1 -1
package/README.md
CHANGED
|
@@ -68,7 +68,7 @@ Then add a script to your `package.json`:
|
|
|
68
68
|
- 🛡️ **Comprehensive Quality Gates:** 85 custom rules (85 on by default) + 19 eslint-plugin-vue rules = 104 registered rules.
|
|
69
69
|
- 🔒 **Deep Security Guardrails:** Detects hardcoded secrets, unsafe HTML sinks (`v-html`), SSRF, command & SQL injection, prototype pollution, and LLM prompt injection risks.
|
|
70
70
|
- 🧹 **Dead Code & Unused Exports:** Finds unused components, unreferenced exports, orphan types, and dead dependencies using Knip.
|
|
71
|
-
- 🔧 **Automated Codemods:** Deterministic `--fix`
|
|
71
|
+
- 🔧 **Automated Codemods:** Deterministic `--fix` repairs the scan's findings of the two fixable rules: named lodash imports become per-method imports, and `target="_blank"` links get `rel="noopener noreferrer"`. Only reported findings are rewritten; suppressed, disabled and unreported code is never touched.
|
|
72
72
|
- 🤖 **First-Class AI Agent Support:** Built-in stdio Model Context Protocol (MCP) server (`vue-doctor mcp`) and one-command agent playbook installer (`vue-doctor agents install`) for Cursor, Claude Code, Copilot, and Windsurf.
|
|
73
73
|
- 🚦 **GitHub Actions CI & PR Feedback:** Full pull request feedback with sticky summary comments, line-level reviews with AI remediation prompts, check annotations, and score delta tracking.
|
|
74
74
|
- 📈 **Baseline for Existing Codebases:** Adopt Vue Doctor on legacy applications instantly; record existing issues and only fail on new violations.
|
|
@@ -123,10 +123,10 @@ vue-doctor
|
|
|
123
123
|
# Scan a specific directory or workspace project
|
|
124
124
|
vue-doctor ./apps/web
|
|
125
125
|
|
|
126
|
-
#
|
|
126
|
+
# Fix the reported findings of fixable rules, then scan the fixed code
|
|
127
127
|
vue-doctor --fix
|
|
128
128
|
|
|
129
|
-
# Preview
|
|
129
|
+
# Preview the fixes without changing files (unified diff)
|
|
130
130
|
vue-doctor --fix --dry-run
|
|
131
131
|
|
|
132
132
|
# Scan only files changed in your git branch (fast pre-commit / PR mode)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export { i as createBaseline, o as writeBaseline } from "./baseline-
|
|
2
|
+
export { i as createBaseline, o as writeBaseline } from "./baseline-ekG8ZnQz.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { r as ruleIdOf } from "./rule-ids-BrYqJT7o.js";
|
|
3
2
|
import fs from "node:fs";
|
|
3
|
+
import { r as ruleIdOf } from "./rule-ids-BloekNcu.js";
|
|
4
4
|
// src/core/baseline.ts
|
|
5
5
|
const DEFAULT_BASELINE_FILENAME = ".vue-doctor-baseline.json";
|
|
6
6
|
const BASELINE_VERSION = 1;
|
package/dist/cli.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { a as logger, c as getToolVersions, d as loadConfig, i as configureLogger, l as mapWithConcurrency, n as diagnose, o as output, r as createKnipSession, s as highlighter, t as NoVueDependencyError, u as createPrivateTempDirectory } from "./diagnose-B3lL2Qo2.js";
|
|
3
|
-
import { f as getCanonicalRuleId, m as getRuleMeta, o as PLUGIN_NAME, r as ruleIdOf, s as RULE_REGISTRY } from "./rule-ids-BrYqJT7o.js";
|
|
4
|
-
import { i as createBaseline, n as DEFAULT_BASELINE_FILENAME, o as writeBaseline } from "./baseline-BgcqUbRB.js";
|
|
5
|
-
import { n as isMonorepoRoot } from "./find-monorepo-root-VE6uVqvK.js";
|
|
6
|
-
import { a as getRootPackage, b as VERSION$1, g as MILLISECONDS_PER_SECOND, i as formatFrameworkName, n as discoverProject, r as discoverVueSubprojects, u as listWorkspacePackages } from "./discover-project-B1uzc9aU.js";
|
|
7
|
-
import { a as filterSourceFiles, c as EXIT_CODES, d as evaluateGate, l as FAIL_ON_VALUES, n as registerExplainCommand, o as getDiffInfo, r as registerRulesCommand, s as docsUrl, u as GATE_SCOPE_VALUES } from "./rules-CkC009c7.js";
|
|
8
|
-
import { n as REPORT_SCHEMA_URL, t as REPORT_FORMAT } from "./constants-Cav5tPU4.js";
|
|
9
2
|
import fs from "node:fs";
|
|
10
3
|
import path from "node:path";
|
|
11
4
|
import { Command, CommanderError, InvalidArgumentError, Option } from "commander";
|
|
12
|
-
import {
|
|
5
|
+
import { a as logger, c as getToolVersions, d as loadConfig, i as configureLogger, l as mapWithConcurrency, n as diagnose, o as output, r as createKnipSession, s as highlighter, t as NoVueDependencyError, u as createPrivateTempDirectory } from "./diagnose-aMh5eWWF.js";
|
|
6
|
+
import { i as createBaseline, n as DEFAULT_BASELINE_FILENAME, o as writeBaseline } from "./baseline-ekG8ZnQz.js";
|
|
7
|
+
import { a as filterSourceFiles, c as EXIT_CODES, d as evaluateGate, l as FAIL_ON_VALUES, n as registerExplainCommand, o as getDiffInfo, r as registerRulesCommand, s as docsUrl, u as GATE_SCOPE_VALUES } from "./rules-D5a-iMzD.js";
|
|
8
|
+
import { a as getRootPackage, b as VERSION$1, g as MILLISECONDS_PER_SECOND, i as formatFrameworkName, n as discoverProject, r as discoverVueSubprojects, u as listWorkspacePackages } from "./discover-project-DdngEZRq.js";
|
|
9
|
+
import { n as isMonorepoRoot } from "./find-monorepo-root-VE6uVqvK.js";
|
|
10
|
+
import { f as getCanonicalRuleId, m as getRuleMeta, o as PLUGIN_NAME, r as ruleIdOf, s as RULE_REGISTRY } from "./rule-ids-BloekNcu.js";
|
|
11
|
+
import { n as REPORT_SCHEMA_URL, t as REPORT_FORMAT } from "./constants-Cav5tPU4.js";
|
|
13
12
|
import { createHash } from "node:crypto";
|
|
13
|
+
import { gzipSync } from "node:zlib";
|
|
14
|
+
import { pathToFileURL } from "node:url";
|
|
14
15
|
import { availableParallelism } from "node:os";
|
|
15
|
-
import { execFile, spawnSync } from "node:child_process";
|
|
16
16
|
import pc from "picocolors";
|
|
17
|
-
import {
|
|
17
|
+
import { execFile, spawnSync } from "node:child_process";
|
|
18
18
|
import { promisify } from "node:util";
|
|
19
19
|
// src/utils/handle-error.ts
|
|
20
20
|
/** Reports an error that prevented Vue Doctor from running and exits with the usage-error code. */
|
|
@@ -1485,7 +1485,7 @@ const SARIF_FINGERPRINT_KEY = "vueDoctor/v1";
|
|
|
1485
1485
|
/** GitHub rejects runs with more results than this. */
|
|
1486
1486
|
const SARIF_MAX_RESULTS_PER_RUN = 25e3;
|
|
1487
1487
|
/** GitHub rejects gzip-compressed uploads larger than this. */
|
|
1488
|
-
const SARIF_MAX_GZIP_BYTES =
|
|
1488
|
+
const SARIF_MAX_GZIP_BYTES = 0xa00000;
|
|
1489
1489
|
/**
|
|
1490
1490
|
* `security-severity` (CVSS-like 0-10 string; GitHub: >=9 critical, 7-8.9 high, 4-6.9 medium, <4 low)
|
|
1491
1491
|
* derived from the rule's default severity and its confidence.
|
|
@@ -1666,7 +1666,7 @@ const withSourceRootPrefix = (report, prefix) => {
|
|
|
1666
1666
|
const formatSarif = (inputReport, options = {}) => {
|
|
1667
1667
|
const report = withSourceRootPrefix(inputReport, options.sourceRootPrefix ?? "");
|
|
1668
1668
|
const warn = options.warn ?? (() => {});
|
|
1669
|
-
const maxGzipBytes = options.maxGzipBytes ??
|
|
1669
|
+
const maxGzipBytes = options.maxGzipBytes ?? 0xa00000;
|
|
1670
1670
|
let limit = Math.min(options.maxResultsPerRun ?? 25e3, SARIF_MAX_RESULTS_PER_RUN);
|
|
1671
1671
|
let text = `${JSON.stringify(buildSarif(report, limit, warn), null, 2)}\n`;
|
|
1672
1672
|
while (gzipSync(text).length > maxGzipBytes && limit > 1) {
|
|
@@ -1866,8 +1866,8 @@ const createBatchProgressReporter = async (options) => {
|
|
|
1866
1866
|
// src/scan.ts
|
|
1867
1867
|
const printProjectDetection = (projectInfo, isDiffMode, includePaths) => {
|
|
1868
1868
|
const lines = [];
|
|
1869
|
-
const title = `${pc.bold(pc.green("Vue Doctor"))} ${pc.dim("v2.1.
|
|
1870
|
-
lines.push(createFramedLine(`Vue Doctor v2.1.
|
|
1869
|
+
const title = `${pc.bold(pc.green("Vue Doctor"))} ${pc.dim("v2.1.2")}`;
|
|
1870
|
+
lines.push(createFramedLine(`Vue Doctor v2.1.2`, title));
|
|
1871
1871
|
const vueVersionDisplay = projectInfo.vueVersion ? `Vue ${projectInfo.vueVersion}` : "Vue";
|
|
1872
1872
|
const frameworkDisplay = formatFrameworkName(projectInfo.framework);
|
|
1873
1873
|
const projectLine = `${projectInfo.projectName} · ${frameworkDisplay} · ${vueVersionDisplay}`;
|
|
@@ -2813,7 +2813,7 @@ const registerCiCommand = (program) => {
|
|
|
2813
2813
|
const reportPath = path.resolve(options.reportJson ?? "vue-doctor.json");
|
|
2814
2814
|
if (!fs.existsSync(reportPath)) throw new Error(`Report file not found: ${reportPath}`);
|
|
2815
2815
|
const raw = JSON.parse(fs.readFileSync(reportPath, "utf8"));
|
|
2816
|
-
const { reportSchema } = await import("./model-
|
|
2816
|
+
const { reportSchema } = await import("./model-eTvTct_Z.js");
|
|
2817
2817
|
const report = reportSchema.parse(raw);
|
|
2818
2818
|
const token = options.githubToken ?? process.env.GITHUB_TOKEN;
|
|
2819
2819
|
const repoFullName = process.env.GITHUB_REPOSITORY;
|
|
@@ -3125,7 +3125,7 @@ const registerInitCommand = (program) => {
|
|
|
3125
3125
|
const projectDir = path.resolve(directoryArg);
|
|
3126
3126
|
const isInteractive = Boolean(process.stdin.isTTY) && !options.yes;
|
|
3127
3127
|
const clack = isInteractive ? await import("@clack/prompts") : null;
|
|
3128
|
-
const { discoverProject, formatFrameworkName } = await import("./discover-project-
|
|
3128
|
+
const { discoverProject, formatFrameworkName } = await import("./discover-project-Bfc9urYw.js");
|
|
3129
3129
|
const { isMonorepoRoot } = await import("./find-monorepo-root-Cqb6bdkf.js");
|
|
3130
3130
|
const projectInfo = discoverProject(projectDir);
|
|
3131
3131
|
if (isInteractive && clack) {
|
|
@@ -3312,8 +3312,8 @@ const registerInitCommand = (program) => {
|
|
|
3312
3312
|
if (spinner) spinner.start("Scanning project to record baseline snapshot...");
|
|
3313
3313
|
else logger.log("Scanning project to record baseline snapshot...");
|
|
3314
3314
|
try {
|
|
3315
|
-
const { diagnose } = await import("./diagnose-
|
|
3316
|
-
const { createBaseline, writeBaseline } = await import("./baseline-
|
|
3315
|
+
const { diagnose } = await import("./diagnose-20sE9_pC.js");
|
|
3316
|
+
const { createBaseline, writeBaseline } = await import("./baseline-S73VL2i1.js");
|
|
3317
3317
|
const baselineData = createBaseline((await diagnose(projectDir, { baseline: null })).diagnostics);
|
|
3318
3318
|
writeBaseline(path.join(projectDir, baselineFileName), baselineData);
|
|
3319
3319
|
const countMsg = `${baselineData.findings.length} finding${baselineData.findings.length === 1 ? "" : "s"}`;
|
|
@@ -3331,12 +3331,12 @@ const registerInitCommand = (program) => {
|
|
|
3331
3331
|
// src/commands/mcp.ts
|
|
3332
3332
|
const registerMcpCommand = (program) => {
|
|
3333
3333
|
program.command("mcp").description("Start Model Context Protocol (MCP) server over stdio for AI agents").action(async () => {
|
|
3334
|
-
const { McpServer } = await import("./server
|
|
3334
|
+
const { McpServer } = await import("./server--meyU6b-.js");
|
|
3335
3335
|
new McpServer().startStdio();
|
|
3336
3336
|
});
|
|
3337
3337
|
};
|
|
3338
3338
|
// src/program.ts
|
|
3339
|
-
const VERSION = "2.1.
|
|
3339
|
+
const VERSION = "2.1.2";
|
|
3340
3340
|
const parseScore = (value) => {
|
|
3341
3341
|
const score = Number(value);
|
|
3342
3342
|
if (!Number.isInteger(score) || score < 0 || score > 100) throw new InvalidArgumentError("Expected an integer between 0 and 100.");
|
|
@@ -3371,7 +3371,7 @@ const createProgram = () => {
|
|
|
3371
3371
|
program.enablePositionalOptions();
|
|
3372
3372
|
/** True when the user passed the flag; defaults and absent flags fall back to the project config. */
|
|
3373
3373
|
const isFromCli = (optionName) => program.getOptionValueSource(optionName) === "cli";
|
|
3374
|
-
program.name("vue-doctor").description("Diagnose and fix performance issues in your Vue.js app").version(VERSION).argument("[directory]", "Project directory to scan", ".").option("--no-lint", "Skip lint checks").option("--no-dead-code", "Skip dead code checks").option("--no-cache", "Re-analyze every file instead of reusing results for unchanged files").option("-v, --verbose", "Show file details per rule").option("-q, --quiet", "Only print the report, warnings and errors (no banner or progress)").option("--debug", "Print debug details: resolved config, tool versions, per-analyzer counts (also: DEBUG=vue-doctor:*)").option("--timings", "Print per-analyzer timings").option("--no-color", "Disable colours (also: NO_COLOR=1; FORCE_COLOR=1 forces them)").option("--score", "Output just the score number").addOption(new Option("--format <format>", "Report format: text, json (one report@2 document), jsonl (one finding per line), sarif (SARIF 2.1.0 for GitHub code scanning), github (GitHub Actions annotations), markdown (PR comment / step summary) or html (self-contained interactive report file)").choices(REPORT_FORMATS)).option("--json", "Alias for --format json").option("--output <file>", "Write the json/jsonl/sarif/github/markdown/html report to this file instead of stdout").option("--no-timestamp", "Omit the generation time and timings from json/jsonl output, for reproducible reports").option("--report", "Deprecated: use --format html --output <file>. Writes the HTML report to a private temporary directory (never the project) and prints its path").option("--github-summary", "Write results to GitHub Actions step summary").option("--diff [branch]", "Only scan files changed vs. a branch or current changes").option("-y, --yes", "Skip interactive prompts").option("--project <names>", "Workspace project(s) to scan (comma-separated)").option("--audit", "Check installed dependency versions for known vulnerabilities via OSV.dev (sends package names and versions; needs the network, skipped with --offline)").option("--offline", "Guarantee zero network access (also: VUE_DOCTOR_OFFLINE=1)").option("-f, --force", "Bypass Vue dependency check").addOption(new Option("--fail-on <severity>", "Exit with code 1 when findings of this severity (or worse) exist").choices(FAIL_ON_VALUES).default("none")).addOption(new Option("--gate <scope>", "Which findings count for --fail-on: all, or only new ones (vs. baseline/base branch)").choices(GATE_SCOPE_VALUES).default("all")).option("--min-score <score>", "Exit with code 1 when the score is below this value (0-100)", parseScore).option("--strict", "Exit with code 3 when an analyzer could not run").option("--baseline <file>", "Treat findings in this baseline file as known (status: baseline); see `vue-doctor baseline`").option("--fix", "
|
|
3374
|
+
program.name("vue-doctor").description("Diagnose and fix performance issues in your Vue.js app").version(VERSION).argument("[directory]", "Project directory to scan", ".").option("--no-lint", "Skip lint checks").option("--no-dead-code", "Skip dead code checks").option("--no-cache", "Re-analyze every file instead of reusing results for unchanged files").option("-v, --verbose", "Show file details per rule").option("-q, --quiet", "Only print the report, warnings and errors (no banner or progress)").option("--debug", "Print debug details: resolved config, tool versions, per-analyzer counts (also: DEBUG=vue-doctor:*)").option("--timings", "Print per-analyzer timings").option("--no-color", "Disable colours (also: NO_COLOR=1; FORCE_COLOR=1 forces them)").option("--score", "Output just the score number").addOption(new Option("--format <format>", "Report format: text, json (one report@2 document), jsonl (one finding per line), sarif (SARIF 2.1.0 for GitHub code scanning), github (GitHub Actions annotations), markdown (PR comment / step summary) or html (self-contained interactive report file)").choices(REPORT_FORMATS)).option("--json", "Alias for --format json").option("--output <file>", "Write the json/jsonl/sarif/github/markdown/html report to this file instead of stdout").option("--no-timestamp", "Omit the generation time and timings from json/jsonl output, for reproducible reports").option("--report", "Deprecated: use --format html --output <file>. Writes the HTML report to a private temporary directory (never the project) and prints its path").option("--github-summary", "Write results to GitHub Actions step summary").option("--diff [branch]", "Only scan files changed vs. a branch or current changes").option("-y, --yes", "Skip interactive prompts").option("--project <names>", "Workspace project(s) to scan (comma-separated)").option("--audit", "Check installed dependency versions for known vulnerabilities via OSV.dev (sends package names and versions; needs the network, skipped with --offline)").option("--offline", "Guarantee zero network access (also: VUE_DOCTOR_OFFLINE=1)").option("-f, --force", "Bypass Vue dependency check").addOption(new Option("--fail-on <severity>", "Exit with code 1 when findings of this severity (or worse) exist").choices(FAIL_ON_VALUES).default("none")).addOption(new Option("--gate <scope>", "Which findings count for --fail-on: all, or only new ones (vs. baseline/base branch)").choices(GATE_SCOPE_VALUES).default("all")).option("--min-score <score>", "Exit with code 1 when the score is below this value (0-100)", parseScore).option("--strict", "Exit with code 3 when an analyzer could not run").option("--baseline <file>", "Treat findings in this baseline file as known (status: baseline); see `vue-doctor baseline`").option("--fix", "Fix the reported findings of fixable rules with deterministic codemods, then scan the fixed code", false).option("--dry-run", "With --fix: print the fixes as a unified diff instead of writing them (no scan)", false).action(async (directoryArg, options) => {
|
|
3375
3375
|
try {
|
|
3376
3376
|
if (options.quiet && options.debug) throw new InvalidArgumentError("--quiet and --debug cannot be combined.");
|
|
3377
3377
|
configureLogger({
|
|
@@ -3389,28 +3389,51 @@ const createProgram = () => {
|
|
|
3389
3389
|
if (options.output && format === "text") throw new InvalidArgumentError("--output requires --format json, jsonl, sarif, github, markdown or html.");
|
|
3390
3390
|
const legacyHtmlReport = options.report === true;
|
|
3391
3391
|
if (legacyHtmlReport) logger.warn("--report is deprecated and will be removed in a future release; use --format html --output <file>.");
|
|
3392
|
-
if (options.fix)
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3392
|
+
if (options.fix && isFromCli("lint") && options.lint === false) throw new InvalidArgumentError("--fix cannot be combined with --no-lint: fixes are applied to lint findings.");
|
|
3393
|
+
const prepared = [];
|
|
3394
|
+
for (const projectDirectory of projectDirectories) {
|
|
3395
|
+
const loadedConfig = await loadConfig(projectDirectory);
|
|
3396
|
+
const config = loadedConfig?.config ?? null;
|
|
3397
|
+
logger.debug("config", loadedConfig ? `loaded ${loadedConfig.filePath}` : `no config file in ${projectDirectory}`);
|
|
3398
|
+
let includePaths = [];
|
|
3399
|
+
const diff = options.diff ?? (config?.diff === false ? void 0 : config?.diff);
|
|
3400
|
+
if (diff !== void 0) {
|
|
3401
|
+
const diffInfo = getDiffInfo(projectDirectory, typeof diff === "string" ? diff : void 0);
|
|
3402
|
+
if (diffInfo.status === "unavailable") logger.warn(`--diff is unavailable (${diffInfo.reason}); running a FULL scan of ${projectDirectory}.`);
|
|
3403
|
+
else {
|
|
3404
|
+
const changedSourceFiles = diffInfo.status === "ok" ? filterSourceFiles(diffInfo.changedFiles) : [];
|
|
3405
|
+
if (changedSourceFiles.length === 0) {
|
|
3406
|
+
const scope = diffInfo.isCurrentChanges ? "uncommitted changes" : `changes vs. ${diffInfo.baseBranch}`;
|
|
3407
|
+
logger.dim(`No changed source files in ${scope} for ${projectDirectory}; nothing to scan.`);
|
|
3408
|
+
continue;
|
|
3409
|
+
}
|
|
3410
|
+
includePaths = changedSourceFiles;
|
|
3402
3411
|
}
|
|
3403
3412
|
}
|
|
3413
|
+
prepared.push({
|
|
3414
|
+
directory: projectDirectory,
|
|
3415
|
+
config,
|
|
3416
|
+
includePaths
|
|
3417
|
+
});
|
|
3418
|
+
}
|
|
3419
|
+
if (options.fix) {
|
|
3420
|
+
const { runFixPass } = await import("./runner-DfuzuZYa.js");
|
|
3421
|
+
await runFixPass(prepared, {
|
|
3422
|
+
dryRun: options.dryRun === true,
|
|
3423
|
+
displayRoot: resolvedDirectory,
|
|
3424
|
+
lint: isFromCli("lint") ? options.lint : void 0,
|
|
3425
|
+
cache: isFromCli("cache") ? options.cache : void 0,
|
|
3426
|
+
force: options.force ?? false,
|
|
3427
|
+
offline: options.offline,
|
|
3428
|
+
onDebug: logger.debug
|
|
3429
|
+
});
|
|
3404
3430
|
if (options.dryRun) {
|
|
3405
3431
|
process.exitCode = EXIT_CODES.ok;
|
|
3406
3432
|
return;
|
|
3407
3433
|
}
|
|
3408
3434
|
}
|
|
3409
3435
|
const scans = [];
|
|
3410
|
-
for (const projectDirectory of
|
|
3411
|
-
const loadedConfig = await loadConfig(projectDirectory);
|
|
3412
|
-
const config = loadedConfig?.config ?? null;
|
|
3413
|
-
logger.debug("config", loadedConfig ? `loaded ${loadedConfig.filePath}` : `no config file in ${projectDirectory}`);
|
|
3436
|
+
for (const { directory: projectDirectory, config, includePaths } of prepared) {
|
|
3414
3437
|
const scanOptions = {
|
|
3415
3438
|
lint: isFromCli("lint") ? options.lint : void 0,
|
|
3416
3439
|
deadCode: isFromCli("deadCode") ? options.deadCode : void 0,
|
|
@@ -3422,24 +3445,10 @@ const createProgram = () => {
|
|
|
3422
3445
|
audit: isFromCli("audit") ? options.audit : void 0,
|
|
3423
3446
|
json: format !== "text",
|
|
3424
3447
|
force: options.force ?? false,
|
|
3425
|
-
includePaths
|
|
3448
|
+
includePaths,
|
|
3426
3449
|
config,
|
|
3427
3450
|
baseline: options.baseline === void 0 ? void 0 : path.resolve(options.baseline)
|
|
3428
3451
|
};
|
|
3429
|
-
const diff = options.diff ?? (config?.diff === false ? void 0 : config?.diff);
|
|
3430
|
-
if (diff !== void 0) {
|
|
3431
|
-
const diffInfo = getDiffInfo(projectDirectory, typeof diff === "string" ? diff : void 0);
|
|
3432
|
-
if (diffInfo.status === "unavailable") logger.warn(`--diff is unavailable (${diffInfo.reason}); running a FULL scan of ${projectDirectory}.`);
|
|
3433
|
-
else {
|
|
3434
|
-
const changedSourceFiles = diffInfo.status === "ok" ? filterSourceFiles(diffInfo.changedFiles) : [];
|
|
3435
|
-
if (changedSourceFiles.length === 0) {
|
|
3436
|
-
const scope = diffInfo.isCurrentChanges ? "uncommitted changes" : `changes vs. ${diffInfo.baseBranch}`;
|
|
3437
|
-
logger.dim(`No changed source files in ${scope} for ${projectDirectory}; nothing to scan.`);
|
|
3438
|
-
continue;
|
|
3439
|
-
}
|
|
3440
|
-
scanOptions.includePaths = changedSourceFiles;
|
|
3441
|
-
}
|
|
3442
|
-
}
|
|
3443
3452
|
scans.push({
|
|
3444
3453
|
directory: projectDirectory,
|
|
3445
3454
|
options: scanOptions,
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { _ as CUSTOM_TEMPLATE_PLUGIN_NAME, a as OXLINT_RULES, b as isTestFile, d as createTemplateRuleConfig, f as getCanonicalRuleId, g as SCRIPT_DEPENDENT_TEMPLATE_RULES, h as toDiagnosticRule, i as AUDIT_RULES, l as createCustomTemplateRuleConfig, m as getRuleMeta, n as resolveRuleKey, o as PLUGIN_NAME, p as getEnabledFsRules, r as ruleIdOf, t as createRuleIdReporter, u as createOxlintConfig, v as CUSTOM_TEMPLATE_RULES, y as COOKIE_SESSION_FUNCTIONS } from "./rule-ids-BrYqJT7o.js";
|
|
3
|
-
import { a as readBaseline, r as applyBaseline } from "./baseline-BgcqUbRB.js";
|
|
4
|
-
import { i as normalizeRelativePath, n as isInsideAnyDirectory, r as listProjectSourceFiles, t as LINTABLE_FILE_PATTERN } from "./list-source-files-Uf11_Lde.js";
|
|
5
|
-
import { n as isMonorepoRoot, r as readPackageJson, t as findMonorepoRoot } from "./find-monorepo-root-VE6uVqvK.js";
|
|
6
|
-
import { S as WARNING_RULE_PENALTY, _ as OXLINT_NODE_REQUIREMENT, c as listNestedWorkspaceDirectories, d as resolveTsconfigPath, f as resolvePnpmCatalogVersion, h as ERROR_RULE_PENALTY, l as listWorkspaceDirectories, n as discoverProject, s as inferVueVersionFromNuxt, t as NUXT_CONFIG_FILENAMES, u as listWorkspacePackages, x as VUE_FILE_PATTERN } from "./discover-project-B1uzc9aU.js";
|
|
7
|
-
import { r as resolveConfiguredRuleOptions, t as mergeRuleOptions } from "./rule-options-dyUSlzk0.js";
|
|
8
|
-
import Module, { createRequire } from "node:module";
|
|
9
|
-
import fs from "node:fs";
|
|
10
2
|
import path from "node:path";
|
|
11
|
-
import { fileURLToPath } from "node:url";
|
|
12
3
|
import { performance } from "node:perf_hooks";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
import { a as readBaseline, r as applyBaseline } from "./baseline-ekG8ZnQz.js";
|
|
13
7
|
import { createHash } from "node:crypto";
|
|
14
8
|
import os from "node:os";
|
|
15
9
|
import { spawn, spawnSync } from "node:child_process";
|
|
10
|
+
import { _ as CUSTOM_TEMPLATE_PLUGIN_NAME, a as OXLINT_RULES, b as isTestFile, d as createTemplateRuleConfig, f as getCanonicalRuleId, g as SCRIPT_DEPENDENT_TEMPLATE_RULES, h as toDiagnosticRule, i as AUDIT_RULES, l as createCustomTemplateRuleConfig, m as getRuleMeta, n as resolveRuleKey, o as PLUGIN_NAME, p as getEnabledFsRules, r as ruleIdOf, t as createRuleIdReporter, u as createOxlintConfig, v as CUSTOM_TEMPLATE_RULES, y as COOKIE_SESSION_FUNCTIONS } from "./rule-ids-BloekNcu.js";
|
|
11
|
+
import { n as isMonorepoRoot, r as readPackageJson, t as findMonorepoRoot } from "./find-monorepo-root-VE6uVqvK.js";
|
|
12
|
+
import { S as WARNING_RULE_PENALTY, _ as OXLINT_NODE_REQUIREMENT, c as listNestedWorkspaceDirectories, d as resolveTsconfigPath, f as resolvePnpmCatalogVersion, h as ERROR_RULE_PENALTY, l as listWorkspaceDirectories, n as discoverProject, s as inferVueVersionFromNuxt, t as NUXT_CONFIG_FILENAMES, u as listWorkspacePackages, x as VUE_FILE_PATTERN } from "./discover-project-DdngEZRq.js";
|
|
13
|
+
import Module, { createRequire } from "node:module";
|
|
16
14
|
import pc from "picocolors";
|
|
15
|
+
import { r as resolveConfiguredRuleOptions, t as mergeRuleOptions } from "./rule-options-DxpXX5-D.js";
|
|
17
16
|
// src/config/load-config.ts
|
|
18
17
|
/** Looked up in the project root only, in this order. More than one is an error. */
|
|
19
18
|
const CONFIG_FILENAMES$1 = [
|
|
@@ -59,7 +58,7 @@ const validateConfig = async (value, filePath) => {
|
|
|
59
58
|
if (!result.success) throw new ConfigError(filePath, result.error.issues.flatMap(formatIssue));
|
|
60
59
|
const config = value;
|
|
61
60
|
if (Object.values(config.rules ?? {}).some((entry) => Array.isArray(entry) && entry.length === 2)) {
|
|
62
|
-
const { validateRuleOptions } = await import("./validate-rule-options-
|
|
61
|
+
const { validateRuleOptions } = await import("./validate-rule-options-Du_YeG6D.js");
|
|
63
62
|
const issues = validateRuleOptions(config);
|
|
64
63
|
if (issues.length > 0) throw new ConfigError(filePath, issues);
|
|
65
64
|
}
|
|
@@ -119,6 +118,66 @@ const loadConfig = async (directory) => {
|
|
|
119
118
|
filePath: packageJsonPath
|
|
120
119
|
};
|
|
121
120
|
};
|
|
121
|
+
// src/utils/list-source-files.ts
|
|
122
|
+
/** Files the analyzers lint: Vue SFCs and JS/TS modules. */
|
|
123
|
+
const LINTABLE_FILE_PATTERN = /\.(vue|[cm]?[jt]sx?)$/;
|
|
124
|
+
const SKIPPED_DIRECTORY_NAMES = /* @__PURE__ */ new Set([
|
|
125
|
+
"node_modules",
|
|
126
|
+
"dist",
|
|
127
|
+
"build",
|
|
128
|
+
"coverage",
|
|
129
|
+
"out"
|
|
130
|
+
]);
|
|
131
|
+
const GIT_LIST_MAX_BUFFER_BYTES$1 = 268435456;
|
|
132
|
+
const normalizeRelativePath = (filePath) => path.posix.normalize(filePath.replace(/\\/g, "/"));
|
|
133
|
+
const listFilesWithGit = (rootDirectory) => {
|
|
134
|
+
const result = spawnSync("git", [
|
|
135
|
+
"ls-files",
|
|
136
|
+
"-z",
|
|
137
|
+
"--cached",
|
|
138
|
+
"--others",
|
|
139
|
+
"--exclude-standard"
|
|
140
|
+
], {
|
|
141
|
+
cwd: rootDirectory,
|
|
142
|
+
encoding: "utf-8",
|
|
143
|
+
maxBuffer: GIT_LIST_MAX_BUFFER_BYTES$1
|
|
144
|
+
});
|
|
145
|
+
if (result.error || result.status !== 0) return null;
|
|
146
|
+
return result.stdout.split("\0").filter((filePath) => filePath && fs.existsSync(path.join(rootDirectory, filePath)));
|
|
147
|
+
};
|
|
148
|
+
const walkFiles = (rootDirectory) => {
|
|
149
|
+
const files = [];
|
|
150
|
+
const walk = (directory) => {
|
|
151
|
+
let entries;
|
|
152
|
+
try {
|
|
153
|
+
entries = fs.readdirSync(directory, { withFileTypes: true });
|
|
154
|
+
} catch {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
for (const entry of entries) {
|
|
158
|
+
if (entry.name.startsWith(".") || SKIPPED_DIRECTORY_NAMES.has(entry.name)) continue;
|
|
159
|
+
const fullPath = path.join(directory, entry.name);
|
|
160
|
+
if (entry.isDirectory()) walk(fullPath);
|
|
161
|
+
else if (entry.isFile()) files.push(path.relative(rootDirectory, fullPath));
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
walk(rootDirectory);
|
|
165
|
+
return files;
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* Whether `filePath` (relative to `rootDirectory`) lies inside one of `directories` (absolute, or
|
|
169
|
+
* relative to `rootDirectory`).
|
|
170
|
+
*/
|
|
171
|
+
const isInsideAnyDirectory = (rootDirectory, filePath, directories) => directories.some((directory) => {
|
|
172
|
+
const prefix = normalizeRelativePath(path.relative(rootDirectory, path.resolve(rootDirectory, directory)));
|
|
173
|
+
return prefix !== "" && prefix !== "." && normalizeRelativePath(filePath).startsWith(`${prefix}/`);
|
|
174
|
+
});
|
|
175
|
+
/**
|
|
176
|
+
* Lintable source files of a project, relative with forward slashes and sorted: git's view
|
|
177
|
+
* (honours .gitignore) with a plain directory walk as fallback outside git repositories.
|
|
178
|
+
* `excludedDirectories` (e.g. the workspaces nested in a monorepo root) are left out.
|
|
179
|
+
*/
|
|
180
|
+
const listProjectSourceFiles = (rootDirectory, excludedDirectories = []) => (listFilesWithGit(rootDirectory) ?? walkFiles(rootDirectory)).filter((filePath) => LINTABLE_FILE_PATTERN.test(filePath)).map(normalizeRelativePath).filter((filePath) => !isInsideAnyDirectory(rootDirectory, filePath, excludedDirectories)).sort();
|
|
122
181
|
// src/core/cache.ts
|
|
123
182
|
/**
|
|
124
183
|
* Content-hash cache of raw analyzer findings, so re-runs (e.g. an AI agent's fix loop) only send
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export { n as discoverProject, i as formatFrameworkName } from "./discover-project-
|
|
2
|
+
export { n as discoverProject, i as formatFrameworkName } from "./discover-project-DdngEZRq.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { n as isMonorepoRoot, r as readPackageJson, t as findMonorepoRoot } from "./find-monorepo-root-VE6uVqvK.js";
|
|
3
2
|
import fs from "node:fs";
|
|
4
3
|
import path from "node:path";
|
|
5
4
|
import { spawnSync } from "node:child_process";
|
|
5
|
+
import { n as isMonorepoRoot, r as readPackageJson, t as findMonorepoRoot } from "./find-monorepo-root-VE6uVqvK.js";
|
|
6
6
|
// src/constants.ts
|
|
7
7
|
const DOCS_BASE_URL = "https://remylagerweij.github.io/vue-doctor";
|
|
8
8
|
const SOURCE_FILE_PATTERN = /\.(vue|tsx?|jsx?|mjs|cjs)$/;
|
|
@@ -13,7 +13,7 @@ const SPAWN_ARGS_MAX_LENGTH_CHARS = 24e3;
|
|
|
13
13
|
const DEFAULT_BRANCH_CANDIDATES = ["main", "master"];
|
|
14
14
|
const ERROR_RULE_PENALTY = 1.5;
|
|
15
15
|
const WARNING_RULE_PENALTY = .75;
|
|
16
|
-
const VERSION = "2.1.
|
|
16
|
+
const VERSION = "2.1.2";
|
|
17
17
|
const OXLINT_NODE_REQUIREMENT = "^22.12.0 || >=24.0.0";
|
|
18
18
|
// src/utils/pnpm-catalog.ts
|
|
19
19
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public programmatic API of Vue Doctor.
|
|
3
|
+
*
|
|
4
|
+
* Importing this module has no side effects: it never parses argv, prints, or exits.
|
|
5
|
+
* The CLI (`vue-doctor` bin) is a thin layer on top of `diagnose()`.
|
|
6
|
+
*/
|
|
1
7
|
import { z } from "zod";
|
|
2
8
|
/**
|
|
3
9
|
* Single source of truth for `vue-doctor.config.*`: the TypeScript types, runtime validation and the
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { S as isTestFile, _ as toDiagnosticRule, a as createRuleIdReporter, b as CUSTOM_TEMPLATE_RULES, c as AUDIT_RULES, d as createCustomTemplateRuleConfig, f as createOxlintConfig, g as getRuleMeta, h as getEnabledFsRules, l as OXLINT_RULES, m as getCanonicalRuleId, o as resolveRuleKey, p as createTemplateRuleConfig, r as resolveConfiguredRuleOptions, s as ruleIdOf, t as mergeRuleOptions, u as PLUGIN_NAME, v as SCRIPT_DEPENDENT_TEMPLATE_RULES, x as COOKIE_SESSION_FUNCTIONS, y as CUSTOM_TEMPLATE_PLUGIN_NAME } from "./rule-options-DKLnjGap.js";
|
|
2
|
-
import Module, { createRequire } from "node:module";
|
|
3
1
|
import path from "node:path";
|
|
4
2
|
import { performance } from "node:perf_hooks";
|
|
5
3
|
import fs from "node:fs";
|
|
6
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { S as isTestFile, _ as toDiagnosticRule, a as createRuleIdReporter, b as CUSTOM_TEMPLATE_RULES, c as AUDIT_RULES, d as createCustomTemplateRuleConfig, f as createOxlintConfig, g as getRuleMeta, h as getEnabledFsRules, l as OXLINT_RULES, m as getCanonicalRuleId, o as resolveRuleKey, p as createTemplateRuleConfig, r as resolveConfiguredRuleOptions, s as ruleIdOf, t as mergeRuleOptions, u as PLUGIN_NAME, v as SCRIPT_DEPENDENT_TEMPLATE_RULES, x as COOKIE_SESSION_FUNCTIONS, y as CUSTOM_TEMPLATE_PLUGIN_NAME } from "./rule-options-DuZJJ_Sn.js";
|
|
7
6
|
import { createHash } from "node:crypto";
|
|
8
7
|
import os from "node:os";
|
|
9
8
|
import { spawn, spawnSync } from "node:child_process";
|
|
9
|
+
import Module, { createRequire } from "node:module";
|
|
10
10
|
import pc from "picocolors";
|
|
11
11
|
// src/config/load-config.ts
|
|
12
12
|
/** Looked up in the project root only, in this order. More than one is an error. */
|
|
@@ -53,7 +53,7 @@ const validateConfig = async (value, filePath) => {
|
|
|
53
53
|
if (!result.success) throw new ConfigError(filePath, result.error.issues.flatMap(formatIssue));
|
|
54
54
|
const config = value;
|
|
55
55
|
if (Object.values(config.rules ?? {}).some((entry) => Array.isArray(entry) && entry.length === 2)) {
|
|
56
|
-
const { validateRuleOptions } = await import("./validate-rule-options-
|
|
56
|
+
const { validateRuleOptions } = await import("./validate-rule-options-r01B-gA_.js");
|
|
57
57
|
const issues = validateRuleOptions(config);
|
|
58
58
|
if (issues.length > 0) throw new ConfigError(filePath, issues);
|
|
59
59
|
}
|