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

[unbound-method] rule triggered when binding a class method #700

Closed
andsouto opened this issue Jul 12, 2019 · 1 comment
Closed

[unbound-method] rule triggered when binding a class method #700

andsouto opened this issue Jul 12, 2019 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers has pr there is a PR raised to close this package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@andsouto
Copy link

Repro

{
  "rules": {
    "@typescript-eslint/unbound-method": ["error"]
  }
}
class Foo {
	constructor() {
		this.onMessage = this.onMessage.bind(this);
	}

	onMessage(): void {}
}

Expected Result
No error detected

Actual Result
Avoid referencing unbound methods which may cause unintentional scoping of this @typescript-eslint/unbound-method

Additional Info
As far as I know this is a common pattern for binding event handlers. Could be related with #692

Versions

package version
@typescript-eslint/eslint-plugin 1.11.0
@typescript-eslint/parser 1.11.0
TypeScript 3.5.3
ESLint 5.16.0
node 8.16.0
npm 6.10.0
@andsouto andsouto added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for maintainers to take a look labels Jul 12, 2019
@bradzacher bradzacher added the bug Something isn't working label Jul 13, 2019
@bradzacher bradzacher added good first issue Good for newcomers and removed triage Waiting for maintainers to take a look labels Jul 27, 2019
sergey-shulyak added a commit to sergey-shulyak/typescript-eslint that referenced this issue Oct 18, 2019
sergey-shulyak added a commit to sergey-shulyak/typescript-eslint that referenced this issue Oct 19, 2019
@bradzacher bradzacher added the has pr there is a PR raised to close this label Oct 19, 2019
@glen-84
Copy link
Contributor

glen-84 commented Jan 10, 2020

Is this a duplicate of #636?

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working good first issue Good for newcomers has pr there is a PR raised to close this package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

No branches or pull requests

3 participants