Content-Length: 331398 | pFad | http://github.com/jsx-eslint/eslint-plugin-react/commit/a09083b1ce38b7ef6704a048cf26eb96ad774d0e

9E [Fix] `no-is-mounted`: fix logic in method name check · jsx-eslint/eslint-plugin-react@a09083b · GitHub
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 11 additions & 0 deletions
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)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/jsx-eslint/eslint-plugin-react/commit/a09083b1ce38b7ef6704a048cf26eb96ad774d0e

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy