[英]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?我正在使用 VS 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.
我知道这个功能是在一月份添加的,但我在 PR 或问题中没有提到如何将它添加到设置中。
prettier.semi (default: true)
prettier.semi (默认: 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)
是否在每行的末尾添加分号(semi:true),或者仅在可能导致 ASI 失败的行的开头添加分号(semi:false)
You have to set prettier.semi
to false
.您必须将
prettier.semi
设置为false
。
To change prettier settings see ,要更改更漂亮的设置,请参阅,
Like all other vscode settings
像所有其他 vscode 设置一样
note: These settings are prefixed with prettier.
注意:这些设置以 prettier 为前缀。
Open settings.json
file*.打开
settings.json
文件*。
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.使用 Ctrl+P 在 Vs Code 中搜索文件。 *
*
In your prettier
config file.在你
prettier
的配置文件中。 Add the following添加以下内容
semi: false
prettier --write --no-semi your_file
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.