You can update .prettierrc.json and set option trailingComma to none like:
{
"trailingComma" : "none",
...
}
Answer from Zuckerberg on Stack OverflowYou can update .prettierrc.json and set option trailingComma to none like:
{
"trailingComma" : "none",
...
}
Trailing commas are a code-style convention that was introduced to avoid spurious differences in version controls (ie Git).
Imagine you have version controlled code and you have to change it. When you add a new line to your object without the trailing comma, you will have to change the original last line by adding a comma. In version control this then shows up as two changed lines. The code reviewer or a future dev have to check if you effectively changed the last line, or only added the comma.
Zuckerberg's answer shows you how to change it. However, it is better to change your style, than change prettier's style.
Trailing Commas - Yea or Nay?
prettier.trailingComma: es5 removed on save
Trailing-comma "all" stopped working
Trailing comma automatically inserted in JSON files
What are everyone’s thoughts on using trailing commas? I tend to dislike them because it makes my code look messier, but after doing some research it sounds like it might be the way to go due to less complicated diffs and easier reorganization, etc.
JavaScript has allowed trailing commas in array literals since the beginning, and later added them to object literals (ECMAScript 5) and most recently (ECMAScript 2017) to function parameters.
This is a relatively new change in syntax, but the basic idea is that by putting a comma on each line allows for:
- Easier to add an item or re-order items. Before you always had to check the trailing comma and make sure it was present or removed depending on location.
- Removes the need to have one line item be special because it lacks the
,. - Allows for cleaner Git diffs.
You can read up on the full documentation if you like - it goes into further detail: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Trailing_commas
As far as the issue with your chart not displaying, unless you are using a very old browser, a trailing comma should not cause an error/information to not display.
You need to update the configuration of prettier extension.
There are two ways. Below one is mostly used.
Create a
.prettierrcfile at the root of your project and specifying the below configuration.{ "trailingComma": "es5" }
In order to honor the configuration make sure to enable the below setting in vs code configuration.
"prettier.requireConfig": true