@@ -82,6 +82,12 @@ impl Runner for LintRunner {
8282 }
8383 } ;
8484
85+ let handler = if cfg ! ( any( test, feature = "force_test_reporter" ) ) {
86+ GraphicalReportHandler :: new_themed ( miette:: GraphicalTheme :: none ( ) )
87+ } else {
88+ GraphicalReportHandler :: new ( )
89+ } ;
90+
8591 let config_search_result =
8692 Self :: find_oxlint_config ( & self . cwd , basic_options. config . as_ref ( ) ) ;
8793
@@ -90,8 +96,12 @@ impl Runner for LintRunner {
9096 Err ( err) => {
9197 print_and_flush_stdout (
9298 stdout,
93- & format ! ( "Failed to parse configuration file.\n {err}\n " ) ,
99+ & format ! (
100+ "Failed to parse configuration file.\n {}\n " ,
101+ render_report( & handler, & err)
102+ ) ,
94103 ) ;
104+
95105 return CliRunResult :: InvalidOptionConfig ;
96106 }
97107 } ;
@@ -172,12 +182,6 @@ impl Runner for LintRunner {
172182 let paths = walker. paths ( ) ;
173183 let number_of_files = paths. len ( ) ;
174184
175- let handler = if cfg ! ( any( test, feature = "force_test_reporter" ) ) {
176- GraphicalReportHandler :: new_themed ( miette:: GraphicalTheme :: none ( ) )
177- } else {
178- GraphicalReportHandler :: new ( )
179- } ;
180-
181185 let mut external_plugin_store = ExternalPluginStore :: default ( ) ;
182186
183187 let search_for_nested_configs = !disable_nested_config &&
@@ -485,40 +489,14 @@ impl LintRunner {
485489 // when config is provided, but not found, an String with the formatted error is returned, else the oxlintrc config file is returned
486490 // when no config is provided, it will search for the default file names in the current working directory
487491 // when no file is found, the default configuration is returned
488- fn find_oxlint_config ( cwd : & Path , config : Option < & PathBuf > ) -> Result < Oxlintrc , String > {
489- if let Some ( config_path) = config {
490- let full_path = match absolute ( cwd. join ( config_path) ) {
491- Ok ( path) => path,
492- Err ( e) => {
493- let handler = GraphicalReportHandler :: new ( ) ;
494- let mut err = String :: new ( ) ;
495- handler
496- . render_report (
497- & mut err,
498- & OxcDiagnostic :: error ( format ! (
499- "Failed to resolve config path {}: {e}" ,
500- config_path. display( )
501- ) ) ,
502- )
503- . unwrap ( ) ;
504- return Err ( err) ;
505- }
506- } ;
507- return match Oxlintrc :: from_file ( & full_path) {
508- Ok ( config) => Ok ( config) ,
509- Err ( diagnostic) => {
510- let handler = GraphicalReportHandler :: new ( ) ;
511- let mut err = String :: new ( ) ;
512- handler. render_report ( & mut err, & diagnostic) . unwrap ( ) ;
513- return Err ( err) ;
514- }
515- } ;
492+ fn find_oxlint_config ( cwd : & Path , config : Option < & PathBuf > ) -> Result < Oxlintrc , OxcDiagnostic > {
493+ let path: & Path = config. map_or ( Self :: DEFAULT_OXLINTRC . as_ref ( ) , PathBuf :: as_ref) ;
494+ let full_path = cwd. join ( path) ;
495+
496+ if config. is_some ( ) || full_path. exists ( ) {
497+ return Oxlintrc :: from_file ( & full_path) ;
516498 }
517- // no config argument is provided,
518- // auto detect default config file from current work directory
519- // or return the default configuration, when no valid file is found
520- let config_path = cwd. join ( Self :: DEFAULT_OXLINTRC ) ;
521- Oxlintrc :: from_file ( & config_path) . or_else ( |_| Ok ( Oxlintrc :: default ( ) ) )
499+ Ok ( Oxlintrc :: default ( ) )
522500 }
523501
524502 /// Looks in a directory for an oxlint config file, returns the oxlint config if it exists
@@ -715,6 +693,12 @@ mod test {
715693 Tester :: new ( ) . with_cwd ( "fixtures/auto_config_detection" . into ( ) ) . test_and_snapshot ( args) ;
716694 }
717695
696+ #[ test]
697+ fn oxlint_config_auto_detection_parse_error ( ) {
698+ let args = & [ "debugger.js" ] ;
699+ Tester :: new ( ) . with_cwd ( "fixtures/auto_config_parse_error" . into ( ) ) . test_and_snapshot ( args) ;
700+ }
701+
718702 #[ test]
719703 fn eslintrc_no_undef ( ) {
720704 let args = & [
0 commit comments