Skip to content

vue/no-restricted-static-attribute

禁止特定属性

¥disallow specific attribute

📖 规则详情

此规则允许你指定你不想在应用中使用的属性名称。

¥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:

json
{
  "vue/no-restricted-static-attribute": ["error", "foo", "bar"]
}
Now loading...

或者,该规则也接受对象。

¥Alternatively, the rule also accepts objects.

json
{
  "vue/no-restricted-static-attribute": [
    "error",
    {
      "key": "stlye",
      "message": "Using \"stlye\" is not allowed. Use \"style\" instead."
    },
    {
      "key": "style",
      "element": "/^([A-Z][a-zA-Z_-]*)$/",
      "message": "Using \"style\" is not allowed in custom component. Use \"class\" instead."
    }
  ]
}

可以为对象指定以下属性。

¥The following properties can be specified for the object.

  • key ...指定属性键名称或模式。

    ¥key ... Specify the attribute key name or pattern.

  • value ...指定值文本或模式或 true。如果指定,则仅在使用指定的值时才会报告。如果是 true,则仅在没有值或值和键相同时才会报告。

    ¥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 ...指定元素名称或模式。如果指定,则仅在指定元素上使用时才会报告。

    ¥element ... Specify the element name or pattern. If specified, it will only be reported if used on the specified element.

  • message ...指定可选的自定义消息。

    ¥message ... Specify an optional custom message.

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

Now loading...

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

Now loading...

👫相关规则

¥👫 Related Rules

🚀版本

¥🚀 Version

此规则在 eslint-plugin-vue v7.0.0 中引入

¥This rule was introduced in eslint-plugin-vue v7.0.0

🔍代码实现

¥🔍 Implementation

eslint-plugin-vue v10.1 中文网 - 粤ICP备13048890号