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.

Why does Prettier turn trailingComma on?

See original GitHub issue

The trailingCommas option is based on esnext when Prettier is turned on. But why is this the case? Neither XO nor Prettier allow trailingComma by default.

https://prettier.io/docs/en/options.html#trailing-commas

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

5reactions
sindresorhuscommented, Mar 5, 2018

The trailing comma makes git diff more readable and allow to find which git commit modified which property in an array or object more accurately, so it might make sense to enable it when esnext is true.

I’m still not personally sold on trailing commas and it would be a pretty controversial change. I kinda agree with the code manipulation argument, but it’s never bothered me very much. The Git argument is just trying to fix the problem in the wrong place. The solution there is better Git diffs.

1reaction
kevvacommented, Mar 2, 2018

Currently, it’s enabled when esnext is true, disabled when it’s false

Sorry, I meant the other way around. But the question still stands, why enable it at all for prettier when it’s always false in xo?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does prettier put the trailing comma on its own and give ...
"trailingComma": "es5" says that the trailing comma is invalid after the last property. "airbnb-base" might contain a rule which conflicts with ...
Read more >
Options - Prettier
This option allows you to switch between the default behavior ( auto ) and disabling this feature entirely ( off ). Valid options:...
Read more >
VS Code Prettier Setting: prettier.trailingComma - YouTube
Your browser can 't play this video. Learn more. Switch camera.
Read more >
Code Syntax Style: Trailing Commas - JetBrains Rider
Some developers consider the trailing comma redundant, but it has a number of benefits, especially in multi-line declarations:.
Read more >
Start Using Prettier The Right Way - DEV Community ‍ ‍
Starting in es5 we are allowed to write trailing commas in JavaScript (note they are not allowed in JSON). I love this feature...
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