fix(format): preserve built-in fields when partially overriding a formatter#14883
Open
zerone0x wants to merge 1 commit intoanomalyco:devfrom
Open
fix(format): preserve built-in fields when partially overriding a formatter#14883zerone0x wants to merge 1 commit intoanomalyco:devfrom
zerone0x wants to merge 1 commit intoanomalyco:devfrom
Conversation
…matter When a user overrides only `extensions` (without specifying `command`), the built-in command was silently replaced with an empty array due to incorrect merge ordering. The `command: []` stub spread before `...item` was then passed to mergeDeep as the override value, causing the `command.length === 0` guard to skip the entire formatter config. Fix the merge order so that: defaults < built-in < user config This way, any field the user omits falls back to the built-in value instead of an empty default. Fixes anomalyco#14857 Co-Authored-By: Claude <noreply@anthropic.com>
b832eca to
5a6347f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #14857
Type of change
What does this PR do?
When a user overrides a built-in formatter's
extensionswithout also specifyingcommand, the entire override was silently discarded and the original built-in (including all default extensions) remained unchanged.Root cause: The merge order was wrong. The code spread
command: []as an empty stub before...item, then passed the combined object as the override tomergeDeep. Since the user didn't providecommand, the stub[]was used — which then replaced the built-in command array. Thecommand.length === 0guard fired, skipping the formatter entirely.Fix: Change the merge order to:
defaults < built-in < user configThis means a user can now write:
…and prettier's built-in command is preserved while only the extensions are narrowed.
How did you verify your code works?
extensions, (b) override with onlycommand, (c) override with both, (d) new custom formatter, (e)disabled: true— all cases behave correctly.mergeDeepimport fromremeda.Checklist
🤖 Generated with Claude Code (issue-hunter-pro)