diff --git a/apps/oxlint/src/lint.rs b/apps/oxlint/src/lint.rs index 4c36af07d6929..677882a956bb5 100644 --- a/apps/oxlint/src/lint.rs +++ b/apps/oxlint/src/lint.rs @@ -341,6 +341,20 @@ impl CliRunner { let number_of_files = files_to_lint.len(); + // Due to the architecture of the import plugin and JS plugins, + // linting a large number of files with both enabled can cause resource exhaustion. + // See: https://github.com/oxc-project/oxc/issues/15863 + if number_of_files > 10_000 && use_cross_module && has_external_linter { + print_and_flush_stdout( + stdout, + &format!( + "Failed to run oxlint.\n{}\n", + render_report(&handler, &OxcDiagnostic::error(format!("Linting {number_of_files} files with both import plugin and JS plugins enabled can cause resource exhaustion.")).with_help("See https://github.com/oxc-project/oxc/issues/15863 for more details.")) + ), + ); + return CliRunResult::TooManyFilesWithImportAndJsPlugins; + } + let tsconfig = basic_options.tsconfig; if let Some(path) = tsconfig.as_ref() { if path.is_file() { diff --git a/apps/oxlint/src/result.rs b/apps/oxlint/src/result.rs index 7c658f633defb..84b6f08f15e46 100644 --- a/apps/oxlint/src/result.rs +++ b/apps/oxlint/src/result.rs @@ -17,6 +17,7 @@ pub enum CliRunResult { ConfigFileInitFailed, ConfigFileInitSucceeded, TsGoLintError, + TooManyFilesWithImportAndJsPlugins, } impl Termination for CliRunResult { @@ -37,7 +38,8 @@ impl Termination for CliRunResult { | Self::InvalidOptionSeverityWithoutFilter | Self::InvalidOptionSeverityWithoutPluginName | Self::InvalidOptionSeverityWithoutRuleName - | Self::TsGoLintError => ExitCode::FAILURE, + | Self::TsGoLintError + | Self::TooManyFilesWithImportAndJsPlugins => ExitCode::FAILURE, } } }