Skip to content

Commit 7c71c48

Browse files
authored
fix(v-for-delimiter-style): ignore Punctuator token (#2416)
1 parent 8e8e1e8 commit 7c71c48

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

Diff for: lib/rules/v-for-delimiter-style.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module.exports = {
4242
node.left.length > 0
4343
? node.left[node.left.length - 1]
4444
: tokenStore.getFirstToken(node),
45-
(token) => token.type !== 'Punctuator' || token.value !== ')'
45+
(token) => token.type !== 'Punctuator'
4646
)
4747
)
4848

Diff for: tests/lib/rules/v-for-delimiter-style.js

+24
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ tester.run('v-for-delimiter-style', rule, {
3535
filename: 'test.vue',
3636
code: '<template><div v-for="x in xs"></div></template>'
3737
},
38+
{
39+
// https://github.com/vuejs/vue-eslint-parser/issues/226
40+
filename: 'test.vue',
41+
code: '<template><div v-for="(x,) in xs"></div></template>'
42+
},
43+
{
44+
filename: 'test.vue',
45+
code: '<template><div v-for="(value, key, index) in xs"></div></template>'
46+
},
47+
{
48+
filename: 'test.vue',
49+
code: '<template><div v-for="{ x, y } in xs"></div></template>'
50+
},
3851
{
3952
filename: 'test.vue',
4053
code: '<template><div v-for="x in xs"></div></template>',
@@ -58,6 +71,17 @@ tester.run('v-for-delimiter-style', rule, {
5871
}
5972
]
6073
},
74+
{
75+
filename: 'test.vue',
76+
code: '<template><div v-for="(x, index) of xs"></div></template>',
77+
output: '<template><div v-for="(x, index) in xs"></div></template>',
78+
errors: [
79+
{
80+
message: "Expected 'in' instead of 'of' in 'v-for'.",
81+
column: 23
82+
}
83+
]
84+
},
6185
{
6286
filename: 'test.vue',
6387
code: '<template><div v-for="x of xs"></div></template>',

0 commit comments

Comments
 (0)