Formatting an array of objects not working as expected
See original GitHub issueDescription
I submitted this question on SO, but I have a feeling it’s an issue with the parser itself.
I want to both preserve my newlines and have my braces be on the same line as a bracket or other brace.
If I turn preserve_newlines off, then the formatting works except that my newlines are no longer there. How do I set up my config file to get the desired output?
Input
The code looked like this before beautification:
{
someFunction: function() {
},
arr: [{
thing: 1
}, {
one: 2
}],
arr2: [{
thing: 1
},
{
one: 2
}]
}
Desired Output
The code should have looked like this after beautification:
{
someFunction: function() {
},
arr: [{
thing: 1
}, {
one: 2
}],
arr2: [{
thing: 1
}, {
one: 2
}]
}
Actual Output
The code actually looked like this after beautification:
{
someFunction: function() {
},
arr: [{
thing: 1
}, {
one: 2
}],
arr2: [{
thing: 1
},
{
one: 2
}
]
}
Steps to Reproduce
Environment
OS:
Settings
Example:
{
"indent_size": 4,
"indent_char": " ",
"indent_with_tabs": false,
"eol": "\\n",
"end_with_newline": true,
"indent_level": 0,
"preserve_newlines": true,
"max_preserve_newlines": 10,
"space_in_paren": false,
"space_in_empty_paren": false,
"jslint_happy": false,
"space_after_anon_function": false,
"brace_style": "end-expand",
"unindent_chained_methods": false,
"break_chained_methods": false,
"keep_array_indentation": false,
"unescape_strings": false,
"wrap_line_length": 0,
"e4x": false,
"comma_first": false,
"operator_position": "before-newline"
}
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Formatting the Array of objects [duplicate] - Stack Overflow
How do I convert array of Objects into one Object in JavaScript? ... That data structure is what you want to get, not...
Read more >Trailing commas - JavaScript - MDN Web Docs
JavaScript allows trailing commas wherever a comma-separated list of values is accepted and more values may be expected after the last item.
Read more >Everything you wanted to know about arrays - PowerShell
Adding items to an array is one of its biggest limitations, but there are a few other collections that we can turn to...
Read more >Arrays | Elasticsearch Guide [8.5] | Elastic
Arrays of objects do not work as you would expect: you cannot query each object independently of the other objects in the array....
Read more >Semi-structured Data Types - Snowflake Documentation
Snowflake can convert data from JSON, Avro, ORC, or Parquet format to an internal hierarchy of ARRAY, OBJECT, and VARIANT data and store...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@bitwiseman, maybe. I like the idea to separate
brace_style
for code andarray_style
for arrays/objects. Mostly because of JSON formatting.Also when
brace_style: "collapse"
we haveInput
Desired (unchanged)
Actual
I really suffer beacuse of it )