Skip to content

Conversation

@wagenet
Copy link
Contributor

@wagenet wagenet commented Oct 25, 2025

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

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() and OxlintGlobals::merge() for deep merge
  • Updated Oxlintrc::merge() to use new merge methods
  • Added settings field to OxlintOverride struct
  • Applied settings in override resolution logic with deep merge
  • Added PartialEq to 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.

@wagenet wagenet requested a review from camc314 as a code owner October 25, 2025 00:37
Copilot AI review requested due to automatic review settings October 25, 2025 00:37
@graphite-app
Copy link
Contributor

graphite-app bot commented Oct 25, 2025

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.

@github-actions github-actions bot added the A-linter Area - Linter label Oct 25, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements ESLint-compatible deep merge semantics for config extension and overrides. Previously, settings, env, and globals were replaced entirely when extending configs or using overrides. Now these fields are properly merged, allowing incremental configuration changes without redeclaring entire objects.

Key Changes:

  • Added deep merge methods to all plugin settings types and OxlintSettings
  • Implemented merge logic for env and globals
  • Added settings field support to overrides with deep merge behavior

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
npm/oxlint/configuration_schema.json Added settings field to override schema definition
crates/oxc_linter/src/snapshots/schema_json.snap Updated schema snapshot with settings in overrides
crates/oxc_linter/src/config/settings/vitest.rs Added merge method and is_empty helper to VitestPluginSettings
crates/oxc_linter/src/config/settings/react.rs Added merge method and is_empty helper to ReactPluginSettings
crates/oxc_linter/src/config/settings/next.rs Added merge method to NextPluginSettings
crates/oxc_linter/src/config/settings/mod.rs Added merge and merge_into methods to OxlintSettings
crates/oxc_linter/src/config/settings/jsx_a11y.rs Added merge method to JSXA11yPluginSettings
crates/oxc_linter/src/config/settings/jsdoc.rs Added merge method and is_empty helper to JSDocPluginSettings
crates/oxc_linter/src/config/oxlintrc.rs Updated to use merge methods for settings, env, and globals
crates/oxc_linter/src/config/overrides.rs Added settings field to OxlintOverride struct
crates/oxc_linter/src/config/globals.rs Added merge method to OxlintGlobals
crates/oxc_linter/src/config/env.rs Added merge method to OxlintEnv
crates/oxc_linter/src/config/config_store.rs Integrated settings merging in override resolution and added accessor methods
crates/oxc_linter/src/config/config_builder.rs Added settings to override building and comprehensive merge tests
crates/oxc_linter/fixtures/extends_config/merge/*.json Added test fixtures for merge behavior validation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions github-actions bot added the A-cli Area - CLI label Oct 25, 2025
@camc314 camc314 self-assigned this Oct 25, 2025
@overlookmotel overlookmotel added the A-linter-plugins Area - Linter JS plugins label Nov 10, 2025
@wagenet wagenet force-pushed the improved-config-merging branch from 9b23573 to f7a08f0 Compare November 14, 2025 05:40
@codspeed-hq
Copy link

codspeed-hq bot commented Nov 14, 2025

CodSpeed Performance Report

Merging #14940 will not alter performance

Comparing wagenet:improved-config-merging (c1edd11) with main (c167dfa)1

Summary

✅ 4 untouched
⏩ 33 skipped2

Footnotes

  1. 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.

  2. 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.

@wagenet wagenet force-pushed the improved-config-merging branch from f7a08f0 to 37c6e3f Compare November 14, 2025 05:56
@github-actions github-actions bot added the A-codegen Area - Code Generation label Nov 14, 2025
@wagenet
Copy link
Contributor Author

wagenet commented Nov 14, 2025

CI Tests pass for me locally (macOS) so I'm not sure what's going on there. Looks like maybe just whitespace.

@connorshea
Copy link
Contributor

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

Finished in <variable>ms on 43 files using 1 threads.
----------
CLI result: LintFoundErrors
Error running tsgolint: "exit status: exit status: 2"----------
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you probably need to run pnpm i and re-run the test cases - this snapshot change looks incorrect.

@overlookmotel
Copy link
Member

Have we discussed whether this would be considered a breaking change?

@wagenet wagenet force-pushed the improved-config-merging branch from 37c6e3f to c1edd11 Compare November 17, 2025 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-codegen Area - Code Generation A-linter Area - Linter A-linter-plugins Area - Linter JS plugins

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants