Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ vp = "local"
steps = [
{ argv = ["vp", "check", "--fix"], continue-on-failure = true },
{ argv = ["vp", "check"], continue-on-failure = true },
{ argv = ["vp", "check", "--fix", "--quiet"], comment = "quiet composes with the fix pipeline", continue-on-failure = true },
]
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,13 @@ warn: Lint warnings found

Found 0 errors and 1 warning in 2 files (<duration>, <n> threads)
```

## `vp check --fix --quiet`

quiet composes with the fix pipeline

```

Found 0 errors and 1 warning in 2 files (<duration>, <n> threads)
pass: Formatting completed for checked files (<duration>)
```
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = "check_fmt_fail"
vp = "local"
steps = [
{ argv = ["vp", "check"], continue-on-failure = true },
{ argv = ["vp", "check", "--quiet"], comment = "quiet does not suppress formatting failures", continue-on-failure = true },
{ argv = ["vp", "check", "--fix"], continue-on-failure = true },
{ argv = ["vp", "check"], comment = "should pass after fix", continue-on-failure = true },
]
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ src/index.js (<duration>)
Found formatting issues in 1 file (<duration>, <n> threads). Run `vp check --fix` to fix them.
```

## `vp check --quiet`

quiet does not suppress formatting failures

**Exit code:** 1

```
error: Formatting issues found
src/index.js (<duration>)

Found formatting issues in 1 file (<duration>, <n> threads). Run `vp check --fix` to fix them.
```

## `vp check --fix`

```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ name = "check_lint_fail"
vp = "local"
steps = [
{ argv = ["vp", "check"], continue-on-failure = true },
{ argv = ["vp", "check", "--quiet"], comment = "warnings are suppressed while errors are still reported", continue-on-failure = true },
]
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,39 @@ error: Lint issues found
1 │ function hello() {
2 │ eval("code");
· ────
3 │ return "hello";
3 │ console.log("warning");
╰────
help: Avoid eval(). For JSON parsing use JSON.parse(); for dynamic property access use bracket notation (obj[key]); for other cases refactor to avoid evaluating strings as code.

Found 1 error and 0 warnings in 2 files (<duration>, <n> threads)
⚠ eslint(no-console): Unexpected console statement.
╭─[src/index.js:3:3]
2 │ eval("code");
3 │ console.log("warning");
· ───────────
4 │ return "hello";
╰────
help: Delete this console statement.

Found 1 error and 1 warning in 2 files (<duration>, <n> threads)
```

## `vp check --quiet`

warnings are suppressed while errors are still reported

**Exit code:** 1

