-
-
Notifications
You must be signed in to change notification settings - Fork 508
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
feat(formatter): add expand
#4819
Conversation
CodSpeed Performance ReportMerging #4819 will not alter performanceComparing Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do admit I’m not really happy with the naming. My first thought was the option was something to configure lists of something to expand (kinda like allowLists
), and I only understood what it actually meant after reading the description. But maybe that’s just me 😅
But even after reading it, I understood it would apply to arrays, but I was still surprised it applied to objects too. I don’t think I’ve ever seen objects called lists in any terminology before, so this doesn’t really make sense to me.
I actually think there’s less confusion with expandLiterals
, because even though the term literals applies to primitives too, I don’t think anyone is surprised it doesn’t expand literals that cannot be expanded.
I also think “literal” is not really a beginner-unfriendly term. It’s surely better than calling things incorrectly to avoid the actual correct words.
I also considered expandObjects
. At least there’s the precedent that JavaScript considers arrays to be objects, but I still prefer expandLiterals
overall, since both “object literal” and “array literal” are commonly accepted in JavaScript terminology and expandObjects
may just introduce confusion in the opposite direction that expandLists
does.
What do you think of just
|
Hm, yeah. Given it’s only for JSON, where there aren’t many other explanations possible, I think that could work:) |
Introduce the ability to configure JSON list formatting with an "expand lists" option. This ensures arrays and objects can always be expanded across multiple lines when specified. Defaults are applied differently for `package.json` files unless overridden.
expandLists
expand
d58887d
to
daa03d6
Compare
Co-authored-by: Arend van Beelen jr. <[email protected]>
Summary
This PR closes #4370
I added a new option called
expand
. It was suggestedexpandLiterals
, but it doesn't seem very beginner-friendly:However, feel free to suggest some other name.
Also,
package.json
is always expanded, unless the user decides to change the defaults.Test Plan
I added new tests