Skip to content

Commit

Permalink
Fix false positives for arrow return in vue/valid-next-tick rule (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ota-meshi committed Oct 29, 2021
1 parent 3b5b127 commit 6234455
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/rules/valid-next-tick.js
Expand Up @@ -76,6 +76,13 @@ function isAwaitedPromise(callExpression) {
// cases like `return nextTick()`
return true
}
if (
callExpression.parent.type === 'ArrowFunctionExpression' &&
callExpression.parent.body === callExpression
) {
// cases like `() => nextTick()`
return true
}

if (
callExpression.parent.type === 'MemberExpression' &&
Expand Down
16 changes: 16 additions & 0 deletions tests/lib/rules/valid-next-tick.js
Expand Up @@ -113,6 +113,22 @@ tester.run('valid-next-tick', rule, {
return this.$nextTick();
}
}</script>`
},

{
filename: 'test.vue',
code: `<script>;
export default {
methods: {
fn1 () {
return this.$nextTick()
},
fn2 () {
return this.$nextTick()
.then(() => this.$nextTick())
},
}
}</script>`
}
],
invalid: [
Expand Down

0 comments on commit 6234455

Please sign in to comment.