New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(eslint-plugin): added allowSuper option for unbound-method #1925
Conversation
Thanks for the PR, @anikethsaha! typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code mostly LGTM
Could you please drop the option?
I don't think this needs an option - it should just be part of how the rule works.
parent.operator === '=' && | ||
(node === parent.left || | ||
(allowSuper && | ||
(node as TSESTree.MemberExpression) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is unsafe - prefer an explicit check.
(node as TSESTree.MemberExpression) && | |
node.type === AST_NODE_TYPES.MemberExpression && |
}, | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please add a sanity check, this should report an error
class BaseClass {
x: number = 42;
logThis() {
console.log('x is ');
}
}
class OtherClass extends BaseClass {
superLogThis: any;
constructor() {
super();
const x = super.logThis; // ERROR - unbound method
}
}
fixes #1866
Added options
allowSuper
: default :false
- type :boolean
should it be
false
by default ? let me know