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

Diff for: 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
}

Diff for: 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)