如何删除漂亮的分号?

我使用 VS 代码更漂亮的插件格式化我的代码,如何添加一个设置,不添加或删除分号时,我格式化我的代码?我知道这个功能是在一月份添加的,但我没有发现在公关或问题中提到如何添加到设置。

70770 次浏览

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.

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.*

In your Prettier settings. Add the following

semi: false
  • If you want to format your file using CLI, then
prettier --write --no-semi your_file