-
-
Notifications
You must be signed in to change notification settings - Fork 476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛 extends
does not extend/merge values properly from source
#1440
Comments
@ematipico Would you think this bug is fixable before Biome 2? I was never sure whether the behavior was intentional or not, and it could be someone relies on it by now... |
If that "someone" does indeed rely on this misbehaviour, its time to finally fix it 😄 |
I think I've found the bug. Preparing a PR. |
Okay, it is going to be a bit of a complex fix, since the root of the issue runs all the way back into Biome's deserializer. In short: The implementation for Similar problems also exist with It appears an attempt has already been made to work around this problem, since there are explicit So I think the correct fix would actually be to fix the deserializers so they start from a "null" state instead of the default, allowing callers to distinguish between fields that are present in the JSON and those that aren't. Then the defaults should only be merged in at the end, after merging any extended configs. The scope of this will be pretty wide though, and I can't yet oversee all the consequences. It might also mean I can fully clean up Finally, the problems go even deeper for fields with complex values, such as the sets used for I'll attempt to first see how far I would get with changing the deserializers, but please let me know if anyone thinks that approach is likely to fail. (cc @ematipico, @Conaclos) |
I also notice the |
I have a feeling it will be both! I think Ema had called out sometime previously that the difficulty with unifying I think a possible approach here would be to do exactly what you've mentioned and have everything on the configuration side use The language-specific settings also have an interesting property (and a decision to make) about how they interact with overrides. For example: {
"formatter": { "indentWidth": 2 },
"javascript": { "formatter": { "indentWidth": 3 } },
"overrides": [{
"files": ["test.js"],
"formatter": { "indentWidth": 4 }
}]
} When I want to format So imo, formatting for The order of resolution for the value would be (from most important to least important):
And I think the way to achieve that is again exactly the approach you've described, which is to use I guess more generally, that means the order ends up being:
|
I agree, that seems the most logical to me as well. |
Before my refactoring of
The caller was responsible for creating an instance. In fact, every caller created a I refactored Thus, I think this should be easy to change it since only the deserializers have to be updated :) Alternatively, we could remove all custom impls of the |
I agree, however I could prefer reasoning in terms of config propagation. In your example, the {
"formatter": { "indentWidth": 2 },
"javascript": { "formatter": { "indentWidth": 3 } },
"overrides": [{
"files": ["test.js"],
"formatter": { "indentWidth": 4 }
"javascript": { "formatter": { "indentWidth": 3 } },
}]
} |
Yeah that's the curse of the defaults. @faultyserver explained how my solution could be. I wished there was a more generic way to handle this |
We could also introduce a The implementation of
For "atomic" types (numbers, booleans, strings,
|
My first attempt at a fix: #1460 |
Fixed by #1460 |
Environment information
What happened?
Have the following setup:
config.json
biome.json
Result (does not merge properly, it seems like it overrides the entire
formatter
property instead of merging into with precedence)Expected result
Values from
config.json
to be merged intobiome.json
withbiome.json
properties (deep merge maybe) to take precedence:Result
Code of Conduct
The text was updated successfully, but these errors were encountered: