Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

no-unbound-method warns when deleting property #3801

Closed
tvuotila opened this issue Mar 29, 2018 · 4 comments
Closed

no-unbound-method warns when deleting property #3801

tvuotila opened this issue Mar 29, 2018 · 4 comments

Comments

@tvuotila
Copy link

Bug Report

  • TSLint version: 5.9.1
  • TypeScript version: 2.4.2
  • Running TSLint via: CLI

TypeScript code being linted

const a = {
  getText() {
    return 'text';
  }
};

delete a.getText;

with tslint.json configuration:

{
  "rules": {
    "no-unbound-method": true
  }
}

Actual behavior

Error Avoid referencing unbound methods which may cause unintentional scoping of 'this'.

Expected behavior

No error. I am deleting a property. There is no risk on deleting unbound method compared to other kind of properties.

@piotrgajow
Copy link
Contributor

Hi, I think I could fix this issue by adding allow-delete parameter similar to what I have done previously for typeof operator. What do you think about such solution?

@JoshuaKGoldberg
Copy link
Contributor

@piotrgajow that sounds great, yes please! 😄

@piotrgajow
Copy link
Contributor

Ok, I have made PR for this change.

@JoshuaKGoldberg
Copy link
Contributor

Fxed by #4548! ✨

@adidahiya adidahiya added this to the 5.14.0 milestone Mar 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants