New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Single quotes are sometimes replaced with double quotes even when "prettier.singleQuote: true" is specified #2338
Comments
This is as intended. From https://github.com/prettier/prettier/tree/21733e441dc01f7d85b483edee92b7e7507bfd9a#quotes:
Maybe we should change the preceding description "Use single quotes instead of double quotes." to something like "Prefer single quotes over double quotes.". |
FYI, this is how Prettier handles quotes:
See also #973. |
The reason I reported is because prettier modifies the code to use double quotes, which results in an eslint error. Is there any way this can be avoided? |
Yes! Disable the ESLint rule. It gains you nothing. |
Ahh, good point! Thanks for the advice and the great tool. :) |
Instead of disabling it entirely, you can use avoidEscape option (http://eslint.org/docs/rules/quotes). |
@oliamb Even if you do, the rule still doesn't gain you anything, does it? It only makes ESLint take a little longer to run? |
I have at least one interesting use case that can justify this rule. When using string constants, it is useful to be able to search and replace using NB: let's maybe not dive into whether it is a good idea to use string constants ;-) |
Code style is all about consistency, it doesn't need to "gain something" beyond consistency for it to be useful. Still, using |
Also check: prettier/prettier#2338 when Prettier was using double quotes, instead single quotes (as in config: `"singleQuote": true`)
My .prettierrc looks :
and it works perfect, I had the problem that I wanted to format my typescript clases but when I was using Prettier it always changed the single quote to double, I only modify the parser to Typescript. |
FYI the tslint rule for avoid escape is here: |
I am using the vscode extension and am having an issue with the prettier.singleQuote setting. The only settings I have customized are:
Specifically, when prettier is run on a string like this:
the string is changed to:
The expected behavior (I think) is to continue using single quotes since the setting prohibits the use of double quotes.
My temporary workaround is to change the string to:
The text was updated successfully, but these errors were encountered: