【问题标题】:Prettier VSCode. Single Quotes set, yet ALWAYS changes it to double更漂亮的 VSCode。单引号设置,但总是将其更改为双引号
【发布时间】:2020-06-17 19:15:28
【问题描述】:
  1. 在 VSCode 中使用 Prettier 扩展。

  2. Single Quote 设置为单个。

  3. format onSave 设置为 true。

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

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


另外...

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

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

为什么?

【问题讨论】:

    标签: visual-studio-code prettier


    【解决方案1】:

    我已经找到问题的根源了。

    当检查format on save 时,当VSCode 尝试重新格式化文本时,似乎有一些配置级别将被检查。

    • 更漂亮的扩展配置
    • .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
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-26
      • 1970-01-01
      • 1970-01-01
      • 2019-08-21
      • 2020-03-30
      • 1970-01-01
      • 2020-10-17
      • 1970-01-01
      相关资源
      最近更新 更多