Enforce the consistent use of double or single quotes.
- ⭐️ This rule is included in
plugin:@peggyjs/recommended
preset.- ✒️ This rule will fix all errors it finds.
Both single quotes ('
) and double quotes ("
) are valid in a Peggy grammar,
either for string literals, or for display names for rules.
👎 Examples of incorrect code for this rule:
// eslint @peggyjs/quotes: ["error", "double"]
Foo = 'bar'
// eslint @peggyjs/quotes: ["error", "double"]
Foo 'Frequently Observed Ocelot' = "bar"
👍 Examples of correct code for this rule:
// eslint @peggyjs/quotes: ["error", "double"]
import {"boo" as bar} from "bar.js"
Foo "More Ocelots" = "bar" / boo
// eslint @peggyjs/quotes: ["error", "single"]
Foo 'Crepuscular' = "bar"
// eslint @peggyjs/quotes: ["error", { style: "double", avoidEscape: true }]
Foo 'More "Ocelots"' = 'Where is the "bar"?'
// eslint @peggyjs/quotes: ["error", { style: "double", avoidEscape: false }]
Foo "More \"Ocelots\"" = "Where is the \"bar\"?"
The first parameter is the quoting style, either "single" or "double" (the default), or an object with the keys "style" and "avoidEscapes". If "avoidEscapes" is true (the default), you can use the non-preferred quoting style to avoid having to backslash-escape your preferred quotes. If false, there are no exceptions.
{
"rules": {
"@peggyjs/quotes": ["error", { style: "double", avoidEscape: true }]
}
}