当我在Vue组件上执行格式化文档命令时。vue文件VSCode将所有单引号字符串替换为双引号字符串。
在我的具体情况下,该规则与要求单引号的electronic -vue lint配置冲突。
我没有安装更漂亮的扩展(没有更漂亮。singleQuote在我的设置)
如何定制VSCode来避免这种情况?
当我在Vue组件上执行格式化文档命令时。vue文件VSCode将所有单引号字符串替换为双引号字符串。
在我的具体情况下,该规则与要求单引号的electronic -vue lint配置冲突。
我没有安装更漂亮的扩展(没有更漂亮。singleQuote在我的设置)
如何定制VSCode来避免这种情况?
当前回答
试试这些解决方案中的一种
在vscode设置。Json文件添加此条目 ”漂亮。singleQuote”:真正的 在vscode中,如果您有.editorconfig文件,在根符号[*]quote_type = single下添加这一行 在vscode中,如果你有. pretierrc文件,添加这行
{
"singleQuote": true,
"vetur.format.defaultFormatterOptions": {
"prettier": {
"singleQuote": true
}
}
}
其他回答
quote_type = single
将此添加到.editorconfig中
# EditorConfig is awesome: https://EditorConfig.org
# top-most EditorConfig file
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false
quote_type = single
我在控制毛边和更漂亮的排版方面有很多问题。我有自己的规矩,让自己看起来更漂亮
"prettier/prettier": [
"error",
{ "singleQuote": true, "trailingComma": "none" }
],
和。prettierrc文件中的规则
{
"tabWidth": 2
}
但是我的.prettierrc文件没有得到处理。我的解决方案是在开发依赖中安装prettier作为一个包。所以对我有效的解决方案是安装所有这些包eslint-config-prettier eslint-plugin-prettier and prettier。
这对我来说很管用: 尝试右键单击当前文档 然后选择format document with, 并为文档选择自己的格式扩展。 :)
正确解决方法:
我在我的主根项目中添加了. pretierrc .js文件 和写
module.exports = {
singleQuote: true
};
看起来这个问题有一个漏洞:更漂亮的漏洞
以上方法对我都没用。 唯一有效的是,在package.json中添加这行代码:
"prettier": {
"singleQuote": true
},