当我在Vue组件上执行格式化文档命令时。vue文件VSCode将所有单引号字符串替换为双引号字符串。
在我的具体情况下,该规则与要求单引号的electronic -vue lint配置冲突。
我没有安装更漂亮的扩展(没有更漂亮。singleQuote在我的设置)
如何定制VSCode来避免这种情况?
当我在Vue组件上执行格式化文档命令时。vue文件VSCode将所有单引号字符串替换为双引号字符串。
在我的具体情况下,该规则与要求单引号的electronic -vue lint配置冲突。
我没有安装更漂亮的扩展(没有更漂亮。singleQuote在我的设置)
如何定制VSCode来避免这种情况?
当前回答
After struggling with the issue I found a useful tool. If you click on the Prettier word in the right lower corner you will get the Output window opened. In that window once you run formatting (in my case it is Alt + Shift + F) you will see all the configurations which prettier will use to format the document. So, we can clearly see that specifying the prettier in the prettier.singleQuote is wrong. It should just be singleQuote. Hence, having the .prettierrc file in my user root folder with the following contents produced the desired result:
{
"trailingComma": "none",
"useEditorConfig": false,
"singleQuote": true
}
此外,请确保已安装了Prettier扩展。
其他回答
它为我工作检查单引号在更漂亮的以及 tslint。autoFixOnSave设为true
这对我来说很管用: 尝试右键单击当前文档 然后选择format document with, 并为文档选择自己的格式扩展。 :)
对我来说,这两种选择都解决了问题:
通过在。prettierrc - "singleQuote": true中添加 或者在包中添加以下内容。json - - - > "漂亮":{ “singleQuote”:真的 }
虽然我也尝试添加.prettierrc.js和有以下
module。导出= { singleQuote: true };
这并没有起作用。
对我来说唯一有效的方法是: 并且仅适用于Angular项目:
开始你的项目吧。”Editorconfig "文件,并粘贴'quote_type = single'。 希望这对你也有用。
我使用的是typescript,对我来说,它在更漂亮的设置下检查“Tslint集成”标志得到了解决(在vscode首选项中):