更漂亮的 VSCode。设置单引号,但始终将其更改为双引号

GN.*_*GN. 4 visual-studio-code prettier

  1. 在 VSCode 中使用Prettier扩展。

  2. 设置Single Quote为单人。

  3. format onSave设置为 true。

还是... 当我点击保存时,单引号会转换为双引号..

为什么?为什么?为什么?为什么?


此外...

  1. 我已将 eslint 设置为使用单引号
  2. 我什至从 VSCode 中删除了 eslint 扩展。
// in .eslint file
"quotes": [2, "single", { "avoidEscape": true }],
Run Code Online (Sandbox Code Playgroud)

还是... 当我点击保存时,单引号会转换为双引号..

为什么?

GN.*_*GN. 6

我已经追踪到问题的根源。

当 VSCode 尝试重新格式化文本时,似乎会检查配置级别format on save

  • 更漂亮的扩展配置
  • .eslintrc
  • .editorconfig

我仍然不确定他们按什么顺序运行,因此谁有最终决定权。

但就我而言,.editorconfig问题是一个非常基本的问题。删除这个文件就解决了。

# EditorConfig https://editorconfig.org/

root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_size = 2
indent_style = space
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
Run Code Online (Sandbox Code Playgroud)

在上面的文件中根本没有提到间距首选项。所以我假设双引号有一些默认值。

  • 现在有点旧了,但我能够更新`.editorconfig`以包含单引号而不是删除它(在我的情况下是我的雇主要求的):`quote_type = single` (2认同)