Prefer escaping single quotes in strings rather than mixing quote styles.
Problem
Currently, this string (`'\'editing\' flag'`) is automatically converted to `"'editing' flag"` - is there a way to prefer escaped single quotes? The value of this preference is that it promotes a consistent code style. In my opinion, there should be an option to leave the single quotes alone. What do you guys think? Edit: I've encountered this issue in my Jest tests and I have the --single-quote option set.
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: Prefer escaping single quotes in strings rather than mixing quote styles.
I think that consistency is more important than having to write/read another character. Mixing quote types makes you think if you're going to use a quote type same as the enclosing one inside the string or not. Escaping characters allows you to have that comfort of not having to think too much about your strings - you just get used to escaping all single quotes. @SimenB I wouldn't mind if it wa
Trust Score
7 verifications
- 1
I think that consistency is more important than having to write/read another cha
I think that consistency is more important than having to write/read another character. Mixing quote types makes you think if you're going to use a quote type same as the enclosing one inside the string or not.
- 2
Escaping characters allows you to have that comfort of not having to think too m
Escaping characters allows you to have that comfort of not having to think too much about your strings - you just get used to escaping all single quotes.
- 3
@SimenB I wouldn't mind if it was behind an option. Also, I understand that Pret
@SimenB I wouldn't mind if it was behind an option. Also, I understand that Prettier is pretty opinionated, but come on, mixing quote types isn't the industry standard and it won't be anytime soon... :D
Validation
Resolved in prettier/prettier GitHub issue #973. Community reactions: 32 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep