Skip to content

Commit 6234455

Browse files
authored
Fix false positives for arrow return in vue/valid-next-tick rule (#1686)
1 parent 3b5b127 commit 6234455

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

lib/rules/valid-next-tick.js

+7
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ function isAwaitedPromise(callExpression) {
7676
// cases like `return nextTick()`
7777
return true
7878
}
79+
if (
80+
callExpression.parent.type === 'ArrowFunctionExpression' &&
81+
callExpression.parent.body === callExpression
82+
) {
83+
// cases like `() => nextTick()`
84+
return true
85+
}
7986

8087
if (
8188
callExpression.parent.type === 'MemberExpression' &&

tests/lib/rules/valid-next-tick.js

+16
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,22 @@ tester.run('valid-next-tick', rule, {
113113
return this.$nextTick();
114114
}
115115
}</script>`
116+
},
117+
118+
{
119+
filename: 'test.vue',
120+
code: `<script>;
121+
export default {
122+
methods: {
123+
fn1 () {
124+
return this.$nextTick()
125+
},
126+
fn2 () {
127+
return this.$nextTick()
128+
.then(() => this.$nextTick())
129+
},
130+
}
131+
}</script>`
116132
}
117133
],
118134
invalid: [

0 commit comments

Comments
 (0)