Skip to content

Commit 1d2eaca

Browse files
committed
refactor(oxlint2): introduce force_test_reporter feature for consistent graphical outputs (#12133)
1 parent baa3726 commit 1d2eaca

File tree

6 files changed

+12
-5
lines changed

6 files changed

+12
-5
lines changed

apps/oxlint/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,4 @@ default = []
6262
allocator = ["dep:mimalloc-safe"]
6363
oxlint2 = ["oxc_linter/oxlint2"]
6464
disable_oxlint2 = ["oxc_linter/disable_oxlint2"]
65+
force_test_reporter = ["oxc_linter/force_test_reporter"]

apps/oxlint/src/lint.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,11 @@ impl Runner for LintRunner {
172172
let paths = walker.paths();
173173
let number_of_files = paths.len();
174174

175-
let handler = GraphicalReportHandler::new();
175+
let handler = if cfg!(any(test, feature = "force_test_reporter")) {
176+
GraphicalReportHandler::new_themed(miette::GraphicalTheme::none())
177+
} else {
178+
GraphicalReportHandler::new()
179+
};
176180

177181
let search_for_nested_configs = !disable_nested_config &&
178182
// If the `--config` option is explicitly passed, we should not search for nested config files

apps/oxlint/src/output_formatter/default.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ impl InternalFormatter for DefaultOutputFormatter {
4040
}
4141
}
4242

43-
#[cfg(not(test))]
43+
#[cfg(not(any(test, feature = "force_test_reporter")))]
4444
fn get_diagnostic_reporter(&self) -> Box<dyn DiagnosticReporter> {
4545
Box::new(GraphicalReporter::default())
4646
}
4747

48-
#[cfg(test)]
48+
#[cfg(any(test, feature = "force_test_reporter"))]
4949
fn get_diagnostic_reporter(&self) -> Box<dyn DiagnosticReporter> {
5050
use crate::output_formatter::default::test_implementation::GraphicalReporterTester;
5151

@@ -113,7 +113,7 @@ fn get_diagnostic_result_output(result: &DiagnosticResult) -> String {
113113
output
114114
}
115115

116-
#[cfg(test)]
116+
#[cfg(any(test, feature = "force_test_reporter"))]
117117
mod test_implementation {
118118
use oxc_diagnostics::{
119119
Error, GraphicalReportHandler, GraphicalTheme,

crates/oxc_linter/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ ruledocs = ["oxc_macros/ruledocs"] # Enables the `ruledocs` feature for conditio
1919
language_server = ["oxc_data_structures/rope"] # For the Runtime to support needed information for the language server
2020
oxlint2 = []
2121
disable_oxlint2 = []
22+
force_test_reporter = []
2223

2324
[lints]
2425
workspace = true

napi/oxlint2/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,4 @@ napi-build = { workspace = true }
4242

4343
[features]
4444
default = []
45+
force_test_reporter = ["oxlint/force_test_reporter"]

napi/oxlint2/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "module",
66
"scripts": {
77
"build-dev": "napi build --platform --js ./bindings.js --dts ./bindings.d.ts --output-dir src --no-dts-cache --esm",
8-
"build-test": "pnpm run build-dev --release",
8+
"build-test": "pnpm run build-dev --release --features force_test_reporter",
99
"build": "pnpm run build-dev --release",
1010
"test": "vitest"
1111
},

0 commit comments

Comments
 (0)