Skip to content

Files

Latest commit

 

History

History
85 lines (60 loc) · 2 KB

no-restricted-static-attribute.md

File metadata and controls

85 lines (60 loc) · 2 KB

Pattern: Use of restricted static attribute

Issue: -

Description

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

Options

This rule takes a list of strings, where each string is a attribute name or pattern to be restricted:

{
  "vue/no-restricted-static-attribute": ["error", "foo", "bar"]
}
<template>
  <!-- ✗ BAD -->
  <div foo="x" />
  <div bar />
</template>

Alternatively, the rule also accepts objects.

{
  "vue/no-restricted-static-attribute": ["error",
    {
      "key": "stlye",
      "message": "Using \"stlye\" is not allowed. Use \"style\" instead."
    }
  ]
}

The following properties can be specified for the object.

  • key ... Specify the attribute key name or pattern.
  • value ... Specify the value text or pattern or true. If specified, it will only be reported if the specified value is used. If true, it will only be reported if there is no value or if the value and key are same.
  • element ... Specify the element name or pattern. If specified, it will only be reported if used on the specified element.
  • message ... Specify an optional custom message.

{ "key": "foo", "value": "bar" }

<template>
  <!-- ✓ GOOD -->
  <div foo="foo" />

  <!-- ✗ BAD -->
  <div foo="bar" />
</template>

{ "key": "foo", "element": "MyButton" }

<template>
  <!-- ✓ GOOD -->
  <CoolButton foo="x" />

  <!-- ✗ BAD -->
  <MyButton foo="x" />
</template>

Further Reading