JS.VUE.NO.RESTRICTED.BLOCK

Disallow specific block

Rule Details

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:

Copy
{
  "vue/no-restricted-block": ["error", "style", "foo", "bar"]
}

{'vue/no-restricted-block': ['error', 'style', 'foo', 'bar']}

Copy
<!-- BAD -->
<foo>
  Custom block
</foo>
<bar>
  Custom block
</bar>
<style>
.foo {}
</style>

Alternatively, the rule also accepts objects.

Copy
{
  "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 ... Specify the block element name or pattern.
  • message ... Specify an optional custom message.

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

{'vue/no-restricted-block': ['error', { element: 'foo' }, { element: '/forbidden/' }]}

Copy
<!-- BAD -->
<foo>
  BAD
</foo>
<forbidden-block></forbidden-block>
<block-forbidden></block-forbidden>

The content on this page is adapted from the ESLint User Guide. Copyright © OpenJS Foundation and other contributors, www.openjsf.org. All rights reserved. https://eslint.org/docs/rules/