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

Appearance settings

Commit 354c0de

Browse filesBrowse files
authored
fix(attribute-hyphenation): apply to v-model directive (#2511)
1 parent 21d3ed8 commit 354c0de
Copy full SHA for 354c0de

File tree

Expand file treeCollapse file tree

2 files changed

+48
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+48
-1
lines changed

‎lib/rules/attribute-hyphenation.js

Copy file name to clipboardExpand all lines: lib/rules/attribute-hyphenation.js
+1-1Lines changed: 1 addition & 1 deletion
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
) {

‎tests/lib/rules/attribute-hyphenation.js

Copy file name to clipboardExpand all lines: tests/lib/rules/attribute-hyphenation.js
+47Lines changed: 47 additions & 0 deletions
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>',
@@ -219,6 +224,48 @@ ruleTester.run('attribute-hyphenation', rule, {
219224
}
220225
]
221226
},
227+
{
228+
// https://github.com/vuejs/eslint-plugin-vue/issues/2510
229+
filename: 'test.vue',
230+
code: '<template><div><custom v-model:my-prop="prop"></custom></div></template>',
231+
output:
232+
'<template><div><custom v-model:myProp="prop"></custom></div></template>',
233+
options: ['never'],
234+
errors: [
235+
{
236+
message: "Attribute 'v-model:my-prop' can't be hyphenated.",
237+
type: 'VDirectiveKey',
238+
line: 1
239+
}
240+
]
241+
},
242+
{
243+
filename: 'test.vue',
244+
code: '<template><div><custom v-model:myProp="prop"></custom></div></template>',
245+
output:
246+
'<template><div><custom v-model:my-prop="prop"></custom></div></template>',
247+
options: ['always'],
248+
errors: [
249+
{
250+
message: "Attribute 'v-model:myProp' must be hyphenated.",
251+
type: 'VDirectiveKey',
252+
line: 1
253+
}
254+
]
255+
},
256+
{
257+
filename: 'test.vue',
258+
code: '<template><div><custom v-model:MyProp="prop"></custom></div></template>',
259+
output: null,
260+
options: ['always'],
261+
errors: [
262+
{
263+
message: "Attribute 'v-model:MyProp' must be hyphenated.",
264+
type: 'VDirectiveKey',
265+
line: 1
266+
}
267+
]
268+
},
222269
{
223270
filename: 'test.vue',
224271
code: `

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.