mirror of
https://github.com/danbulant/oxc
synced 2026-05-25 04:42:10 +00:00
this allows the ability to redirect the stdout to so can create a valid json file this also matches with eslint's format option closes #2899
This commit is contained in:
parent
d65eab3b8b
commit
6eba02f472
3 changed files with 32 additions and 21 deletions
|
|
@ -145,6 +145,7 @@ impl Runner for LintRunner {
|
||||||
number_of_errors: diagnostic_service.errors_count(),
|
number_of_errors: diagnostic_service.errors_count(),
|
||||||
max_warnings_exceeded: diagnostic_service.max_warnings_exceeded(),
|
max_warnings_exceeded: diagnostic_service.max_warnings_exceeded(),
|
||||||
deny_warnings: warning_options.deny_warnings,
|
deny_warnings: warning_options.deny_warnings,
|
||||||
|
print_summary: diagnostic_service.is_graphical_output(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ pub struct LintResult {
|
||||||
pub number_of_errors: usize,
|
pub number_of_errors: usize,
|
||||||
pub max_warnings_exceeded: bool,
|
pub max_warnings_exceeded: bool,
|
||||||
pub deny_warnings: bool,
|
pub deny_warnings: bool,
|
||||||
|
pub print_summary: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
@ -51,31 +52,36 @@ impl Termination for CliRunResult {
|
||||||
number_of_errors,
|
number_of_errors,
|
||||||
max_warnings_exceeded,
|
max_warnings_exceeded,
|
||||||
deny_warnings,
|
deny_warnings,
|
||||||
|
print_summary,
|
||||||
}) => {
|
}) => {
|
||||||
let threads = rayon::current_num_threads();
|
if print_summary {
|
||||||
let number_of_diagnostics = number_of_warnings + number_of_errors;
|
let threads = rayon::current_num_threads();
|
||||||
|
let number_of_diagnostics = number_of_warnings + number_of_errors;
|
||||||
|
|
||||||
if number_of_diagnostics > 0 {
|
if number_of_diagnostics > 0 {
|
||||||
println!();
|
println!();
|
||||||
|
}
|
||||||
|
|
||||||
|
let time = Self::get_execution_time(&duration);
|
||||||
|
let s = if number_of_files == 1 { "" } else { "s" };
|
||||||
|
println!(
|
||||||
|
"Finished in {time} on {number_of_files} file{s} with {number_of_rules} rules using {threads} threads."
|
||||||
|
);
|
||||||
|
|
||||||
|
if max_warnings_exceeded {
|
||||||
|
println!(
|
||||||
|
"Exceeded maximum number of warnings. Found {number_of_warnings}."
|
||||||
|
);
|
||||||
|
return ExitCode::from(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"Found {number_of_warnings} warning{} and {number_of_errors} error{}.",
|
||||||
|
if number_of_warnings == 1 { "" } else { "s" },
|
||||||
|
if number_of_errors == 1 { "" } else { "s" }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let time = Self::get_execution_time(&duration);
|
|
||||||
let s = if number_of_files == 1 { "" } else { "s" };
|
|
||||||
println!(
|
|
||||||
"Finished in {time} on {number_of_files} file{s} with {number_of_rules} rules using {threads} threads."
|
|
||||||
);
|
|
||||||
|
|
||||||
if max_warnings_exceeded {
|
|
||||||
println!("Exceeded maximum number of warnings. Found {number_of_warnings}.");
|
|
||||||
return ExitCode::from(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
println!(
|
|
||||||
"Found {number_of_warnings} warning{} and {number_of_errors} error{}.",
|
|
||||||
if number_of_warnings == 1 { "" } else { "s" },
|
|
||||||
if number_of_errors == 1 { "" } else { "s" }
|
|
||||||
);
|
|
||||||
|
|
||||||
let exit_code =
|
let exit_code =
|
||||||
u8::from((number_of_warnings > 0 && deny_warnings) || number_of_errors > 0);
|
u8::from((number_of_warnings > 0 && deny_warnings) || number_of_errors > 0);
|
||||||
ExitCode::from(exit_code)
|
ExitCode::from(exit_code)
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,10 @@ impl DiagnosticService {
|
||||||
self.reporter = DiagnosticReporter::new_json();
|
self.reporter = DiagnosticReporter::new_json();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_graphical_output(&self) -> bool {
|
||||||
|
matches!(self.reporter, DiagnosticReporter::Graphical { .. })
|
||||||
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn with_quiet(mut self, yes: bool) -> Self {
|
pub fn with_quiet(mut self, yes: bool) -> Self {
|
||||||
self.quiet = yes;
|
self.quiet = yes;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue