Reputation: 9909
Using Prettier
extension in VSCode.
Have the Single Quote
set to single.
format onSave
is set to true.
Still... When I hit save, single quotes are converted to double..
WHY? WHY? WHY? WHY?
In addition...
// in .eslint file
"quotes": [2, "single", { "avoidEscape": true }],
Still... When I hit save, single quotes are converted to double..
Upvotes: 4
Views: 5388
Reputation: 31
I have the same problem. make sure if prettier is using any other config that could override it's own settings in VSCode. most likely to be .editorconfig
there's two options
.editorconfig
Add this code in .editorconfig
quote_type = single
.editorconfig
In .vscode/settings.json
, add this code.
"prettier.useEditorConfig": false, // tell prettier to don't use .editorconfig
"prettier.singleQuote": true, // force single quote
Upvotes: 3
Reputation: 9909
I've traced the source of the problem.
It appears there are levels of configuration that will be checked when VSCode attempts to reformat the text when format on save
is checked.
.eslintrc
.editorconfig
I'm still not sure in what order they run in, thus who has the final say.
But in my case, a VERY basic .editorconfig
was the problem. Deleting this file fixed it.
# 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
In the file above there is no mention of spacing prefs at all. So I'm assuming there are some defaults to double quotes.
Upvotes: 6