From 297963fdbf8affecd1975d68546b377b81471165 Mon Sep 17 00:00:00 2001 From: Flo Edelmann Date: Mon, 24 Jan 2022 13:30:01 +0100 Subject: [PATCH] Skip conditional expressions in `vue/valid-next-tick` --- lib/rules/valid-next-tick.js | 7 ++++++- tests/lib/rules/valid-next-tick.js | 13 +++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/rules/valid-next-tick.js b/lib/rules/valid-next-tick.js index ed5137f8c..eba820041 100644 --- a/lib/rules/valid-next-tick.js +++ b/lib/rules/valid-next-tick.js @@ -142,7 +142,12 @@ module.exports = { return } - const parentNode = nextTickNode.parent + let parentNode = nextTickNode.parent + + // skip conditional expressions like `foo ? nextTick : bar` + if (parentNode.type === 'ConditionalExpression') { + parentNode = parentNode.parent + } if ( parentNode.type === 'CallExpression' && diff --git a/tests/lib/rules/valid-next-tick.js b/tests/lib/rules/valid-next-tick.js index a2ac636fb..c6e263eeb 100644 --- a/tests/lib/rules/valid-next-tick.js +++ b/tests/lib/rules/valid-next-tick.js @@ -129,6 +129,19 @@ tester.run('valid-next-tick', rule, { }, } }` + }, + + // https://github.com/vuejs/eslint-plugin-vue/issues/1776 + { + filename: 'test.vue', + code: `` } ], invalid: [