` :ng: `
` `
`)">
Skip to content

lodash-template/attribute-value-quote

enforce quotes style of HTML attributes. (ex. 🆗 <div class="abc"> 🆖 <div class='abc'> <div class=abc>)

  • ⚙️ This rule is included in "plugin:lodash-template/recommended-with-html" and "plugin:lodash-template/all".
  • 🔧 The --fix option on the command line can automatically fix some of the problems reported by this rule.

Rule Details

This rule enforces the quotes style of HTML attributes.

html
<% /* eslint "lodash-template/attribute-value-quote": "error" */ %>
<!-- ✓ GOOD -->
<img src="./logo.png">

<!-- ✗ BAD -->
<img src=
'./logo.png'
>
<img src=
./logo.png
>

Options

json
{
  "lodash-template/attribute-value-quote": ["error", "double" | "single" | "either" | "prefer-double"]
}
  • "double" ... requires double quotes.
  • "single" ... requires single quotes.
  • "either" ... requires double quotes or single quotes.
  • "prefer-double" (default) ... requires double quotes or single quotes. if do not need escape double quotes, requires double quotes.

Examples for this rule with "single" option:

html
<% /* eslint "lodash-template/attribute-value-quote": ["error", "single"] */ %>
<!-- ✓ GOOD -->
<img src='./logo.png'>

<!-- ✗ BAD -->
<img src=
"./logo.png"
>
<img src=
./logo.png
>

Examples for this rule with "either" option:

html
<% /* eslint "lodash-template/attribute-value-quote": ["error", "either"] */ %>
<!-- ✓ GOOD -->
<img src="./logo.png">
<img src='./logo.png'>

<!-- ✗ BAD -->
<img src=
./logo.png
>

Further Reading

Implementation