Search code examples
javascriptvisual-studio-codeprettier

Trailing comma after last line in object


I'm using Prettier in VS Code. I noticed that when using format on save, Prettier adds trailing commas on the last line of an object every time.

For example, let's say I had a JS object like this:

obj = {
 hello: 'hello',
 world: 'world'
}

Prettier turns it into this:

obj = {
 hello: 'hello',
 world: 'world',
}

Notice the extra comma after 'world'

Didn't find in the settings an option to fix this.


Solution

  • You can update .prettierrc.json and set option trailingComma to none like:

    {
      "trailingComma" : "none",
      ...
    }