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

Beware of TSLint's no-unused-variable rule #4

Open
cartant opened this issue Aug 20, 2017 · 3 comments
Open

Beware of TSLint's no-unused-variable rule #4

cartant opened this issue Aug 20, 2017 · 3 comments
Labels

Comments

@cartant
Copy link
Owner

cartant commented Aug 20, 2017

I'm creating this issue as a reminder to myself and as a note that might be of use to others.

TSLint's no-unused-variable rule still seems to have problems - it has given me grief in the past. If it's enabled, the type information made available to rxjs-tslint-rules seems to change, resulting in the implementation sometimes being unable to determine whether or not an expression is an Observable. This can lead to false positives with the rxjs-no-unused-add rule, etc.

And it's not just rxjs-tslint-rules that's affected. With no-unused-variable enabled, I've seen false positives for TSLint's no-unnecessary-type-assertion rule, too.

@LogvinovLeon
Copy link

Did someone investigate that already? I've just spent quite a significant amount of time trying to figure out why no-unnecessary-type-assertion gives me false positives. Didn't expect the other unrelated linter rule to change the types. Will be nice to have that fixed.

@cartant
Copy link
Owner Author

cartant commented Jan 26, 2018

@LogvinovLeon I put a fair bit of time into it and raised this issue. IIRC, that situation might have been fixed, but others were still broken. I gave up on that rule entirely, as it had wasted a lot of my time.

Have a look at the number of issues that relate to no-unused-variable before you commit yourself to looking into it.

@cartant
Copy link
Owner Author

cartant commented Jun 28, 2018

For anyone who ends up here due to problems with the no-unused-variable rule, I've written an alternative. There is a no-unused-declaration rule in my tslint-etc package. It does much the same thing and includes a fixer (for unused imports).

cartant added a commit to cartant/rxjs that referenced this issue Nov 18, 2018
This rule has caused so many problems for me in the past.
See cartant/rxjs-tslint-rules#4
benlesh pushed a commit to ReactiveX/rxjs that referenced this issue Mar 25, 2019
This rule has caused so many problems for me in the past.
See cartant/rxjs-tslint-rules#4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants