Skip to content

vue/no-restricted-block

禁止特定块

¥disallow specific block

📖 规则详情

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

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

🔧选项

¥🔧 Options

此规则采用字符串列表,其中每个字符串都是要限制的块名称或模式:

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

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

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

¥Alternatively, the rule also accepts objects.

json
{
  "vue/no-restricted-block": ["error",
    {
      "element": "style",
      "message": "Do not use <style> block in this project."
    },
    {
      "element": "foo",
      "message": "Do not use <foo> block in this project."
    },
    {
      "element": "/forbidden/",
      "message": "Do not use blocks that include `forbidden` in their name."
    }
  ]
}

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

¥The following properties can be specified for the object.

  • element ...指定块元素名称或模式。

    ¥element ... Specify the block element name or pattern.

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

    ¥message ... Specify an optional custom message.

{ "element": "foo" }, { "element": "/forbidden/" }

Now loading...

🚀版本

¥🚀 Version

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

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

🔍代码实现

¥🔍 Implementation

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