Skip to content

Commit edf3610

Browse files
committed
fix(attribute-hyphenation): apply to v-model directive
1 parent bfc72a4 commit edf3610

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

Diff for: lib/rules/attribute-hyphenation.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function getAttributeName(node) {
1818
}
1919

2020
if (
21-
node.key.name.name === 'bind' &&
21+
(node.key.name.name === 'bind' || node.key.name.name === 'model') &&
2222
node.key.argument &&
2323
node.key.argument.type === 'VIdentifier'
2424
) {

Diff for: tests/lib/rules/attribute-hyphenation.js

+47
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ ruleTester.run('attribute-hyphenation', rule, {
2626
code: '<template><div><custom data-id="foo" aria-test="bar" slot-scope="{ data }" my-prop="prop"></custom></div></template>',
2727
options: ['always']
2828
},
29+
{
30+
filename: 'test.vue',
31+
code: '<template><div><custom :my-prop="prop" v-model:foo-bar="fooBar"></custom></div></template>',
32+
options: ['always']
33+
},
2934
{
3035
filename: 'test.vue',
3136
code: '<template><div><custom data-id="foo" aria-test="bar" slot-scope="{ data }" myProp="prop"></custom></div></template>',
@@ -209,6 +214,48 @@ ruleTester.run('attribute-hyphenation', rule, {
209214
}
210215
]
211216
},
217+
{
218+
// https://github.com/vuejs/eslint-plugin-vue/issues/2510
219+
filename: 'test.vue',
220+
code: '<template><div><custom v-model:my-prop="prop"></custom></div></template>',
221+
output:
222+
'<template><div><custom v-model:myProp="prop"></custom></div></template>',
223+
options: ['never'],
224+
errors: [
225+
{
226+
message: "Attribute 'v-model:my-prop' can't be hyphenated.",
227+
type: 'VDirectiveKey',
228+
line: 1
229+
}
230+
]
231+
},
232+
{
233+
filename: 'test.vue',
234+
code: '<template><div><custom v-model:myProp="prop"></custom></div></template>',
235+
output:
236+
'<template><div><custom v-model:my-prop="prop"></custom></div></template>',
237+
options: ['always'],
238+
errors: [
239+
{
240+
message: "Attribute 'v-model:myProp' must be hyphenated.",
241+
type: 'VDirectiveKey',
242+
line: 1
243+
}
244+
]
245+
},
246+
{
247+
filename: 'test.vue',
248+
code: '<template><div><custom v-model:MyProp="prop"></custom></div></template>',
249+
output: null,
250+
options: ['always'],
251+
errors: [
252+
{
253+
message: "Attribute 'v-model:MyProp' must be hyphenated.",
254+
type: 'VDirectiveKey',
255+
line: 1
256+
}
257+
]
258+
},
212259
{
213260
filename: 'test.vue',
214261
code: `

0 commit comments

Comments
 (0)