From 94347a823ec99fed702bf0d0d54bc4fa39d7f45d Mon Sep 17 00:00:00 2001 From: ota-meshi Date: Fri, 25 Dec 2020 22:23:11 +0900 Subject: [PATCH] Add vue/no-restricted-block rule --- docs/rules/README.md | 1 + docs/rules/no-restricted-block.md | 88 +++++++++++++++++ lib/index.js | 1 + lib/rules/no-restricted-block.js | 126 +++++++++++++++++++++++++ tests/lib/rules/no-restricted-block.js | 96 +++++++++++++++++++ 5 files changed, 312 insertions(+) create mode 100644 docs/rules/no-restricted-block.md create mode 100644 lib/rules/no-restricted-block.js create mode 100644 tests/lib/rules/no-restricted-block.js diff --git a/docs/rules/README.md b/docs/rules/README.md index 68677d252..ab1d2c28f 100644 --- a/docs/rules/README.md +++ b/docs/rules/README.md @@ -301,6 +301,7 @@ For example: | [vue/no-multiple-objects-in-class](./no-multiple-objects-in-class.md) | disallow to pass multiple objects into array to class | | | [vue/no-potential-component-option-typo](./no-potential-component-option-typo.md) | disallow a potential typo in your component property | | | [vue/no-reserved-component-names](./no-reserved-component-names.md) | disallow the use of reserved names in component definitions | | +| [vue/no-restricted-block](./no-restricted-block.md) | disallow specific block | | | [vue/no-restricted-component-options](./no-restricted-component-options.md) | disallow specific component option | | | [vue/no-restricted-custom-event](./no-restricted-custom-event.md) | disallow specific custom event | | | [vue/no-restricted-props](./no-restricted-props.md) | disallow specific props | | diff --git a/docs/rules/no-restricted-block.md b/docs/rules/no-restricted-block.md new file mode 100644 index 000000000..f84b13746 --- /dev/null +++ b/docs/rules/no-restricted-block.md @@ -0,0 +1,88 @@ +--- +pageClass: rule-details +sidebarDepth: 0 +title: vue/no-restricted-block +description: disallow specific block +--- +# vue/no-restricted-block + +> disallow specific block + +- :exclamation: ***This rule has not been released yet.*** + +## :book: Rule Details + +This rule allows you to specify block names that you don't want to use in your application. + +## :wrench: 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"] +} +``` + + + +```vue + + + Custom block + + + Custom block + + +``` + + + +Alternatively, the rule also accepts objects. + +```json +{ + "vue/no-restricted-block": ["error", + { + "element": "style", + "message": "Do not use ', + options: ['foo'] + } + ], + invalid: [ + { + filename: 'test.vue', + code: ``, + options: ['style', 'foo'], + errors: [ + { + message: 'Using ` + + `, + options: [ + { + element: 'style', + message: 'Do not use