perf(oxlint): return first found config for resolving config#21055
perf(oxlint): return first found config for resolving config#21055
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
There was a problem hiding this comment.
Pull request overview
This PR optimizes oxlint’s nested config discovery when walking ancestor directories by returning only the first config found per directory instead of collecting all possible config files.
Changes:
- Updated ancestor config discovery to use a single optional config per directory (early-return).
- Changed
find_configs_in_directoryfrom returningVec<DiscoveredConfig>toOption<DiscoveredConfig>.
Comments suppressed due to low confidence (1)
apps/oxlint/src/config_loader.rs:72
- In
discover_configs_in_ancestors, the “stop at base config” boundary relies onfind_configs_in_directoryreturning the base config when it exists. After changing that helper to return only a single (first-found) config, a directory with multiple config files can cause the base config path to be missed, so the walk can continue past the intended root and also skip emitting a conflict error. Consider preserving multi-config discovery here (or explicitly detecting conflict + base-config presence) so ancestor traversal is correctly bounded and conflicts are still diagnosed.
if let Some(config) = find_configs_in_directory(dir) {
if config.path() == base_config_path {
// Stop if we've reached the base config file (e.g., root oxlintrc)
// to avoid duplicate loading and filling nested config with configs outside from the root config.
break;
}
config_paths.insert(config);
}
| fn find_configs_in_directory(dir: &Path) -> Option<DiscoveredConfig> { | ||
| let json_path = dir.join(DEFAULT_OXLINTRC_NAME); | ||
| if json_path.is_file() { | ||
| configs.push(DiscoveredConfig::Json(json_path)); | ||
| return Some(DiscoveredConfig::Json(json_path)); | ||
| } | ||
| let jsonc_path = dir.join(DEFAULT_JSONC_OXLINTRC_NAME); | ||
| if jsonc_path.is_file() { | ||
| configs.push(DiscoveredConfig::Jsonc(jsonc_path)); | ||
| return Some(DiscoveredConfig::Jsonc(jsonc_path)); | ||
| } | ||
|
|
||
| let ts_path = dir.join(DEFAULT_TS_OXLINTRC_NAME); | ||
| if ts_path.is_file() { | ||
| configs.push(DiscoveredConfig::Js(ts_path)); | ||
| return Some(DiscoveredConfig::Js(ts_path)); | ||
| } |
There was a problem hiding this comment.
find_configs_in_directory now returns only the first matching config file (JSON → JSONC → TS) and stops checking the other filenames. This changes behavior from the previous implementation that discovered all config files in a directory, which is needed so load_many can detect and error on per-directory config conflicts (see config_conflict_diagnostic). With the new logic, a directory containing multiple config files will silently pick one and will no longer surface the conflict diagnostic during ancestor discovery, potentially applying the wrong config.
69594fa to
64a1a7e
Compare
ba61312 to
6029159
Compare
6029159 to
1171ce7
Compare

No description provided.