Skip to content

Commit ac581a4

Browse files
authored
Omit BinaryExpression in v-model references check (#243)
1 parent 2793ca2 commit ac581a4

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/rules/valid-v-model.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ function create (context) {
139139

140140
for (const reference of node.value.references) {
141141
const id = reference.id
142-
if (id.parent.type === 'MemberExpression') {
142+
if (id.parent.type === 'MemberExpression' || id.parent.type === 'BinaryExpression') {
143143
continue
144144
}
145145

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ tester.run('valid-v-model', rule, {
6767
filename: 'test.vue',
6868
code: '<template><div><div v-for="x in list"><input v-model="x.foo"></div></div></template>'
6969
},
70+
{
71+
filename: 'test.vue',
72+
code: '<template><div><div v-for="x in list"><input v-model="foo[x]"></div></div></template>'
73+
},
74+
{
75+
filename: 'test.vue',
76+
code: '<template><div><div v-for="x in list"><input v-model="foo[x - 1]"></div></div></template>'
77+
},
7078
{
7179
filename: 'test.vue',
7280
code: '<template><input :type="a" v-model="b"></template>'

0 commit comments

Comments
 (0)