quotes
This rule enforces consistent use of quotes for attribute values ('
or "
).
How to use
module.exports = {
rules: {
"@html-eslint/quotes": "error",
},
};
Rule Details
Options
This rule has two options, a string option and an object option.
- String option (quote style):
"double"
(default) enforces the use of double quotes ("
)"single"
enforces the use of single quotes ('
)
- Object option:
"enforceTemplatedAttrValue": false
(default) does not enforce quote style inside template expressions"enforceTemplatedAttrValue": true
enforces quote style inside templated attribute values, which also means bare templated attributes are disallowed
"double"
Examples of incorrect code for this rule with the default
"double"
option:
<div id='foo'></div>
Examples of correct code for this rule with the default
"double"
option:
<div id="foo"></div>
<div id='containing "double" quotes'></div>
Examples of incorrect code for this rule with the
"double"
and enforceTemplatedAttrValue: true
:
html`<div id=${value}></div>`;
html`<div id='${value}'></div>`;
Examples of correct code for this rule with the
"double"
and enforceTemplatedAttrValue: true
:
html`<div id="${value}"></div>`;
"single"
Examples of incorrect code for this rule with the
"single"
option:
<div id="foo"></div>
Examples of correct code for this rule with the default
"single"
option:
<div id='foo'></div>
<div id="containing 'single' quotes"></div>
Examples of incorrect code for this rule with the
"single"
and enforceTemplatedAttrValue: true
:
html`<div id=${value}></div>`;
html`<div id="${value}"></div>`;
Examples of correct code for this rule with the
"single"
and enforceTemplatedAttrValue: true
:
html`<div id='${value}'></div>`;