Skip to content

Commit

Permalink
Update vue/no-restricted-v-bind and vue/valid-v-bind rules to sup…
Browse files Browse the repository at this point in the history
…port `attr` modifier. (#1598)
  • Loading branch information
ota-meshi committed Aug 10, 2021
1 parent b7b2393 commit a1a5122
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/rules/no-restricted-v-bind.js
Expand Up @@ -113,7 +113,7 @@ module.exports = {
type: 'array',
items: {
type: 'string',
enum: ['prop', 'camel', 'sync']
enum: ['prop', 'camel', 'sync', 'attr']
},
uniqueItems: true
},
Expand Down
2 changes: 1 addition & 1 deletion lib/rules/valid-v-bind.js
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions tests/lib/rules/no-restricted-v-bind.js
Expand Up @@ -147,6 +147,13 @@ tester.run('no-restricted-v-bind', rule, {
</template>`,
options: [{ argument: 'foo', message: 'foo' }],
errors: ['foo']
},

{
filename: 'test.vue',
code: '<template><div :foo.attr="foo" /><div :bar.attr="foo" /></template>',
options: [{ argument: 'foo', modifiers: ['attr'] }],
errors: ['Using `:foo.attr` is not allowed.']
}
]
})
4 changes: 4 additions & 0 deletions tests/lib/rules/valid-v-bind.js
Expand Up @@ -71,6 +71,10 @@ tester.run('valid-v-bind', rule, {
filename: 'test.vue',
code: "<template><div :aaa.camel='bbb'></div></template>"
},
{
filename: 'test.vue',
code: "<template><div :aaa.attr='bbb'></div></template>"
},
{
filename: 'test.vue',
code: "<template><input v-bind='$attrs' /></template>"
Expand Down

0 comments on commit a1a5122

Please sign in to comment.