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 9b6b17f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rules/no-is-mounted.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ 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
12 changes: 12 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,18 @@ ruleTester.run('no-is-mounted', rule, {
});
`,
},
{
code: `
class Hello extends React.Component {
notIsMounted() {}
render() {
this.notIsMounted();
return <div>Hello</div>;
}
};
`,
errors: [{ messageId: 'noIsMounted' }],
},
]),

invalid: parsers.all([
Expand Down

0 comments on commit 9b6b17f

Please sign in to comment.