Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove semicolons in prettier?

I am using the VS Code prettier plugin to format my code, how can I add a setting to not add or remove semicolons when I format my code? I know that this feature was added in January but I found no mention in the PR or issue of how to add it to settings.

like image 468
Achyut Rastogi Avatar asked Jul 30 '17 21:07

Achyut Rastogi


People also ask

Do you have to use semicolons in JavaScript?

JavaScript does not require semicolons (other than the one exception you saw earlier). This is because JavaScript is clever and it can add the semicolons where needed automatically. This happens behind the scenes and you will not notice it. This process is called Automatic Semicolon Insertion (ASI).

Does prettier work with TypeScript?

Using the above config, Prettier will not format TypeScript code on paste or save but it will format code on paste or save for any other language that it understands.


2 Answers

From the readme:

prettier.semi (default: true)

Whether to add a semicolon at the end of every line (semi: true), or only at the beginning of lines that may introduce ASI failures (semi: false)

You have to set prettier.semi to false.

To change prettier settings see,

Like all other vscode settings enter image description here

note: These settings are prefixed with prettier.

like image 187
Francisco Avatar answered Sep 22 '22 17:09

Francisco


Open settings.json file*.

Add this lines to format your code on save and to remove semicolons on save:

    "editor.formatOnSave": true,      "prettier.semi": false, 




Use Ctrl+P to search for file in Vs Code.*

like image 38
Qui-Gon Jinn Avatar answered Sep 23 '22 17:09

Qui-Gon Jinn