Enum trailing commas get included on the same line as the semicolon ending the line
See original GitHub issueEnums that get split across multiple lines can lead to the last enum in the series having a , ;
on the last line. If a ,
is specified after the last enum value that should be used as an indicator to create another newline and to place the ;
on that newline, or the ,
should be dropped entirely and it should just become a ;
after the last enum value.
I could see arguments for either option, but I’d prefer placing the ;
on a newline as this preserves version control history for the line with the previous enum value when a new value is eventually added.
Input:
enum MyEnum {
AAAAAAAA("aaaaaa"),
BBBBBBBBBBB("bbbbbbbbbb"),
CCCCCCCCCC("ccccccccc"),
DDDDDDDDD("ddddddddddddddddddddddddd"),
EEEEEEE("eeeeeeeeee"),
;
}
Output:
enum MyEnum {
AAAAAAAA("aaaaaa"),
BBBBBBBBBBB("bbbbbbbbbb"),
CCCCCCCCCC("ccccccccc"),
DDDDDDDDD("ddddddddddddddddddddddddd"),
EEEEEEE("eeeeeeeeee"), ;
}
Expected Output:
enum MyEnum {
AAAAAAAA("aaaaaa"),
BBBBBBBBBBB("bbbbbbbbbb"),
CCCCCCCCCC("ccccccccc"),
DDDDDDDDD("ddddddddddddddddddddddddd"),
EEEEEEE("eeeeeeeeee"),
;
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Trailing comma after last line in object - Stack Overflow
When you add a new line to your object without the trailing comma, you will have to change the original last line by...
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. This...
Read more >Code Syntax Style: Trailing Commas - JetBrains Rider
When multiple items are separated by the comma (object, array, and collection initializers, as well as enums and switch expressions) , C# allows...
Read more >Trailing comma in constructor initializer list - Google Groups
Yes, I have seen the workaround of putting commas on the next line, but this doesn't match some coding styles. class dword_table
Read more >Use Punctuation, Comma, Semicolon in JavaScript
Omitting the semicolon means JavaScript is putting a semicolon automatically at the end of the line. “Automatic Semicolon Insertion” (ASI) is the name...
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
Haha, I saw that too! The update to Prettier 2.0 will be in the next release, with the default to trailingComma=“always”
Probably this weekend. I’d like to wrap a couple of things in it, but I could postpone them for a next release