@@ -13,8 +13,8 @@ use ignore::{gitignore::Gitignore, overrides::OverrideBuilder};
1313use oxc_allocator:: AllocatorPool ;
1414use oxc_diagnostics:: { DiagnosticService , GraphicalReportHandler , OxcDiagnostic } ;
1515use oxc_linter:: {
16- AllowWarnDeny , Config , ConfigStore , ConfigStoreBuilder , InvalidFilterKind , LintFilter ,
17- LintOptions , LintService , LintServiceOptions , Linter , Oxlintrc ,
16+ AllowWarnDeny , Config , ConfigStore , ConfigStoreBuilder , ExternalLinter , InvalidFilterKind ,
17+ LintFilter , LintOptions , LintService , LintServiceOptions , Linter , Oxlintrc ,
1818} ;
1919use rustc_hash:: { FxHashMap , FxHashSet } ;
2020use serde_json:: Value ;
@@ -29,13 +29,18 @@ use crate::{
2929pub struct LintRunner {
3030 options : LintCommand ,
3131 cwd : PathBuf ,
32+ external_linter : Option < ExternalLinter > ,
3233}
3334
3435impl Runner for LintRunner {
3536 type Options = LintCommand ;
3637
37- fn new ( options : Self :: Options ) -> Self {
38- Self { options, cwd : env:: current_dir ( ) . expect ( "Failed to get current working directory" ) }
38+ fn new ( options : Self :: Options , external_linter : Option < ExternalLinter > ) -> Self {
39+ Self {
40+ options,
41+ cwd : env:: current_dir ( ) . expect ( "Failed to get current working directory" ) ,
42+ external_linter,
43+ }
3944 }
4045
4146 fn run ( self , stdout : & mut dyn Write ) -> CliRunResult {
@@ -63,6 +68,8 @@ impl Runner for LintRunner {
6368 ..
6469 } = self . options ;
6570
71+ let external_linter = self . external_linter . as_ref ( ) ;
72+
6673 let search_for_nested_configs = !disable_nested_config &&
6774 // If the `--config` option is explicitly passed, we should not search for nested config files
6875 // as the passed config file takes absolute precedence.
@@ -173,7 +180,7 @@ impl Runner for LintRunner {
173180 let handler = GraphicalReportHandler :: new ( ) ;
174181
175182 let nested_configs = if search_for_nested_configs {
176- match Self :: get_nested_configs ( stdout, & handler, & filters, & paths) {
183+ match Self :: get_nested_configs ( stdout, & handler, & filters, & paths, external_linter ) {
177184 Ok ( v) => v,
178185 Err ( v) => return v,
179186 }
@@ -192,20 +199,21 @@ impl Runner for LintRunner {
192199 } else {
193200 None
194201 } ;
195- let config_builder = match ConfigStoreBuilder :: from_oxlintrc ( false , oxlintrc) {
196- Ok ( builder) => builder,
197- Err ( e) => {
198- print_and_flush_stdout (
199- stdout,
200- & format ! (
201- "Failed to parse configuration file.\n {}\n " ,
202- render_report( & handler, & OxcDiagnostic :: error( e. to_string( ) ) )
203- ) ,
204- ) ;
205- return CliRunResult :: InvalidOptionConfig ;
202+ let config_builder =
203+ match ConfigStoreBuilder :: from_oxlintrc ( false , oxlintrc, external_linter) {
204+ Ok ( builder) => builder,
205+ Err ( e) => {
206+ print_and_flush_stdout (
207+ stdout,
208+ & format ! (
209+ "Failed to parse configuration file.\n {}\n " ,
210+ render_report( & handler, & OxcDiagnostic :: error( e. to_string( ) ) )
211+ ) ,
212+ ) ;
213+ return CliRunResult :: InvalidOptionConfig ;
214+ }
206215 }
207- }
208- . with_filters ( & filters) ;
216+ . with_filters ( & filters) ;
209217
210218 if let Some ( basic_config_file) = oxlintrc_for_print {
211219 let config_file = config_builder. resolve_final_config_file ( basic_config_file) ;
@@ -387,6 +395,7 @@ impl LintRunner {
387395 handler : & GraphicalReportHandler ,
388396 filters : & Vec < LintFilter > ,
389397 paths : & Vec < Arc < OsStr > > ,
398+ external_linter : Option < & ExternalLinter > ,
390399 ) -> Result < FxHashMap < PathBuf , Config > , CliRunResult > {
391400 // TODO(perf): benchmark whether or not it is worth it to store the configurations on a
392401 // per-file or per-directory basis, to avoid calling `.parent()` on every path.
@@ -417,7 +426,8 @@ impl LintRunner {
417426 // iterate over each config and build the ConfigStore
418427 for ( dir, oxlintrc) in nested_oxlintrc {
419428 // TODO(refactor): clean up all of the error handling in this function
420- let builder = match ConfigStoreBuilder :: from_oxlintrc ( false , oxlintrc) {
429+ let builder = match ConfigStoreBuilder :: from_oxlintrc ( false , oxlintrc, external_linter)
430+ {
421431 Ok ( builder) => builder,
422432 Err ( e) => {
423433 print_and_flush_stdout (
0 commit comments