Skip to content

Commit

Permalink
fix(v-for-delimiter-style): ignore Punctuator token (#2416)
Browse files Browse the repository at this point in the history
  • Loading branch information
waynzh committed Mar 9, 2024
1 parent 8e8e1e8 commit 7c71c48
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/v-for-delimiter-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ module.exports = {
node.left.length > 0
? node.left[node.left.length - 1]
: tokenStore.getFirstToken(node),
(token) => token.type !== 'Punctuator' || token.value !== ')'
(token) => token.type !== 'Punctuator'
)
)

Expand Down
24 changes: 24 additions & 0 deletions tests/lib/rules/v-for-delimiter-style.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ tester.run('v-for-delimiter-style', rule, {
filename: 'test.vue',
code: '<template><div v-for="x in xs"></div></template>'
},
{
// https://github.com/vuejs/vue-eslint-parser/issues/226
filename: 'test.vue',
code: '<template><div v-for="(x,) in xs"></div></template>'
},
{
filename: 'test.vue',
code: '<template><div v-for="(value, key, index) in xs"></div></template>'
},
{
filename: 'test.vue',
code: '<template><div v-for="{ x, y } in xs"></div></template>'
},
{
filename: 'test.vue',
code: '<template><div v-for="x in xs"></div></template>',
Expand All @@ -58,6 +71,17 @@ tester.run('v-for-delimiter-style', rule, {
}
]
},
{
filename: 'test.vue',
code: '<template><div v-for="(x, index) of xs"></div></template>',
output: '<template><div v-for="(x, index) in xs"></div></template>',
errors: [
{
message: "Expected 'in' instead of 'of' in 'v-for'.",
column: 23
}
]
},
{
filename: 'test.vue',
code: '<template><div v-for="x of xs"></div></template>',
Expand Down

0 comments on commit 7c71c48

Please sign in to comment.