In VSCode, whenever I save a file, Prettier changes all single quotes to double quotes. I want to keep this behaviour for SCSS and CSS files, but want to change it for JavaScript and JSON files.
I am aware of the setting "prettier.singleQuote": true, but this will change double quotes to single quotes in all file types.
How can I activate single quote only for JavaScript and JSON files and keep double quote for SCSS and CSS files?
There is no difference between single or double quotes. You can simply use single quotes or double quotes, that is simply up to you, but my recommendation is to use double quotes. Especially when you will want to add some JS, you will find it very useful.
Use a Prettier configuration file in your project folder: .prettierrc
Inside your config file use Prettier overrides: https://prettier.io/docs/en/configuration.html#configuration-overrides
So in your case this example config should work (.prettierrc):
{
"singleQuote": true,
"overrides": [
{
"files": ["**/*.css", "**/*.scss", "**/*.html"],
"options": {
"singleQuote": false
}
}
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With