Skip to content

Files

Latest commit

 

History

History
87 lines (64 loc) · 1.71 KB

no-restricted-html-elements.md

File metadata and controls

87 lines (64 loc) · 1.71 KB

Pattern: Use of restricted HTML element

Issue: -

Description

This rule allows you to specify HTML elements that you don't want to use in your application.

<template>
  <!-- ✓ GOOD -->
  <p></p>
  <input />
  <br />

  <!-- ✗ BAD -->
  <button></button>
  <marquee></marquee>
</template>

Options

This rule takes a list of strings, where each string is an HTML element name to be restricted:

{
  "vue/no-restricted-html-elements": ["error", "button", "marquee"]
}
<template>
  <!-- ✗ BAD -->
  <button></button>
  <marquee></marquee>
</template>

Alternatively, the rule also accepts objects.

{
  "vue/no-restricted-html-elements": [
    "error",
    {
      "element": "button",
      "message": "Prefer use of our custom <AppButton /> component"
    },
    {
      "element": "marquee",
      "message": "Do not use deprecated HTML tags"
    }
  ]
}

The following properties can be specified for the object.

  • element ... Specify the html element.
  • message ... Specify an optional custom message.

{ "element": "marquee" }, { "element": "button" }

<template>
  <!-- ✗ BAD -->
  <marquee></marquee>
  <button></button>
</template>

Further Reading