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

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

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

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


当前回答

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

其他回答

我在vscode中也有同样的问题。只需在根目录中创建一个. pretierrc文件,并添加以下json。 对于单引号添加:

{
  "singleQuote": true
}

对于双引号添加:

  {
      "singleQuote": false
  }

试试这些解决方案中的一种

在vscode设置。Json文件添加此条目 ”漂亮。singleQuote”:真正的 在vscode中,如果您有.editorconfig文件,在根符号[*]quote_type = single下添加这一行 在vscode中,如果你有. pretierrc文件,添加这行

{
    "singleQuote": true,
    "vetur.format.defaultFormatterOptions": {
        "prettier": {
            "singleQuote": true
        }
    }
}

从vuejs/vetur发行页面https://github.com/vuejs/vetur/issues/986# 这个解决方案对我很有效。

在vcodes设置中。Json文件添加此条目

"vetur.format.defaultFormatterOptions": {
    "prettier": {
        "singleQuote": true
    }
},

首先,安装Prettier扩展。在项目的根目录下创建一个. pretierrc配置文件。并添加如下配置:

{ trailingComma:“es5”, singleQuote:真的, jsxSingleQuote:真的, printWidth: 100, tabWidth: 2, “春天”:真的, “endOfLine”:“auto” 的

撰写本文时(2022年6月):

请考虑.editorconfig在最后覆盖所有其他配置,找到该文件(很可能在项目的根目录上),编辑它并添加以下内容:

[*]
quote_type = single