Prettier-vscode: Trailing commas setting does not work

Created on 20 Mar 2017  Â·  9Comments  Â·  Source: prettier/prettier-vscode

Using v0.11.0 trailing commas are always added, even when User Settings or Workspace Settings contains "prettier.trailingComma": "none".

locked

Most helpful comment

Found out the Validation Error problem. The hidden message is

Option "trailingComma" must be of type:
    boolean
  but instead received:
    string

  Example:
  {
    "trailingComma": false
  }

This is due to how we handle settings and the trailing comma change between different versions.
By default we pass in "none". Prettier 0.19.0 changed this option from a boolean value to a string value. It may be possible to set your setting explicitly to true/false if you really want to use a version older than 0.19.0.

All 9 comments

Update - issue was I had an old version of prettier installed in node_modules. Is there a way to override the extension so that it uses the version of prettier installed with the extension instead of the project?

I got the "Validation Error" Issue when I installed 0.11.0 version of this extension.
I found a workaround for this, by installing previous version (0.10.1) from URL:

https://esbenp.gallery.vsassets.io/_apis/public/gallery/publisher/esbenp/extension/prettier-vscode/0.10.1/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage

simply rename it to .VSIX and install.

@markbrouch it's not possible to use the bundled version over the project one (with the latest release). I'm curious, why would you prefer to use a different version from the project one?

@jupiterzzz What do you mean by Validation Error ?

I was on [email protected] and after upgrading to the latest prettier-vscode formatting stopped working completely. After upgrading my local prettier to 0.22.0 it all started to work again as expected.

@CiGit I also experienced what @jupiterzzz described – after upgrading prettier-vscode while on an old version of prettier VSCode would display a generic looking "Validation Error" banner with no context as to what caused the error – it was strange. Still not sure what caused the error but again, upgrading local prettier seemed to resolve the issue.

Found out the Validation Error problem. The hidden message is

Option "trailingComma" must be of type:
    boolean
  but instead received:
    string

  Example:
  {
    "trailingComma": false
  }

This is due to how we handle settings and the trailing comma change between different versions.
By default we pass in "none". Prettier 0.19.0 changed this option from a boolean value to a string value. It may be possible to set your setting explicitly to true/false if you really want to use a version older than 0.19.0.

@CiGit good point - don't really need to use different version than what's in project. Just had a weird circumstance where I couldn't update project right away but wanted to try out a newer version of Prettier.

We should close this in favour of #55, yeah? @CiGit

Seems fair enough

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FlorianWendelborn picture FlorianWendelborn  Â·  3Comments

peralmq picture peralmq  Â·  3Comments

bajtos picture bajtos  Â·  4Comments

sebastijandumancic picture sebastijandumancic  Â·  4Comments

Glinkis picture Glinkis  Â·  4Comments