Skip to content

Commit

Permalink
chore(vue-eslint-parser): Update to 5.0.0, fix test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
michalsnik committed Jan 5, 2019
1 parent 9bf6098 commit 9c5e70a
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 35 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"eslint": "^5.0.0"
},
"dependencies": {
"vue-eslint-parser": "^4.0.2"
"vue-eslint-parser": "^5.0.0"
},
"devDependencies": {
"@types/node": "^4.2.16",
Expand Down
12 changes: 8 additions & 4 deletions tests/lib/rules/no-unused-vars.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ tester.run('no-unused-vars', rule, {
code: '<template><ol v-for="i in data"><li v-for="f in i">{{ f.bar.baz }}</li></ol></template>'
},
{
code: '<template scope="props">{{props}}</template>'
code: '<template><template scope="props">{{props}}</template></template>'
},
{
code: '<template scope="props"><span v-if="props"></span></template>'
code: '<template><template scope="props"><span v-if="props"></span></template></template>'
},
{
code: '<template><div v-for="(item, key) in items" :key="key">{{item.name}}</div></template>'
Expand All @@ -57,11 +57,15 @@ tester.run('no-unused-vars', rule, {
errors: ["'i' is defined but never used."]
},
{
code: '<template scope="props"></template>',
code: '<template><span slot-scope="props"></span></template>',
errors: ["'props' is defined but never used."]
},
{
code: '<template v-for="i in 5"><comp v-for="j in 10">{{i}}{{i}}</comp></template>',
code: '<template><span><template scope="props"></template></span></template>',
errors: ["'props' is defined but never used."]
},
{
code: '<template><div v-for="i in 5"><comp v-for="j in 10">{{i}}{{i}}</comp></div></template>',
errors: ["'j' is defined but never used."]
},
{
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/rules/valid-v-else-if.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ tester.run('valid-v-else-if', rule, {
invalid: [
{
filename: 'test.vue',
code: '<template v-else-if="foo"><div></div></template>',
code: '<template><template v-else-if="foo"><div></div></template></template>',
errors: ["'v-else-if' directives require being preceded by the element which has a 'v-if' or 'v-else-if' directive."]
},
{
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/rules/valid-v-else.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ tester.run('valid-v-else', rule, {
invalid: [
{
filename: 'test.vue',
code: '<template v-else><div></div></template>',
code: '<template><template v-else><div></div></template></template>',
errors: ["'v-else' directives require being preceded by the element which has a 'v-if' or 'v-else' directive."]
},
{
Expand Down
65 changes: 37 additions & 28 deletions tests/lib/rules/valid-v-for.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ tester.run('valid-v-for', rule, {
},
{
filename: 'test.vue',
code: '<template v-for="x of list"><slot name="item" /></template>'
code: '<template><template v-for="x of list"><slot name="item" /></template></template>'
},
{
filename: 'test.vue',
code: '<template v-for="x of list">foo<div></div></template>'
code: '<template><template v-for="x of list">foo<div></div></template></template>'
},
{
filename: 'test.vue',
Expand All @@ -90,22 +90,26 @@ tester.run('valid-v-for', rule, {
{
filename: 'test.vue',
code: `
<template v-for="x in xs">
<template v-for="y in x.ys">
<li v-for="z in y.zs" :key="z.id">
123
</li>
<template>
<template v-for="x in xs">
<template v-for="y in x.ys">
<li v-for="z in y.zs" :key="z.id">
123
</li>
</template>
</template>
</template>`
},
{
filename: 'test.vue',
code: `
<template v-for="x in xs">
<template v-for="y in ys">
<li v-for="z in zs" :key="x.id + y.id + z.id">
123
</li>
<template>
<template v-for="x in xs">
<template v-for="y in ys">
<li v-for="z in zs" :key="x.id + y.id + z.id">
123
</li>
</template>
</template>
</template>`
}
Expand Down Expand Up @@ -215,38 +219,43 @@ tester.run('valid-v-for', rule, {
filename: 'test.vue',
errors: ["Expected 'v-bind:key' directive to use the variables which are defined by the 'v-for' directive."],
code: `
<template v-for="x in xs">
<template v-for="y in a.ys">
<li v-for="z in y.zs" :key="z.id">
123
</li>
<template>
<template v-for="x in xs">
<template v-for="y in a.ys">
<li v-for="z in y.zs" :key="z.id">
123
</li>
</template>
</template>
</template>`
},
{
filename: 'test.vue',
errors: ["Expected 'v-bind:key' directive to use the variables which are defined by the 'v-for' directive."],
code: `
<template v-for="x in xs">
<template v-for="y in x.ys">
<li v-for="z in a.zs" :key="z.id">
123
</li>
<template>
<template v-for="x in xs">
<template v-for="y in x.ys">
<li v-for="z in a.zs" :key="z.id">
123
</li>
</template>
</template>
</template>`
},
{
filename: 'test.vue',
errors: ["Expected 'v-bind:key' directive to use the variables which are defined by the 'v-for' directive."],
code: `
<template v-for="x in xs">
<template v-for="y in x.ys">
<li v-for="z in x.zs" :key="z.id">
123
</li>
<template>
<template v-for="x in xs">
<template v-for="y in x.ys">
<li v-for="z in x.zs" :key="z.id">
123
</li>
</template>
</template>
</template>`
}

]
})

0 comments on commit 9c5e70a

Please sign in to comment.