Skip to content

Commit a09083b

Browse files
Mathias-Sljharb
authored andcommitted
[Fix] no-is-mounted: fix logic in method name check
The last change to `no-is-mounted` caused the rule to error with any method name, not just with "isMounted".
1 parent 1df23d2 commit a09083b

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ This change log adheres to standards from [Keep a CHANGELOG](https://keepachange
66

77
## Unreleased
88

9+
### Fixed
10+
* [`no-is-mounted`]: fix logic in method name check ([#3821][] @Mathias-S)
11+
12+
[#3821]: https://github.com/jsx-eslint/eslint-plugin-react/pull/3821
13+
914
## [7.36.0] - 2024.09.12
1015

1116
### Added

lib/rules/no-is-mounted.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ module.exports = {
4141
}
4242
if (
4343
callee.object.type !== 'ThisExpression'
44-
&& (!('name' in callee.property) || callee.property.name !== 'isMounted')
44+
|| !('name' in callee.property)
45+
|| callee.property.name !== 'isMounted'
4546
) {
4647
return;
4748
}

tests/lib/rules/no-is-mounted.js

+11
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,17 @@ ruleTester.run('no-is-mounted', rule, {
5757
});
5858
`,
5959
},
60+
{
61+
code: `
62+
class Hello extends React.Component {
63+
notIsMounted() {}
64+
render() {
65+
this.notIsMounted();
66+
return <div>Hello</div>;
67+
}
68+
};
69+
`,
70+
},
6071
]),
6172

6273
invalid: parsers.all([

0 commit comments

Comments
 (0)