Skip to content

Commit

Permalink
Omit BinaryExpression in v-model references check (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
michalsnik committed Nov 24, 2017
1 parent 2793ca2 commit ac581a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/valid-v-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function create (context) {

for (const reference of node.value.references) {
const id = reference.id
if (id.parent.type === 'MemberExpression') {
if (id.parent.type === 'MemberExpression' || id.parent.type === 'BinaryExpression') {
continue
}

Expand Down
8 changes: 8 additions & 0 deletions tests/lib/rules/valid-v-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ tester.run('valid-v-model', rule, {
filename: 'test.vue',
code: '<template><div><div v-for="x in list"><input v-model="x.foo"></div></div></template>'
},
{
filename: 'test.vue',
code: '<template><div><div v-for="x in list"><input v-model="foo[x]"></div></div></template>'
},
{
filename: 'test.vue',
code: '<template><div><div v-for="x in list"><input v-model="foo[x - 1]"></div></div></template>'
},
{
filename: 'test.vue',
code: '<template><input :type="a" v-model="b"></template>'
Expand Down

0 comments on commit ac581a4

Please sign in to comment.