Skip to content

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

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

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rules/no-restricted-v-bind.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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