-
Notifications
You must be signed in to change notification settings - Fork 887
no-for-in #4504
Comments
no-for-in-array already exists do you want to disallow this syntax for objects as well? |
Correct |
bump... what do you think |
It can be used in every example where a forof is used in our codebase.
^ this is what our autocomplete does when we write a forif. It might be correct but it's just a bother to worry about. We find it preferable to not even worry about forif, when forof can do it in a more succinct way:
Enforcing this as a rule on a codebase would be great, it just ensures that forof is the only way to iterate (aside from classic for loops, which tslint will recommend against if the index isn't being used with prefer-for-of). We already ban foreach in our tslint.json, we want to extend that to forin. |
This sounds similar to tslint-microsoft-contrib's |
Rule Suggestion
Is your rule for a general problem or is it specific to your development style?
Specific to my style
What does your suggested rule do?
Prevents forin from ever being used, forces forof.
List several examples where your rule could be used
should be obvious
Additional context
forin and forof are easy to confuse, I'd rather stick with one that is simpler in behaviour
The text was updated successfully, but these errors were encountered: