Separate formatter.expand settings for arrays and objects
#8305
derekcarepa
started this conversation in
Ideas
Replies: 1 comment
|
Also good for when you want to expand arrays based on if the first value has a newline. Now, for arrays, it's always or based on line width (auto & never). We use line width 100, but do like to multiline when it contains 3 or more values (which could be under the 100 characters if put on a single line) |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Currently, the formatter.expand option in Biome applies to both arrays and objects uniformly. It would be useful to have separate controls, e.g.:
formatter.expand.arrays: "auto" | "always" | "never"formatter.expand.objects: "auto" | "always" | "never"Use Case:
I find the current uniform expand setting doesn't provide enough flexibility. It would be nice to have separate expand settings for arrays and objects, providing more granular control over formatting. This could allow objects to always expand for better readability in config files, while arrays remain compact using "auto" or "never" based on context. Others with similar preferences for granular formatting might benefit too.
Example:
{ "formatter": { "expand": { "arrays": "auto", "objects": "always" } } }This would format arrays based on content length but always expand objects, even when nested inside arrays.
Nested Behavior:
Objects set to "always" would expand regardless of their container (e.g., inside an array set to "never").
The settings apply recursively based on the literal type.
Backward Compatibility:
The existing
formatter.expandsetting would remain as a fallback or shorthand for setting both arrays and objects to the same value. For example, "expand": "auto" could implicitly set arrays: "auto" and objects: "auto", while the new nested structure allows overrides. This ensures existing configs continue working without changes.Contribution:
I'm not familiar with Rust, but I'm willing to help with testing, documentation, or other aspects of the feature if needed.
What do you think? It would be a nice addition to Biome's formatting options.
All reactions