Open rinu opened 6 years ago
If you set brace-style
to expand
, you get closer to what you're looking for, but still not quite it:
{
"stuff": [
{
"thing": "other thing"
},
{
"thing": "other thing"
}]
}
But actually, this is a bug, because expand
should produce the expected output.
Even if the bug gets fixed, expand
is still not perfect for this use case. Because braces always start on a new line, even if there is no array around. This I assume is not a bug but expected for expand
{"key1":{"i": "o"}}
Becomes
{
"key1":
{
"i": "o"
}
}
Rather than
{
"key1": {
"i": "o"
}
}
@rinu Yes, you're correct. What you're describing is an enhancement.
@bitwiseman any updates on this issue?
@Huachao The linked bug provides interesting context for this issue. Thanks! This enhancement is not high priority for the project. If you are interested in it, your help would be appreciated.
Does anyone expect this issue to ever get fixed? It's the ONE issue I have with js-beautify, unfortunately.
@stevekanter-arcticleaf Nothing has changed. This project currently has very few contributors, so issues remain unfixed. If you'd like to take a swing at fixing this issue, come to the gitter channel and lets talk about what you'd need to do to make this happen.
Description
I need the beautified version not to start an array and object on the same line. This is for code folding with codemirror which only has one folding button per line. It defaults to folding the object but my intent was to fold the entire array. An annoying workaround is to enter a new line manually before folding. The current version looks prettier so I would like it to be an option rather than the default.
Input
The code looked like this before beautification:
Expected Output
The code should have looked like this after beautification:
Actual Output
The code actually looked like this after beautification:
Steps to Reproduce
I used indent_size: 2 as the only option. Can be reproduced on http://jsbeautifier.org/ I'm using js-beautify 1.7.5 from npm.