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.

How to stop Vuter from removing trailing (dangling) commas

See original GitHub issue
  • I have searched through existing issues
  • I have read through docs
  • I have read FAQ

Info

  • Platform: macOS
  • Vetur version: 0.21.0
  • VS Code version: 1.34.0

Problem

When I save a .vue file all trailing commas will be removed. [https://i.imgur.com/cKMd2UA.gif

I’ve tried multiple Vetur › Format › Default Formatter: HTML settings and js-beautify-html get the closest to how I like to write code. (please don’t write comments telling me why trailing commas are bad)

Reproducible Case

  1. Get vscode
  2. install Vuter
  3. Save a .vue file with trailing commas

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

15reactions
welenofskycommented, Jun 15, 2019

I am having this exact same issue. I use prettier+eslint (with .eslintrc) and prettier works just find on .js files and respects eslint rules. But for some reason vetur, even with the "vetur.format.defaultFormatter.js": "prettier-eslint", setting on, removes my trailing commas. The only fix I found is to manually set prettier config options. I do feel this is some sort of bug because the only thing vetur seems to get wrong is the trailing commas. Otherwise it seems to format just fine.

{
  "vetur.format.defaultFormatterOptions": {
    "prettier": {
      "trailingComma": "all"
    }
  }
}
8reactions
yoyo930021commented, Jun 9, 2019

You can set VSCode setting.

"vetur.format.defaultFormatter.js": "prettier",
"vetur.format.defaultFormatter.ts": "prettier"

if use prettier, you can set prettier config. .prettierrc at project root.

{
  trailingComma: 'none'
}

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to turn off the prettier trailing comma in VS Code?
Select none for the prettier trailing comma. ... Select a piece of TypeScript, press Ctrl + Shift + F and the trailing commas...
Read more >
comma-dangle - ESLint - Pluggable JavaScript Linter
Trailing commas simplify adding and removing items to objects and arrays, since only the lines you are modifying must be touched. Another argument...
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 >
Code Syntax Style: Trailing Commas - JetBrains Rider
Your version control diffs are cleaner when you add a new item in the end of the list. ... JetBrains Rider syntax style...
Read more >
Best practices for using trailing commas in JavaScript
A trailing comma, also known as a dangling or terminal comma, ... where you can safely add a trailing comma to the end...
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