Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update vue/no-restricted-v-bind and vue/valid-v-bind rules to support attr modifier. #1598

Merged
merged 1 commit into from Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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