Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a1a5122

Browse files
Update vue/no-restricted-v-bind and vue/valid-v-bind rules to support attr modifier. (#1598)
1 parent b7b2393 commit a1a5122

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

‎lib/rules/no-restricted-v-bind.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ module.exports = {
113113
type: 'array',
114114
items: {
115115
type: 'string',
116-
enum: ['prop', 'camel', 'sync']
116+
enum: ['prop', 'camel', 'sync','attr']
117117
},
118118
uniqueItems: true
119119
},

‎lib/rules/valid-v-bind.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const utils = require('../utils')
1515
// Helpers
1616
// ------------------------------------------------------------------------------
1717

18-
const VALID_MODIFIERS = new Set(['prop', 'camel', 'sync'])
18+
const VALID_MODIFIERS = new Set(['prop', 'camel', 'sync','attr'])
1919

2020
// ------------------------------------------------------------------------------
2121
// Rule Definition

‎tests/lib/rules/no-restricted-v-bind.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,13 @@ tester.run('no-restricted-v-bind', rule, {
147147
</template>`,
148148
options: [{ argument: 'foo', message: 'foo' }],
149149
errors: ['foo']
150+
},
151+
152+
{
153+
filename: 'test.vue',
154+
code: '<template><div :foo.attr="foo" /><div :bar.attr="foo" /></template>',
155+
options: [{ argument: 'foo', modifiers: ['attr'] }],
156+
errors: ['Using `:foo.attr` is not allowed.']
150157
}
151158
]
152159
})

‎tests/lib/rules/valid-v-bind.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ tester.run('valid-v-bind', rule, {
7171
filename: 'test.vue',
7272
code: "<template><div :aaa.camel='bbb'></div></template>"
7373
},
74+
{
75+
filename: 'test.vue',
76+
code: "<template><div :aaa.attr='bbb'></div></template>"
77+
},
7478
{
7579
filename: 'test.vue',
7680
code: "<template><input v-bind='$attrs' /></template>"

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /