Skip to content

Latest commit

 

History

History
106 lines (72 loc) · 2.55 KB

html-quotes.md

File metadata and controls

106 lines (72 loc) · 2.55 KB
pageClass sidebarDepth title description since
rule-details
0
vue/html-quotes
enforce quotes style of HTML attributes
v3.0.0

vue/html-quotes

enforce quotes style of HTML attributes

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

You can choose quotes of HTML attributes from:

  • Double quotes: <div class="foo">
  • Single quotes: <div class='foo'>
  • No quotes: <div class=foo>

This rule enforces the quotes style of HTML attributes.

📖 Rule Details

This rule reports the quotes of attributes if it is different to configured quotes.

<template>
  <!-- ✓ GOOD -->
  <img src="./logo.png">

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

🔧 Options

Default is set to double.

{
  "vue/html-quotes": [ "error", "double" | "single", { "avoidEscape": false } ]
}

String option:

  • "double" (default) ... requires double quotes.
  • "single" ... requires single quotes.

Object option:

  • avoidEscape ... If true, allows strings to use single-quotes or double-quotes so long as the string contains a quote that would have to be escaped otherwise.

"single"

<template>
  <!-- ✓ GOOD -->
  <img src='./logo.png'>

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

"double", { "avoidEscape": true }

<template>
  <!-- ✓ GOOD -->
  <img title='a string containing "double" quotes'>

  <!-- ✗ BAD -->
  <img title='foo'>
  <img title=bar>
</template>

📚 Further Reading

🚀 Version

This rule was introduced in eslint-plugin-vue v3.0.0

🔍 Implementation