question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

YAML trailing comma optional

See original GitHub issue

Prettier 1.19.1

Input:

`[update_vars, ]`

Output:

`[update_vars]`

Expected behavior:

So instead of: [update_vars] we would get tags: [update_vars, ]. Right now trailing commas are removed by the formatter. An option to disable the removal would already be helpful, then I could set them manually. I like trailing commas everywhere, as they remind me of the type I am dealing with.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
alexander-akaitcommented, Jan 28, 2020

Please use issue template otherwise the issue as closed

0reactions
Rich-Farmbroughcommented, Aug 2, 2021

No repro:

Prettier 1.19.1 Playground link

--parser yaml

Input:

`[update_vars, ]`

Output:

`[update_vars, ]`

No repro: The playground link you give currently errors. This link however does seem to be a repro case. (Not that I like trailing commas.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

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 >
Parsing "JSON" containing trailing commas - Stack Overflow
JSON is a subset of YAML, so a YAML parser should parse most JSON. YAML's grammar allows trailing commas in sequences.
Read more >
Code Syntax Style: Trailing Commas - ReSharper - JetBrains
When multiple items are separated by the comma (object, array, and collection initializers, as well as enums and switch expressions) , C# allows ......
Read more >
Best practices for using trailing commas in JavaScript
A trailing comma, also known as a dangling or terminal comma, is a comma symbol that is typed after the last item of...
Read more >
How to Allow Trailing Commas (Comma-Dangle) With ...
You may require trailing commas in all places of your code. Or you can require comma-dangle in multiline statements. For example, the "only- ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found