Skip to content
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

Closed
wants to merge 6 commits into from

Conversation

anikethsaha
Copy link
Contributor

fixes #1866

Added options

allowSuper : default : false - type : boolean

should it be false by default ? let me know

@typescript-eslint
Copy link
Contributor

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.

@bradzacher bradzacher added the enhancement: plugin rule option New rule option for an existing eslint-plugin rule label Apr 22, 2020
Copy link
Member

@bradzacher bradzacher left a 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) &&
Copy link
Member

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.

Suggested change
(node as TSESTree.MemberExpression) &&
node.type === AST_NODE_TYPES.MemberExpression &&

Comment on lines +445 to 446
},
],
Copy link
Member

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
  }
}

@bradzacher bradzacher added the awaiting response Issues waiting for a reply from the OP or another party label May 17, 2020
@bradzacher bradzacher added stale PRs or Issues that are at risk of being or have been closed due to inactivity for a prolonged period and removed awaiting response Issues waiting for a reply from the OP or another party labels Sep 1, 2020
@bradzacher bradzacher closed this Sep 1, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement: plugin rule option New rule option for an existing eslint-plugin rule stale PRs or Issues that are at risk of being or have been closed due to inactivity for a prolonged period
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[unbound-method] Support super.foo in constructor
2 participants