Skip to content

Commit 07f2c97

Browse files
committed
[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 07f2c97

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy