Skip to content

Commit

Permalink
[Refactor] no-*-set-state: improve performance
Browse files Browse the repository at this point in the history
  • Loading branch information
golopot authored and ljharb committed Apr 16, 2022
1 parent 7e4c2c2 commit 2bf54d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -23,7 +23,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
* [Refactor] improve performance for detecting function components ([#3265][] @golopot)
* [Refactor] improve performance for detecting class components ([#3267][] @golopot)
* [Refactor] [`no-deprecated`]: improve performance ([#3271][] @golopot)
* [Refactor] [`no-did-mount-set-state`], [`no-did-update-set-state`], [`no-will-update-set-state`]: improve performance ([#3272][] @golopot)

[#3272]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3272
[#3271]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3271
[#3267]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3267
[#3266]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3266
Expand Down
8 changes: 4 additions & 4 deletions lib/util/makeNoMethodSetStateRule.js
Expand Up @@ -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'
Expand Down

0 comments on commit 2bf54d7

Please sign in to comment.