Skip to content

Commit 09ea463

Browse files
committed
fix(vue/valid-v-for): allow using an empty alias in value
1 parent 5023e75 commit 09ea463

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

lib/rules/valid-v-for.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ module.exports = {
163163
const key = lhs[1]
164164
const index = lhs[2]
165165

166-
if (value === null) {
166+
if (value === null && !key) {
167167
context.report({
168168
node: expr,
169169
messageId: 'invalidEmptyAlias'

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ tester.run('valid-v-for', rule, {
4646
filename: 'test.vue',
4747
code: '<template><div><your-component v-for="x in list" :key="x.id"></your-component></div></template>'
4848
},
49+
{
50+
filename: 'test.vue',
51+
code: '<template><div><div v-for="(, key) in obj"></div></div></template>'
52+
},
53+
{
54+
filename: 'test.vue',
55+
code: '<template><div><div v-for="(, key, index) in obj"></div></div></template>'
56+
},
4957
{
5058
filename: 'test.vue',
5159
code: '<template><div><div is="your-component" v-for="x in list" :key="x.id"></div></div></template>'
@@ -183,11 +191,6 @@ tester.run('valid-v-for', rule, {
183191
code: '<template><div><div v-for></div></div></template>',
184192
errors: ["'v-for' directives require that attribute value."]
185193
},
186-
{
187-
filename: 'test.vue',
188-
code: '<template><div><div v-for="(,a,b) in list"></div></div></template>',
189-
errors: ["Invalid alias ''."]
190-
},
191194
{
192195
filename: 'test.vue',
193196
code: '<template><div><div v-for="(a,,b) in list"></div></div></template>',

0 commit comments

Comments
 (0)