From 1dd36fd50f0d45d211b6ed6f7095c00ba15f087c Mon Sep 17 00:00:00 2001 From: yosuke ota Date: Sat, 7 Aug 2021 16:38:01 +0900 Subject: [PATCH] Update `vue/no-restricted-v-bind` and `vue/valid-v-bind` rules to support `attr` modifier. --- lib/rules/no-restricted-v-bind.js | 2 +- lib/rules/valid-v-bind.js | 2 +- tests/lib/rules/no-restricted-v-bind.js | 7 +++++++ tests/lib/rules/valid-v-bind.js | 4 ++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/rules/no-restricted-v-bind.js b/lib/rules/no-restricted-v-bind.js index d15bb4caa..3cc46e715 100644 --- a/lib/rules/no-restricted-v-bind.js +++ b/lib/rules/no-restricted-v-bind.js @@ -113,7 +113,7 @@ module.exports = { type: 'array', items: { type: 'string', - enum: ['prop', 'camel', 'sync'] + enum: ['prop', 'camel', 'sync', 'attr'] }, uniqueItems: true }, diff --git a/lib/rules/valid-v-bind.js b/lib/rules/valid-v-bind.js index 5b9339c1a..6605ed1c7 100644 --- a/lib/rules/valid-v-bind.js +++ b/lib/rules/valid-v-bind.js @@ -15,7 +15,7 @@ const utils = require('../utils') // Helpers // ------------------------------------------------------------------------------ -const VALID_MODIFIERS = new Set(['prop', 'camel', 'sync']) +const VALID_MODIFIERS = new Set(['prop', 'camel', 'sync', 'attr']) // ------------------------------------------------------------------------------ // Rule Definition diff --git a/tests/lib/rules/no-restricted-v-bind.js b/tests/lib/rules/no-restricted-v-bind.js index e6dd72d59..8691b1d0e 100644 --- a/tests/lib/rules/no-restricted-v-bind.js +++ b/tests/lib/rules/no-restricted-v-bind.js @@ -147,6 +147,13 @@ tester.run('no-restricted-v-bind', rule, { `, options: [{ argument: 'foo', message: 'foo' }], errors: ['foo'] + }, + + { + filename: 'test.vue', + code: '', + options: [{ argument: 'foo', modifiers: ['attr'] }], + errors: ['Using `:foo.attr` is not allowed.'] } ] }) diff --git a/tests/lib/rules/valid-v-bind.js b/tests/lib/rules/valid-v-bind.js index b5e71af7c..24a61bba7 100644 --- a/tests/lib/rules/valid-v-bind.js +++ b/tests/lib/rules/valid-v-bind.js @@ -71,6 +71,10 @@ tester.run('valid-v-bind', rule, { filename: 'test.vue', code: "" }, + { + filename: 'test.vue', + code: "" + }, { filename: 'test.vue', code: ""