quotes
JavaScript allows strings to be defined with double quotes, single quotes, or backticks. This rule enforces consistency.Rule Type: Layout
Fixable: Yes (automatically fixable)
Deprecated: Consider using Prettier
Fixable: Yes (automatically fixable)
Deprecated: Consider using Prettier
Rule Details
This rule enforces consistent use of quotes throughout your codebase.Options
String Option
"double"(default) - Require double quotes"single"- Require single quotes"backtick"- Require backticks
Object Options
"avoidEscape": true- Allow other quotes to avoid escaping"allowTemplateLiterals": true- Allow template literals
Examples
"double"
Incorrect:
"single"
Incorrect:
"backtick"
Incorrect:
avoidEscape Option
Allow other quote styles to avoid escaping:allowTemplateLiterals Option
Allow template literals alongside your preferred quote style:This doesn’t disallow ALL template literals - only simple ones. Template literals with expressions or newlines are always allowed.
Configuration Examples
Common Patterns
Avoiding Escaping
JSX
For JSX attributes, ESLint uses thejsx-quotes rule:
Template Literals
When Not to Use It
Disable if:- You use Prettier or another formatter
- You don’t care about quote consistency
- Your team hasn’t agreed on a quote style