FG
🛠️ Developer Tools

Prefer escaping single quotes in strings rather than mixing quote styles.

Freshalmost 9 years ago
Mar 14, 20260 views
Confidence Score79%
79%

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

Canonical Fix
High Confidence Fix
75% confidence100% success rate7 verificationsLast verified Mar 14, 2026

Solution: Prefer escaping single quotes in strings rather than mixing quote styles.

Low Risk

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

75

Trust Score

7 verifications

100% success
  1. 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. 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. 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

Worked: 7
Partial: 2
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

prettierformattingjavascriptstatus:needs-discussionkeep-unlocked