I am looking for a way to change the double quotes (default behavior) to single quotes. I've read the docs and tried to search online but the normal way of doing it does not seem to work.
I've adapted the package.json
in various ways, none have worked and this is my latest try:
"prettier": {
"singleQuote": true
},
I don't know how to do it. The documentation is pretty bad on this one. They mention configs as well but I wouldn't know how to place them either.
Someone with a similar question: WebStorm: configure Prettier to use tabs?
From the main menu, select File | New Projects Setup | Settings/Preferences for New Projects. In the dialog that opens, go to Languages & Frameworks | JavaScript | Prettier. Use the On code reformatting and On save checkboxes to specify the actions that will trigger Prettier.
Go to File -> Settings | Preferences. Choose Editor -> Code Style -> TypeScript. Select 'Punctuation' tab. Change: Use 'double' quotes to Use 'single' quotes .
You can also configure WebStorm to run Prettier on save (Cmd+S/Ctrl+S) or use it as the default formatter (Opt+Cmd+L/Ctrl+Alt+L). For this, open Preferences / Settings | Languages & Frameworks | JavaScript | Prettier and tick the corresponding checkbox: On save and/or On 'Reformat Code' action.
WebStorm allows importing code style preferences from prettier. For example:
press Yes to get settings applied - they will be used when you reformat your code with Code | Reformat code, as well as when running Reformat with Prettier action
Edit: Due to https://github.com/prettier/prettier/pull/2434 fix, Prettier (even global!) uses configuration file nearest to current file (up the directory tree) when formatting.
So, you can install it globally and configure it in your project, by adding the corresponding .prettierrc
file or "prettier"
section in project package.json
.
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