Awkward formatting of elisions in array assignment patterns
See original GitHub issuePrettier 1.19.1 Playground link
--parser babel
Input:
switch (LTocurrenceCount) {
case 1:
itemToAddToFinalResult = item;
break;
case 2: {
const [, secondDuplicateIdx] = mappingWithPossibleDoubledInputs
.map((item1, idx1) => (item1.labelText === labelText ? idx1 : undefined))
.filter(Boolean);
if (idx === secondDuplicateIdx) {
itemToAddToFinalResult = give_special_treatment(item);
} else itemToAddToFinalResult = item;
break;
}
default:
console.error("more than 2 occurences!");
}
Output:
switch (LTocurrenceCount) {
case 1:
itemToAddToFinalResult = item;
break;
case 2: {
const [
,
secondDuplicateIdx
] = mappingWithPossibleDoubledInputs
.map((item1, idx1) => (item1.labelText === labelText ? idx1 : undefined))
.filter(Boolean);
if (idx === secondDuplicateIdx) {
itemToAddToFinalResult = give_special_treatment(item);
} else itemToAddToFinalResult = item;
break;
}
default:
console.error("more than 2 occurences!");
}
Expected behavior:
I would expect the const [, secondDuplicateIdx]
part not to break into muplitple lines.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Odd splitting when destructuring · Issue #3227 · prettier/prettier ...
Awkward formatting of elisions in array assignment patterns #7089. Open. @thorn0 thorn0 added the area:destructuring label on May 6, 2020.
Read more >The OCaml system release 4.06 - The Caml language
This manual documents the release 4.06 of the OCaml system. It is organized as follows. • Part I, “An introduction to OCaml”, ...
Read more >CoffeeScript
CoffeeScript is a little language that compiles into JavaScript. Underneath that awkward Java-esque patina, JavaScript has always had a gorgeous heart.
Read more >typescript-cheatsheet - GitHub Pages
const hobbies: string[] = ['Programming', 'Cooking'];. If no types are declared, TypeScript will automatically assign a type depending on the types of the...
Read more >ECMA-262 Edition 5.1 - ECMAScript Language Specification
15.4.1 The Array Constructor Called as a Function; 15.4.2 The Array ... array manipulation functions, support for the JSON object encoding format, ...
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 Free
Top 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
Array with holes
Prettier 1.19.1 Playground link
Input:
Output:
Expected:
Maybe keep holes after the first one, like input.
@brodybits Please add Expected because to me it’s not clear what’s wrong with the current output.