@@ -175,7 +175,12 @@ impl Runner for LintRunner {
175175 let mut nested_oxlintrc = FxHashMap :: < & Path , Oxlintrc > :: default ( ) ;
176176 let mut nested_configs = FxHashMap :: < PathBuf , ConfigStore > :: default ( ) ;
177177
178- if experimental_nested_config {
178+ let use_nested_config =
179+ // If the `--config` option is explicitly passed, we should not search for nested config files
180+ // as the passed config file takes absolute precedence.
181+ basic_options. config . is_none ( ) ;
182+
183+ if experimental_nested_config && use_nested_config {
179184 // get all of the unique directories among the paths to use for search for
180185 // oxlint config files in those directories
181186 // e.g. `/some/file.js` and `/some/other/file.js` would both result in `/some`
@@ -945,4 +950,12 @@ mod test {
945950 let args = & [ "--experimental-nested-config" ] ;
946951 Tester :: new ( ) . with_cwd ( "fixtures/nested_config" . into ( ) ) . test_and_snapshot ( args) ;
947952 }
953+
954+ #[ test]
955+ fn test_nested_config_precedence ( ) {
956+ // `--config` takes absolute precedence over nested configs, and will be used for
957+ // linting all files rather than the nested configuration files.
958+ let args = & [ "--experimental-nested-config" , "--config" , "oxlint-no-console.json" ] ;
959+ Tester :: new ( ) . with_cwd ( "fixtures/nested_config" . into ( ) ) . test_and_snapshot ( args) ;
960+ }
948961}
0 commit comments