fumeng
fumeng

Reputation: 1830

Problems with Prettier config in vscode

I have a standard Angular app and am trying to disable trailing commas in Prettier. So I go into vscode settings (both user and workspace) and set trailing commas to none:

enter image description here

I also have an .editorconfig file and tslint.json files. The tslint.json file has trailing commas set to false. Lastly, I am using the Prettier Formatter for VSCode extension. Anyway, the trailing commas still appear unless I put this in package.json:

"prettier": {
    "bracketSpacing": true,
    "singleQuote": true,
    "trailingComma": "none"
 }

How come if my preferences are set in VSCode settings that I then have to add this snippet of redundant code in the package.json file?

Thanks for any helpful tips.

Upvotes: 0

Views: 1523

Answers (3)

intropedro
intropedro

Reputation: 2804

Remove "trailing-comma" in yout tslint config.

Upvotes: 1

Ondie
Ondie

Reputation: 151

Is your default formatter set to prettier? Or the default Typescript and Javascript language features?

You can check this by opening a typescript file and pressing ctrl + shift + p (for windows)

and looking for format document with and looking which is the default.

Upvotes: 1

Matus Jurika
Matus Jurika

Reputation: 305

Maybe you have to set "trailing-comma": true in tslint.json. Anyway good practice is to install https://github.com/prettier/tslint-config-prettier so you don't get conflicts.

Upvotes: 1

Related Questions