Skip to content

fix(config): implement Merge for rules' options#7941

Merged
Conaclos merged 2 commits intomainfrom
conaclos/options-impl-merge
Nov 3, 2025
Merged

fix(config): implement Merge for rules' options#7941
Conaclos merged 2 commits intomainfrom
conaclos/options-impl-merge

Conversation

@Conaclos
Copy link
Copy Markdown
Member

@Conaclos Conaclos commented Nov 1, 2025

Summary

Fixes #7943
This is an alternative approach to #7938

Instead of wrapping options in an Option, all rule options have to implement Merge.
This allows to support fine-grained options merging.
For example, given the following shared config:

{
  "linter": {
    "enabled": true,
    "rules": {
      "style": {
        "useNamingConvention": {
          "level": "on",
          "options": {
            "strictCase": false,
            "conventions": [{
              "selector": { "kind": "variable", "scope": "global" },
              "formats": ["CONSTANT_CASE"]
            }]
          }
        }
      }
    }
  }
}

And the following user config that extends the shared one:

{
  "extends": ["shared.json"],
  "linter": {
    "enabled": true,
    "rules": {
      "style": {
        "useNamingConvention": {
          "level": "on",
          "options": {
            "strictCase": true,
            "requireAsci": false
          }
        }
      }
    }
  }
}

We obtain the following merged config:

{
  "extends": ["shared.json"],
  "linter": {
    "enabled": true,
    "rules": {
      "style": {
        "useNamingConvention": {
          "level": "on",
          "options": {
            "strictCase": true,
            "requireAsci": false,
            "conventions": [{
              "selector": { "kind": "variable", "scope": "global" },
              "formats": ["CONSTANT_CASE"]
            }]
          }
        }
      }
    }
  }
}

In contrast to files.includes, we don't merge collections in rules' options.
This means that if conventions is set in the user config, then it overrides the conventions set in the shared config.

Test Plan

I added two tests:

  • one for inherited options that is not overrided
  • one for fine-grained merge of options

Docs

  • Add a change set
  • Update the contributing guide

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Nov 1, 2025

🦋 Changeset detected

Latest commit: 2d21d2d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 13 packages
Name Type
@biomejs/biome Patch
@biomejs/cli-win32-x64 Patch
@biomejs/cli-win32-arm64 Patch
@biomejs/cli-darwin-x64 Patch
@biomejs/cli-darwin-arm64 Patch
@biomejs/cli-linux-x64 Patch
@biomejs/cli-linux-arm64 Patch
@biomejs/cli-linux-x64-musl Patch
@biomejs/cli-linux-arm64-musl Patch
@biomejs/wasm-web Patch
@biomejs/wasm-bundler Patch
@biomejs/wasm-nodejs Patch
@biomejs/backend-jsonrpc Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions Bot added A-CLI Area: CLI A-Project Area: project A-Linter Area: linter A-Tooling Area: internal tools L-JavaScript Language: JavaScript and super languages L-CSS Language: CSS and super languages L-JSON Language: JSON and super languages labels Nov 1, 2025
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Nov 1, 2025

CodSpeed Performance Report

Merging #7941 will not alter performance

Comparing conaclos/options-impl-merge (2d21d2d) with main (c9e20c3)

Summary

✅ 53 untouched
⏩ 85 skipped1

Footnotes

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

@Conaclos Conaclos force-pushed the conaclos/options-impl-merge branch 3 times, most recently from bee6655 to e152b70 Compare November 2, 2025 11:25
@Conaclos Conaclos marked this pull request as ready for review November 2, 2025 11:26
@Conaclos Conaclos requested review from a team November 2, 2025 11:26
@Conaclos Conaclos changed the title feat: make rule options implement Merge feat: implement Merge for rules' options Nov 2, 2025
@Conaclos Conaclos changed the title feat: implement Merge for rules' options feat(config): implement Merge for rules' options Nov 2, 2025
@Conaclos Conaclos changed the title feat(config): implement Merge for rules' options fix(config): implement Merge for rules' options Nov 2, 2025
Copy link
Copy Markdown
Contributor

@dyc3 dyc3 left a comment

Choose a reason for hiding this comment

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

FWIW I think this is the better option from a UX perspective. It's the behavior I would expect as a user.

@Conaclos Conaclos force-pushed the conaclos/options-impl-merge branch 2 times, most recently from b104bb4 to b066cb5 Compare November 2, 2025 20:24
Copy link
Copy Markdown
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

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

That's a better approach, thank you. I left some suggestions regarding the docs

Comment thread crates/biome_analyze/CONTRIBUTING.md Outdated
Comment thread crates/biome_analyze/CONTRIBUTING.md Outdated
Comment thread crates/biome_analyze/CONTRIBUTING.md
@Conaclos Conaclos force-pushed the conaclos/options-impl-merge branch 2 times, most recently from 3977f60 to 7ce2ee9 Compare November 3, 2025 19:53
@Conaclos Conaclos requested a review from ematipico November 3, 2025 19:58
@Conaclos Conaclos merged commit 19b8280 into main Nov 3, 2025
27 checks passed
@Conaclos Conaclos deleted the conaclos/options-impl-merge branch November 3, 2025 21:48
@github-actions github-actions Bot mentioned this pull request Nov 3, 2025
This was referenced Dec 14, 2025
l0ngvh pushed a commit to l0ngvh/biome that referenced this pull request Dec 21, 2025
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: CLI A-Linter Area: linter A-Project Area: project A-Tooling Area: internal tools L-CSS Language: CSS and super languages L-JavaScript Language: JavaScript and super languages L-JSON Language: JSON and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 Setting rule's fix overrides the inheirited options from a shared config

3 participants