From 3bc35b3e89270bc51ece02e1e237f2087011800b Mon Sep 17 00:00:00 2001 From: Chiawen Chen Date: Sat, 16 Apr 2022 11:18:58 +0800 Subject: [PATCH] [Refactor] `no-*-set-state`: improve performance --- lib/util/makeNoMethodSetStateRule.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/util/makeNoMethodSetStateRule.js b/lib/util/makeNoMethodSetStateRule.js index f1be5c16ae..23346a9a6b 100644 --- a/lib/util/makeNoMethodSetStateRule.js +++ b/lib/util/makeNoMethodSetStateRule.js @@ -73,16 +73,16 @@ module.exports = function makeNoMethodSetStateRule(methodName, shouldCheckUnsafe return false; } + if (shouldBeNoop(context, methodName)) { + return {}; + } + // -------------------------------------------------------------------------- // Public // -------------------------------------------------------------------------- return { CallExpression(node) { - if (shouldBeNoop(context, methodName)) { - return; - } - const callee = node.callee; if ( callee.type !== 'MemberExpression'