From ca91c8e7a37e874d6f73e39a187c17215dcef356 Mon Sep 17 00:00:00 2001 From: Augustine Calvino Date: Thu, 15 Oct 2026 15:02:58 -0600 Subject: [PATCH] feat(check): add --deny-warnings flag Forward --deny-warnings to the lint phase of `vp check` so warnings can fail CI without a separate `vp lint --deny-warnings` run. Co-Authored-By: Claude Sonnet 5.5 --- .../fixtures/check_lint_warn/snapshots.toml | 1 + .../snapshots/check_lint_warn.md | 21 +++++++++++++++++++ .../snapshots/command_check_help.md | 3 +++ .../snapshots/command_no_color.global.md | 1 + .../snapshots/command_no_color.local.md | 1 + docs/guide/check.md | 1 + packages/cli/binding/src/check/mod.rs | 4 ++++ packages/cli/binding/src/cli/mod.rs | 2 ++ packages/cli/binding/src/cli/types.rs | 3 +++ packages/cli/src/help.ts | 1 + 10 files changed, 38 insertions(+) diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_lint_warn/snapshots.toml b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_lint_warn/snapshots.toml index 811ee5d44a..d0b348da28 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_lint_warn/snapshots.toml +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_lint_warn/snapshots.toml @@ -5,4 +5,5 @@ steps = [ { argv = ["vp", "check"], continue-on-failure = true }, { argv = ["vp", "check", "--quiet"], comment = "warning diagnostics are suppressed", continue-on-failure = true }, { argv = ["vp", "lint", "--quiet"], comment = "standalone lint has the same warning suppression semantics", continue-on-failure = true }, + { argv = ["vp", "check", "--deny-warnings"], comment = "warnings fail the check", continue-on-failure = true }, ] diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_lint_warn/snapshots/check_lint_warn.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_lint_warn/snapshots/check_lint_warn.md index 80014e8d9b..0a17e08287 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_lint_warn/snapshots/check_lint_warn.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/check_lint_warn/snapshots/check_lint_warn.md @@ -36,3 +36,24 @@ standalone lint has the same warning suppression semantics Found 1 warning and 0 errors. Finished in on 2 files with rules using threads. ``` + +## `vp check --deny-warnings` + +warnings fail the check + +**Exit code:** 1 + +``` +pass: All 3 files are correctly formatted (, 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 (, threads) +``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_check_help/snapshots/command_check_help.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_check_help/snapshots/command_check_help.md index 76081e3122..bb572f92db 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_check_help/snapshots/command_check_help.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_check_help/snapshots/command_check_help.md @@ -15,6 +15,7 @@ Arguments: Options: --fix Auto-fix format and lint issues --quiet Disable reporting on warnings, only errors are reported + --deny-warnings Treat lint warnings as errors --no-fmt Skip format check --no-lint Skip lint rules; type-check still runs when `lint.options.typeCheck` is true --no-error-on-unmatched-pattern Do not exit with error when pattern is unmatched @@ -43,6 +44,7 @@ Arguments: Options: --fix Auto-fix format and lint issues --quiet Disable reporting on warnings, only errors are reported + --deny-warnings Treat lint warnings as errors --no-fmt Skip format check --no-lint Skip lint rules; type-check still runs when `lint.options.typeCheck` is true --no-error-on-unmatched-pattern Do not exit with error when pattern is unmatched @@ -71,6 +73,7 @@ Arguments: Options: --fix Auto-fix format and lint issues --quiet Disable reporting on warnings, only errors are reported + --deny-warnings Treat lint warnings as errors --no-fmt Skip format check --no-lint Skip lint rules; type-check still runs when `lint.options.typeCheck` is true --no-error-on-unmatched-pattern Do not exit with error when pattern is unmatched diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_no_color/snapshots/command_no_color.global.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_no_color/snapshots/command_no_color.global.md index 26bf2a55a0..915170d3ea 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_no_color/snapshots/command_no_color.global.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_no_color/snapshots/command_no_color.global.md @@ -15,6 +15,7 @@ Arguments: Options: --fix Auto-fix format and lint issues --quiet Disable reporting on warnings, only errors are reported + --deny-warnings Treat lint warnings as errors --no-fmt Skip format check --no-lint Skip lint rules; type-check still runs when `lint.options.typeCheck` is true --no-error-on-unmatched-pattern Do not exit with error when pattern is unmatched diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_no_color/snapshots/command_no_color.local.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_no_color/snapshots/command_no_color.local.md index 9c5c81e3e5..a4d4eb455e 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_no_color/snapshots/command_no_color.local.md +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_no_color/snapshots/command_no_color.local.md @@ -15,6 +15,7 @@ Arguments: Options: --fix Auto-fix format and lint issues --quiet Disable reporting on warnings, only errors are reported + --deny-warnings Treat lint warnings as errors --no-fmt Skip format check --no-lint Skip lint rules; type-check still runs when `lint.options.typeCheck` is true --no-error-on-unmatched-pattern Do not exit with error when pattern is unmatched diff --git a/docs/guide/check.md b/docs/guide/check.md index f13be20498..4d08e42ee1 100644 --- a/docs/guide/check.md +++ b/docs/guide/check.md @@ -16,6 +16,7 @@ We recommend turning both `typeAware` and `typeCheck` on so `vp check` becomes t vp check vp check --fix # Format and run autofixers. vp check --quiet # Hide lint warnings; still report and fail on errors. +vp check --deny-warnings # Treat lint warnings as errors. vp check --no-fmt # Skip format; run lint (and type-check if enabled). vp check --no-lint # Skip lint rules; keep type-check when enabled. vp check --no-fmt --no-lint # Type-check only (requires both `typeAware` and `typeCheck` enabled). diff --git a/packages/cli/binding/src/check/mod.rs b/packages/cli/binding/src/check/mod.rs index 56387073a6..92fd00ca2b 100644 --- a/packages/cli/binding/src/check/mod.rs +++ b/packages/cli/binding/src/check/mod.rs @@ -22,6 +22,7 @@ pub(crate) async fn execute_check( resolver: &SubcommandResolver, fix: bool, quiet: bool, + deny_warnings: bool, no_fmt_flag: bool, no_lint_flag: bool, no_error_on_unmatched_pattern: bool, @@ -175,6 +176,9 @@ pub(crate) async fn execute_check( if quiet { args.push("--quiet".to_string()); } + if deny_warnings { + args.push("--deny-warnings".to_string()); + } // `vp check` parses oxlint's human-readable summary output to print // unified pass/fail lines. When `GITHUB_ACTIONS=true`, oxlint auto-switches // to the GitHub reporter, which omits that summary on success and makes the diff --git a/packages/cli/binding/src/cli/mod.rs b/packages/cli/binding/src/cli/mod.rs index 461eb724d4..02046ec96f 100644 --- a/packages/cli/binding/src/cli/mod.rs +++ b/packages/cli/binding/src/cli/mod.rs @@ -99,6 +99,7 @@ async fn execute_direct_subcommand( SynthesizableSubcommand::Check { fix, quiet, + deny_warnings, no_fmt, no_lint, no_error_on_unmatched_pattern, @@ -108,6 +109,7 @@ async fn execute_direct_subcommand( &resolver, fix, quiet, + deny_warnings, no_fmt, no_lint, no_error_on_unmatched_pattern, diff --git a/packages/cli/binding/src/cli/types.rs b/packages/cli/binding/src/cli/types.rs index 3bcce2b22f..6fbd6ddcb9 100644 --- a/packages/cli/binding/src/cli/types.rs +++ b/packages/cli/binding/src/cli/types.rs @@ -89,6 +89,9 @@ pub enum SynthesizableSubcommand { /// Disable reporting on warnings, only errors are reported #[arg(long)] quiet: bool, + /// Treat lint warnings as errors + #[arg(long = "deny-warnings")] + deny_warnings: bool, /// Skip format check #[arg(long = "no-fmt")] no_fmt: bool, diff --git a/packages/cli/src/help.ts b/packages/cli/src/help.ts index 3fab1f805f..78add4e79b 100644 --- a/packages/cli/src/help.ts +++ b/packages/cli/src/help.ts @@ -824,6 +824,7 @@ const commandHelpDocs = { label: '--quiet', description: 'Disable reporting on warnings, only errors are reported', }, + { label: '--deny-warnings', description: 'Treat lint warnings as errors' }, { label: '--no-fmt', description: 'Skip format check' }, { label: '--no-lint',