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 7e2520a
Show file tree
Hide file tree
Showing 2 changed files with 12 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
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 7e2520a

Please sign in to comment.