首页 > 解决方案 > 更漂亮的 VSCode。单引号设置,但总是将其更改为双引号

问题描述

  1. Prettier在 VSCode 中使用扩展。

  2. 设置Single Quote为单。

  3. format onSave设置为真。

仍然...... 当我点击保存时,单引号被转换为双引号......

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


此外...

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

仍然...... 当我点击保存时,单引号被转换为双引号......

为什么?

标签: visual-studio-codeprettier

解决方案


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

当 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

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


推荐阅读