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 d1cd06e

Browse files
ota-meshimichalsnik
authored andcommitted
Fixes #240 (#638)
1 parent e1e4e1d commit d1cd06e

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ module.exports = {
147147

148148
for (const reference of node.value.references) {
149149
const id = reference.id
150-
if (id.parent.type ==='MemberExpression'||id.parent.type==='BinaryExpression') {
150+
if (id.parent.type !=='VExpressionContainer') {
151151
continue
152152
}
153153

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

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,38 @@ tester.run('valid-v-model', rule, {
7575
filename: 'test.vue',
7676
code: '<template><div><div v-for="x in list"><input v-model="foo[x - 1]"></div></div></template>'
7777
},
78+
{
79+
filename: 'test.vue',
80+
code: '<template><div><div v-for="x in list"><input v-model="foo[`${x}`]"></div></div></template>'
81+
},
82+
{
83+
filename: 'test.vue',
84+
code: '<template><div><div v-for="x in list"><input v-model="foo[`prefix_${x}`]"></div></div></template>'
85+
},
86+
{
87+
filename: 'test.vue',
88+
code: '<template><div><div v-for="x in list"><input v-model="foo[x ? x : \'_\']"></div></div></template>'
89+
},
90+
{
91+
filename: 'test.vue',
92+
code: '<template><div><div v-for="x in list"><input v-model="foo[x || \'_\']"></div></div></template>'
93+
},
94+
{
95+
filename: 'test.vue',
96+
code: '<template><div><div v-for="x in list"><input v-model="foo[x()]"></div></div></template>'
97+
},
98+
{
99+
filename: 'test.vue',
100+
code: '<template><div><div v-for="x in list"><input v-model="foo[/r/.match(x) ? 0 : 1]"></div></div></template>'
101+
},
102+
{
103+
filename: 'test.vue',
104+
code: '<template><div><div v-for="x in list"><input v-model="foo[typeof x]"></div></div></template>'
105+
},
106+
{
107+
filename: 'test.vue',
108+
code: '<template><div><div v-for="x in list"><input v-model="foo[tag`${x}`]"></div></div></template>'
109+
},
78110
{
79111
filename: 'test.vue',
80112
code: '<template><input :type="a" v-model="b"></template>'
@@ -119,6 +151,16 @@ tester.run('valid-v-model', rule, {
119151
filename: 'test.vue',
120152
code: '<template><div><div v-for="x in list"><input v-model="x"></div></div></template>',
121153
errors: ["'v-model' directives cannot update the iteration variable 'x' itself."]
154+
},
155+
{
156+
filename: 'test.vue',
157+
code: '<template><div><div v-for="x in list"><input v-model="(x)"></div></div></template>',
158+
errors: ["'v-model' directives cannot update the iteration variable 'x' itself."]
159+
},
160+
{
161+
filename: 'test.vue',
162+
code: '<template><div><div v-for="x in list"><input v-model="(((x)))"></div></div></template>',
163+
errors: ["'v-model' directives cannot update the iteration variable 'x' itself."]
122164
}
123165
]
124166
})

0 commit comments

Comments
(0)

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