From 81e9b82eb08bef364dab125555ee38b6cce66181 Mon Sep 17 00:00:00 2001 From: MK Date: Mon, 20 Apr 2026 22:46:13 +0800 Subject: [PATCH 1/2] fix(check): respect oxlint exit code so denyWarnings fails `vp check` `vp check` was unconditionally resetting the status to success whenever lint reported only warnings, masking the non-zero exit code produced by oxlint when `options.denyWarnings` (or `--deny-warnings`) is enabled. Drop the override and trust oxlint's exit code so warning-only runs fail the check when warnings have been opted in as failures. Closes #1424 --- packages/cli/binding/src/check/mod.rs | 5 ++++- .../check-lint-warn-deny-warnings/package.json | 5 +++++ .../check-lint-warn-deny-warnings/snap.txt | 13 +++++++++++++ .../check-lint-warn-deny-warnings/src/index.js | 5 +++++ .../check-lint-warn-deny-warnings/steps.json | 6 ++++++ .../check-lint-warn-deny-warnings/vite.config.ts | 10 ++++++++++ 6 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 packages/cli/snap-tests/check-lint-warn-deny-warnings/package.json create mode 100644 packages/cli/snap-tests/check-lint-warn-deny-warnings/snap.txt create mode 100644 packages/cli/snap-tests/check-lint-warn-deny-warnings/src/index.js create mode 100644 packages/cli/snap-tests/check-lint-warn-deny-warnings/steps.json create mode 100644 packages/cli/snap-tests/check-lint-warn-deny-warnings/vite.config.ts diff --git a/packages/cli/binding/src/check/mod.rs b/packages/cli/binding/src/check/mod.rs index 722a52578c..7918fd3bcf 100644 --- a/packages/cli/binding/src/check/mod.rs +++ b/packages/cli/binding/src/check/mod.rs @@ -176,9 +176,12 @@ pub(crate) async fn execute_check( } } Some(Err(failure)) => { + // Trust the oxlint exit code: oxlint exits 0 for warning-only + // output by default and exits non-zero when `denyWarnings` (or + // `--deny-warnings`) promotes warnings to failures. The heading + // still reflects the findings (warnings vs errors). if failure.errors == 0 && failure.warnings > 0 { output::warn(lint_message_kind.warning_heading()); - status = ExitStatus::SUCCESS; } else { output::error(lint_message_kind.issue_heading()); } diff --git a/packages/cli/snap-tests/check-lint-warn-deny-warnings/package.json b/packages/cli/snap-tests/check-lint-warn-deny-warnings/package.json new file mode 100644 index 0000000000..643b60208b --- /dev/null +++ b/packages/cli/snap-tests/check-lint-warn-deny-warnings/package.json @@ -0,0 +1,5 @@ +{ + "name": "check-lint-warn-deny-warnings", + "version": "0.0.0", + "private": true +} diff --git a/packages/cli/snap-tests/check-lint-warn-deny-warnings/snap.txt b/packages/cli/snap-tests/check-lint-warn-deny-warnings/snap.txt new file mode 100644 index 0000000000..655232799e --- /dev/null +++ b/packages/cli/snap-tests/check-lint-warn-deny-warnings/snap.txt @@ -0,0 +1,13 @@ +[1]> vp check +pass: All 4 files are correctly formatted (ms, threads) +warn: Lint warnings found +⚠ eslint(no-console): Unexpected console statement. + ╭─[src/index.js:2:3] + 1 │ function hello() { + 2 │ console.log("hello"); + · ─────────── + 3 │ } + ╰──── + help: Delete this console statement. + +Found 0 errors and 1 warning in 2 files (ms, threads) diff --git a/packages/cli/snap-tests/check-lint-warn-deny-warnings/src/index.js b/packages/cli/snap-tests/check-lint-warn-deny-warnings/src/index.js new file mode 100644 index 0000000000..9373ddd734 --- /dev/null +++ b/packages/cli/snap-tests/check-lint-warn-deny-warnings/src/index.js @@ -0,0 +1,5 @@ +function hello() { + console.log("hello"); +} + +export { hello }; diff --git a/packages/cli/snap-tests/check-lint-warn-deny-warnings/steps.json b/packages/cli/snap-tests/check-lint-warn-deny-warnings/steps.json new file mode 100644 index 0000000000..d9c26d5a29 --- /dev/null +++ b/packages/cli/snap-tests/check-lint-warn-deny-warnings/steps.json @@ -0,0 +1,6 @@ +{ + "env": { + "VITE_DISABLE_AUTO_INSTALL": "1" + }, + "commands": ["vp check"] +} diff --git a/packages/cli/snap-tests/check-lint-warn-deny-warnings/vite.config.ts b/packages/cli/snap-tests/check-lint-warn-deny-warnings/vite.config.ts new file mode 100644 index 0000000000..4957dbe218 --- /dev/null +++ b/packages/cli/snap-tests/check-lint-warn-deny-warnings/vite.config.ts @@ -0,0 +1,10 @@ +export default { + lint: { + options: { + denyWarnings: true, + }, + rules: { + "no-console": "warn", + }, + }, +}; From bcd1a841f735d900eae55918f0b787d91aa7d09f Mon Sep 17 00:00:00 2001 From: MK Date: Mon, 20 Apr 2026 22:51:14 +0800 Subject: [PATCH 2/2] chore(check): drop redundant comment on lint heading branch --- packages/cli/binding/src/check/mod.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/cli/binding/src/check/mod.rs b/packages/cli/binding/src/check/mod.rs index 7918fd3bcf..6e05fbf5c4 100644 --- a/packages/cli/binding/src/check/mod.rs +++ b/packages/cli/binding/src/check/mod.rs @@ -176,10 +176,6 @@ pub(crate) async fn execute_check( } } Some(Err(failure)) => { - // Trust the oxlint exit code: oxlint exits 0 for warning-only - // output by default and exits non-zero when `denyWarnings` (or - // `--deny-warnings`) promotes warnings to failures. The heading - // still reflects the findings (warnings vs errors). if failure.errors == 0 && failure.warnings > 0 { output::warn(lint_message_kind.warning_heading()); } else {