Skip to content

[unbound-method] Doesn't work on destructuring declarations #1112

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

Closed
Validark opened this issue Oct 20, 2019 · 2 comments · Fixed by #2228
Closed

[unbound-method] Doesn't work on destructuring declarations #1112

Validark opened this issue Oct 20, 2019 · 2 comments · Fixed by #2228
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin

Comments

@Validark
Copy link
Contributor

Repro

{
  "rules": {
    "@typescript-eslint/unbound-method": "warn"
  }
}
class MyClass {
	public log(): void {
		print(this);
	}
}

const instance = new MyClass();

const myLog = instance.log; // properly caught
myLog();

const { log } = instance; // no problem ?

log();

Expected Result const { log } = instance; should get reported as bad

Actual Result const { log } = instance; is not reported

Additional Info

Versions

package version
@typescript-eslint/eslint-plugin 2.3.2
@typescript-eslint/parser 2.3.2
TypeScript 3.6.4
ESLint 6.5.1
node 12.9.1
npm 6.11.2
@Validark Validark added package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin triage Waiting for team members to take a look labels Oct 20, 2019
@bradzacher bradzacher added enhancement New feature or request and removed triage Waiting for team members to take a look labels Oct 20, 2019
@OliverJAsh
Copy link
Contributor

👍. Also, note that the example in the docs suggests the destructuring variant should error, so either this is a bug or the docs are a bit misleading?

@bradzacher
Copy link
Member

Hmm, sometimes I don't know a rule well enough to catch things like that when triaging. Thanks for flagging.

Looking closer at the tests, they are pretty clearly written incorrectly, which is probably why this isn't working

{
const { unbound } = instance.unbound;
const { unboundStatic } = ContainsMethods.unboundStatic;
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working package: eslint-plugin Issues related to @typescript-eslint/eslint-plugin
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants