diff --git a/apps/oxlint/src/lint.rs b/apps/oxlint/src/lint.rs index 66dca4a1cdaa4..fc918d9cc0ab9 100644 --- a/apps/oxlint/src/lint.rs +++ b/apps/oxlint/src/lint.rs @@ -359,13 +359,16 @@ impl LintRunner { // Spawn linting in another thread so diagnostics can be printed immediately from diagnostic_service.run. rayon::spawn(move || { + #[cfg(all(feature = "oxlint2", not(feature = "disable_oxlint2")))] + let has_external_linter = linter.has_external_linter(); + let mut lint_service = LintService::new(linter, options); lint_service.with_paths(files_to_lint); - // Use `RawTransferFileSystem` if `oxlint2` feature is enabled. + // Use `RawTransferFileSystem` if `oxlint2` feature is enabled and `ExternalLinter` exists. // This reads the source text into start of allocator, instead of the end. #[cfg(all(feature = "oxlint2", not(feature = "disable_oxlint2")))] - { + if has_external_linter { use crate::raw_fs::RawTransferFileSystem; lint_service.with_file_system(Box::new(RawTransferFileSystem)); } diff --git a/crates/oxc_linter/src/lib.rs b/crates/oxc_linter/src/lib.rs index 42597ee1a3822..0ecab57b2f878 100644 --- a/crates/oxc_linter/src/lib.rs +++ b/crates/oxc_linter/src/lib.rs @@ -92,7 +92,6 @@ fn size_asserts() { pub struct Linter { options: LintOptions, config: ConfigStore, - #[cfg_attr(not(all(feature = "oxlint2", not(feature = "disable_oxlint2"))), expect(dead_code))] external_linter: Option, } @@ -129,6 +128,11 @@ impl Linter { self.config.number_of_rules(type_aware) } + /// Return `true` if `Linter` has an external linter (JS plugins). + pub fn has_external_linter(&self) -> bool { + self.external_linter.is_some() + } + pub fn run<'a>( &self, path: &Path,