```
pass: All 3 files are correctly formatted (<duration>, <n> threads)
error: Lint issues found
× eslint(no-eval): eval can be harmful.
╭─[src/index.js:2:3]
1 │ function hello() {
2 │ eval("code");
· ────
3 │ console.log("warning");
╰────
help: Avoid eval(). For JSON parsing use JSON.parse(); for dynamic property access use bracket notation (obj[key]); for other cases refactor to avoid evaluating strings as code.

Found 1 error and 1 warning in 2 files (<duration>, <n> threads)
```
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
function hello() {
eval("code");
console.log("warning");
return "hello";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export default {
lint: {
rules: {
"no-eval": "error",
"no-console": "warn",
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ name = "check_lint_warn"
vp = "local"
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 },
]
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,23 @@ warn: Lint warnings found

Found 0 errors and 1 warning in 2 files (<duration>, <n> threads)
```

## `vp check --quiet`

warning diagnostics are suppressed

```
pass: All 3 files are correctly formatted (<duration>, <n> threads)

Found 0 errors and 1 warning in 2 files (<duration>, <n> threads)
```

## `vp lint --quiet`

standalone lint has the same warning suppression semantics

```

Found 1 warning and 0 errors.
Finished in <duration> on 2 files with <n> rules using <n> threads.
```
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ name = "check_lint_warn_deny_warnings"
vp = "local"
steps = [
{ argv = ["vp", "check"], continue-on-failure = true },
{ argv = ["vp", "check", "--quiet"], comment = "warnings stay hidden but denyWarnings still fails", continue-on-failure = true },
{ argv = ["vp", "lint", "--quiet"], comment = "standalone lint also hides diagnostics and preserves the denyWarnings failure", continue-on-failure = true },
]
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,28 @@ warn: Lint warnings found

Found 0 errors and 1 warning in 2 files (<duration>, <n> threads)
```

## `vp check --quiet`

warnings stay hidden but denyWarnings still fails

**Exit code:** 1

```
pass: All 3 files are correctly formatted (<duration>, <n> threads)
warn: Lint warnings found

Found 0 errors and 1 warning in 2 files (<duration>, <n> threads)
```

## `vp lint --quiet`

standalone lint also hides diagnostics and preserves the denyWarnings failure

**Exit code:** 1

```

Found 1 warning and 0 errors.
Finished in <duration> on 2 files with <n> rules using <n> threads.
```
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ name = "check_no_lint_typecheck_fail"
vp = "local"
steps = [
{ argv = ["vp", "check", "--no-lint"], continue-on-failure = true },
{ argv = ["vp", "check", "--no-lint", "--quiet"], comment = "type errors are still reported when lint rules are skipped", continue-on-failure = true },
]
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,22 @@ error: Type errors found

Found 1 error and 0 warnings in 2 files (<duration>, <n> threads)
```

## `vp check --no-lint --quiet`

type errors are still reported when lint rules are skipped

**Exit code:** 1

```
pass: All 3 files are correctly formatted (<duration>, <n> threads)
error: Type errors found
× typescript(TS2322): Type 'string' is not assignable to type 'number'.
╭─[src/index.ts:1:7]
1 │ const value: number = "not a number";
· ─────
2 │ export { value };
╰────

Found 1 error and 0 warnings in 2 files (<duration>, <n> threads)
```
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Arguments:

Options:
--fix Auto-fix format and lint issues
--quiet Disable reporting on warnings, only errors are reported
--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
Expand Down Expand Up @@ -41,6 +42,7 @@ Arguments:

Options:
--fix Auto-fix format and lint issues
--quiet Disable reporting on warnings, only errors are reported
--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
Expand Down Expand Up @@ -68,6 +70,7 @@ Arguments:

Options:
--fix Auto-fix format and lint issues
--quiet Disable reporting on warnings, only errors are reported
--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
Expand Down
1 change: 1 addition & 0 deletions docs/guide/check.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ We recommend turning `typeCheck` on so `vp check` becomes the single command for
```bash
vp check
vp check --fix # Format and run autofixers.
vp check --quiet # Hide lint warnings; still report and fail on 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 `typeCheck` enabled).
Expand Down
15 changes: 11 additions & 4 deletions packages/cli/binding/src/check/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ impl LintMessageKind {
}
}

pub(super) fn success_label(self) -> &'static str {
pub(super) fn success_label(self, quiet: bool) -> &'static str {
match self {
Self::LintOnly if quiet => "Found no lint errors",
Self::LintOnly => "Found no warnings or lint errors",
Self::LintAndTypeCheck if quiet => "Found no lint or type errors",
Self::LintAndTypeCheck => "Found no warnings, lint errors, or type errors",
Self::TypeCheckOnly => "Found no type errors",
}
Expand Down Expand Up @@ -262,7 +264,10 @@ mod tests {
fn lint_message_kind_defaults_to_lint_only_without_typecheck() {
assert!(!lint_config_type_check_enabled(None));
assert!(!lint_config_type_check_enabled(Some(&json!({ "options": {} }))));
assert_eq!(LintMessageKind::from_flags(true, false), LintMessageKind::LintOnly);
let kind = LintMessageKind::from_flags(true, false);
assert_eq!(kind, LintMessageKind::LintOnly);
assert_eq!(kind.success_label(false), "Found no warnings or lint errors");
assert_eq!(kind.success_label(true), "Found no lint errors");
}

#[test]
Expand All @@ -278,7 +283,8 @@ mod tests {

let kind = LintMessageKind::from_flags(true, true);
assert_eq!(kind, LintMessageKind::LintAndTypeCheck);
assert_eq!(kind.success_label(), "Found no warnings, lint errors, or type errors");
assert_eq!(kind.success_label(false), "Found no warnings, lint errors, or type errors");
assert_eq!(kind.success_label(true), "Found no lint or type errors");
assert_eq!(kind.warning_heading(), "Lint or type warnings found");
assert_eq!(kind.issue_heading(), "Lint or type issues found");
}
Expand All @@ -287,7 +293,8 @@ mod tests {
fn lint_message_kind_type_check_only_labels() {
let kind = LintMessageKind::from_flags(false, true);
assert_eq!(kind, LintMessageKind::TypeCheckOnly);
assert_eq!(kind.success_label(), "Found no type errors");
assert_eq!(kind.success_label(false), "Found no type errors");
assert_eq!(kind.success_label(true), "Found no type errors");
assert_eq!(kind.warning_heading(), "Type warnings found");
assert_eq!(kind.issue_heading(), "Type errors found");
}
Expand Down
21 changes: 16 additions & 5 deletions packages/cli/binding/src/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use crate::cli::{
pub(crate) async fn execute_check(
resolver: &SubcommandResolver,
fix: bool,
quiet: bool,
no_fmt_flag: bool,
no_lint_flag: bool,
no_error_on_unmatched_pattern: bool,
Expand Down Expand Up @@ -153,6 +154,9 @@ pub(crate) async fn execute_check(
if fix && lint_enabled {
args.push("--fix".to_string());
}
if quiet {
args.push("--quiet".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
Expand Down Expand Up @@ -184,7 +188,7 @@ pub(crate) async fn execute_check(
Some(Ok(success)) => {
let message = format!(
"{} in {}",
lint_message_kind.success_label(),
lint_message_kind.success_label(quiet),
format_count(success.summary.files, "file", "files"),
);
let detail =
Expand All @@ -197,10 +201,17 @@ pub(crate) async fn execute_check(
}
}
Some(Err(failure)) => {
if failure.errors == 0 && failure.warnings > 0 {
output::warn(lint_message_kind.warning_heading());
} else {
output::error(lint_message_kind.issue_heading());
// `--quiet` suppresses warning diagnostics, but oxlint still
// reports warning counts in its summary. Preserve those counts
// so `vp check --quiet` matches `vp lint --quiet` semantics.
let quiet_warning_only =
quiet && failure.errors == 0 && status == ExitStatus::SUCCESS;
if !quiet_warning_only {
if failure.errors == 0 && failure.warnings > 0 {
output::warn(lint_message_kind.warning_heading());
} else {
output::error(lint_message_kind.issue_heading());
}
}
print_stdout_block(&failure.diagnostics);
print_summary_line(&format!(
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/binding/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ async fn execute_direct_subcommand(
let status = match subcommand {
SynthesizableSubcommand::Check {
fix,
quiet,
no_fmt,
no_lint,
no_error_on_unmatched_pattern,
Expand All @@ -102,6 +103,7 @@ async fn execute_direct_subcommand(
return crate::check::execute_check(
&resolver,
fix,
quiet,
no_fmt,
no_lint,
no_error_on_unmatched_pattern,
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/binding/src/cli/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ pub enum SynthesizableSubcommand {
/// Auto-fix format and lint issues
#[arg(long)]
fix: bool,
/// Disable reporting on warnings, only errors are reported
#[arg(long)]
quiet: bool,
/// Skip format check
#[arg(long = "no-fmt")]
no_fmt: bool,
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/src/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,10 @@ const commandHelpDocs = {
title: 'Options',
rows: [
{ label: '--fix', description: 'Auto-fix format and lint issues' },
{
label: '--quiet',
description: 'Disable reporting on warnings, only errors are reported',
},
{ label: '--no-fmt', description: 'Skip format check' },
{
label: '--no-lint',
Expand Down
Loading