当我在Vue组件上执行格式化文档命令时。vue文件VSCode将所有单引号字符串替换为双引号字符串。

在我的具体情况下,该规则与要求单引号的electronic -vue lint配置冲突。

我没有安装更漂亮的扩展(没有更漂亮。singleQuote在我的设置)

如何定制VSCode来避免这种情况?


当前回答

正确解决方法:

我在我的主根项目中添加了. pretierrc .js文件 和写

module.exports = {
    singleQuote: true
  };

其他回答

在.prettierrc中添加

{
  "arrowParens": "avoid",
  "semi": false,
  "singleQuote": true
}

对于默认使用.editorconfig文件的项目。格式化程序将忽略设置中的规则并使用.editorconfig中的规则,然后您可以:

删除.editorconfig文件,并使用VSCode设置。 根据您的文件类型,在.editorconfig文件中添加quote_type = single。也可以将quote_type value设置为double或auto。

使用这个扩展。

https://marketplace.visualstudio.com/items?itemName=BriteSnow.vscode-toggle-quotes

cmd ' (ctrl '在win/Linux上)将在' ' '中循环

正确解决方法:

我在我的主根项目中添加了. pretierrc .js文件 和写

module.exports = {
    singleQuote: true
  };

这对我来说很管用: 尝试右键单击当前文档 然后选择format document with, 并为文档选择自己的格式扩展。 :)