diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a7934cc39..a3faa4c5ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange ## Unreleased +### Fixed +* [`no-is-mounted`]: fix logic in method name check ([#3821][] @Mathias-S) + +[#3821]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3821 + ## [7.36.0] - 2024.09.12 ### Added diff --git a/lib/rules/no-is-mounted.js b/lib/rules/no-is-mounted.js index 02a100251a..24d9a37d02 100644 --- a/lib/rules/no-is-mounted.js +++ b/lib/rules/no-is-mounted.js @@ -41,7 +41,8 @@ module.exports = { } if ( callee.object.type !== 'ThisExpression' - && (!('name' in callee.property) || callee.property.name !== 'isMounted') + || !('name' in callee.property) + || callee.property.name !== 'isMounted' ) { return; } diff --git a/tests/lib/rules/no-is-mounted.js b/tests/lib/rules/no-is-mounted.js index ba63e8d67e..c8b22daabb 100644 --- a/tests/lib/rules/no-is-mounted.js +++ b/tests/lib/rules/no-is-mounted.js @@ -57,6 +57,17 @@ ruleTester.run('no-is-mounted', rule, { }); `, }, + { + code: ` + class Hello extends React.Component { + notIsMounted() {} + render() { + this.notIsMounted(); + return
Hello
; + } + }; + `, + }, ]), invalid: parsers.all([