-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(eslint-plugin): add prefer-for-of rule #338
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
Conversation
This rule is intended to provide functionality equivalent to TSLint's prefer-for-of rule.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few changes, but otherwise LGTM.
Note - also needs to add link to the rule doc in the README.md
Thanks for the review! Updated. While updating the README I also noticed I have the option of using type information, which would allow us to fix palantir/tslint#2021. Would it be worth it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome work! LGTM
@edsrzf - you could use the type information if you want. I don't know how necessary that is immediately considering that is a bit of an edge case. |
Codecov Report
@@ Coverage Diff @@
## master #338 +/- ##
=========================================
- Coverage 96.96% 96.87% -0.1%
=========================================
Files 69 70 +1
Lines 2572 2625 +53
Branches 408 424 +16
=========================================
+ Hits 2494 2543 +49
- Misses 46 49 +3
- Partials 32 33 +1
|
This rule provides functionality equivalent to TSLint's prefer-for-of rule. Test cases are mostly taken from TSLint, but I added others that I thought of while implementing.
Note that this implementation still falls into palantir/tslint#2021, false positives on non-
Array
s that are still indexable and have alength
property, such as typed arrays. We'd need type-checking to do better than this.This is the first attempt I've made at writing a lint, so bear that in mind. 😄