Skip to content

Commit 2bf54d7

Browse files
chiawendtljharb
authored andcommitted
[Refactor] no-*-set-state: improve performance
1 parent 7e4c2c2 commit 2bf54d7

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
2323
* [Refactor] improve performance for detecting function components ([#3265][] @golopot)
2424
* [Refactor] improve performance for detecting class components ([#3267][] @golopot)
2525
* [Refactor] [`no-deprecated`]: improve performance ([#3271][] @golopot)
26+
* [Refactor] [`no-did-mount-set-state`], [`no-did-update-set-state`], [`no-will-update-set-state`]: improve performance ([#3272][] @golopot)
2627

28+
[#3272]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3272
2729
[#3271]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3271
2830
[#3267]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3267
2931
[#3266]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3266

lib/util/makeNoMethodSetStateRule.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,16 @@ module.exports = function makeNoMethodSetStateRule(methodName, shouldCheckUnsafe
7373
return false;
7474
}
7575

76+
if (shouldBeNoop(context, methodName)) {
77+
return {};
78+
}
79+
7680
// --------------------------------------------------------------------------
7781
// Public
7882
// --------------------------------------------------------------------------
7983

8084
return {
8185
CallExpression(node) {
82-
if (shouldBeNoop(context, methodName)) {
83-
return;
84-
}
85-
8686
const callee = node.callee;
8787
if (
8888
callee.type !== 'MemberExpression'

0 commit comments

Comments
 (0)