Implement proper deep merging for settings, env, and globals in config extension and overrides
Yes, this was written with AI. However, I have manually reviewed all of it and it seems correct and high quality to me. That said, I am new to this codebase.
Problem
When extending configs or using overrides, settings, env, and globals were completely replaced instead of being merged. This meant you had to redeclare entire configuration objects even if you only wanted to change one value.
Solution
Implemented deep merge semantics (ESLint compatible) for config extension and added settings support to overrides:
Config Extension (extends)
- env & globals: Deep merge - nested properties are merged, child values override parent values
-
settings: Deep merge at all levels:
-
Objects (like
components,attributes): Merged recursively - both parent and child entries are preserved, child overrides on conflict -
Arrays (like
formComponents,rootDir): Replaced, not merged (ESLint v9 behavior) -
Primitives (like
polymorphicPropName, booleans): Child overrides parent
-
Objects (like
File Overrides (overrides)
- settings: Now supported - can specify different settings for specific file patterns using same deep merge logic
- env & globals: Already worked, now uses consistent deep merge behavior
Changes
- Added
merge()methods to all plugin settings types (JSXA11yPluginSettings,ReactPluginSettings,NextPluginSettings,JSDocPluginSettings,VitestPluginSettings) - Updated
OxlintSettings::merge()to orchestrate deep merging across all plugin settings - Updated
OxlintEnv::merge()andOxlintGlobals::merge()for deep merge - Updated
Oxlintrc::merge()to use new merge methods - Added
settingsfield toOxlintOverridestruct - Applied settings in override resolution logic with deep merge
- Added
PartialEqto settings structs for comparison optimization
Testing
- 5 tests covering env, globals, and settings merging in both extension and overrides
- All 816 tests pass
- Test fixtures added in
fixtures/extends_config/merge/
Example (Deep Merge)
// parent.json
{
"env": { "browser": true },
"settings": {
"jsx-a11y": {
"polymorphicPropName": "as",
"components": { "Link": "a" }
}
}
}
// child.json
{
"extends": ["./parent.json"],
"env": { "node": true },
"settings": {
"jsx-a11y": {
"polymorphicPropName": "component",
"components": { "Button": "button" }
},
"react": { "formComponents": ["CustomForm"] }
}
}
Result (Deep Merge):
- env:
{ "browser": true, "node": true }— Both merged - settings.jsx-a11y:
-
polymorphicPropName: "component"— Child overrides -
components: { "Link": "a", "Button": "button" }— Both merged
-
- settings.react:
{ "formComponents": ["CustomForm"] }— Added from child
This matches ESLint's deep merge behavior where nested objects are recursively merged but arrays are replaced.
How to use the Graphite Merge Queue
Add either label to this PR to merge it via the merge queue:
- 0-merge - adds this PR to the back of the merge queue
- hotfix - for urgent hot fixes, skip the queue and merge this PR next
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.
CodSpeed Performance Report
Merging #14940 will not alter performance
Comparing wagenet:improved-config-merging (c1edd11) with main (c167dfa)[^unexpected-base]
[^unexpected-base]: No successful run was found on main (fbf0fd4) during the generation of this report, so c167dfa was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.
Summary
✅ 4 untouched
⏩ 33 skipped[^skipped]
[^skipped]: 33 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.
CI Tests pass for me locally (macOS) so I'm not sure what's going on there. Looks like maybe just whitespace.
CI Tests pass for me locally (macOS) so I'm not sure what's going on there. Looks like maybe just whitespace.
ah I actually ran into the same problem in the last few weeks with that snapshot, if you revert the changes to that snapshot it should pass
Have we discussed whether this would be considered a breaking change?