跳至内容

vue/no-restricted-static-attribute

禁止使用特定属性

📖 规则详情

此规则允许您指定在应用程序中不希望使用的属性名称。

🔧 选项

此规则接受字符串列表,其中每个字符串都是要限制的属性名称或模式。

json
{
  "vue/no-restricted-static-attribute": ["error", "foo", "bar"]
}
正在加载...

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

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."
    }
  ]
}

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

  • key ... 指定属性键名或模式。
  • value ... 指定值文本或模式或 true。如果指定,则只有在使用指定值时才会报告。如果为 true,则只有在没有值或值和键相同的情况下才会报告。
  • element ... 指定元素名称或模式。如果指定,则只有在指定元素上使用时才会报告。
  • message ... 指定可选的自定义消息。

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

正在加载...

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

正在加载...

🚀 版本

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

🔍 实现