Skip to content

Commit

Permalink
[Fix] no-is-mounted: fix logic in method name check
Browse files Browse the repository at this point in the history
The last change to `no-is-mounted` caused the rule to error
with any method name, not just with "isMounted".
  • Loading branch information
Mathias-S committed Sep 12, 2024
1 parent 1df23d2 commit 07f2c97
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/rules/no-is-mounted.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
11 changes: 11 additions & 0 deletions tests/lib/rules/no-is-mounted.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ ruleTester.run('no-is-mounted', rule, {
});
`,
},
{
code: `
class Hello extends React.Component {
notIsMounted() {}
render() {
this.notIsMounted();
return <div>Hello</div>;
}
};
`,
},
]),

invalid: parsers.all([
Expand Down

0 comments on commit 07f2c97

Please sign in to comment.