-
Notifications
You must be signed in to change notification settings - Fork 510
requireVarDeclFirst vs const/let #1783
Comments
@markelog when requireVarDeclFirst was implemented I did not consider ES6 at that time. I think I could look into allowing let to have block scope. This might take sometime though, is it a time critical requirement or can we let #1069 get released without the requireVarDeclFirst rule and add that to the preset once I can swing around to fix it. I am looking into a 3-4 weeks time frame as the past 2 weeks will be tight for me to look into this. :) |
For sure! No hurry ;) |
This should be added to the idiomatic preset. |
+1 for a change of behavior of this property. I disabled it for now, way too annoying w/ ES2015 :) |
Yep, agree with the need to change this rule. |
I might have sometime next week, I will try looking into this. :) |
Another +1. When you implement don't forget you can't just look for braces: for (let item in obj) and for (let i = 0; i < len; i++) are implicitly block scoped. |
Sure. Sorry I had to delay on this as I just let my company and had a little cleaning up to do on the day job. |
No big rush, I've been doing JavaScript for a long time so it's not very natural to me to put variables anywhere else, let will take some getting used to. Actually, now that I've thought about it, I'm surprised this rule gets triggered at all. Seems it would specifically be looking for var. Just a suggestion, it's your product and it's a good one but I'd split the rule. requireVarDeclFirst - only look at var |
If people want it, I can create a change now that ignores let/const and release another patch version |
That would work for me. I could remove the override comments and add the new rule later if you do it that way. |
Those are block scoped, so it doesn't makes sense to require them to be the first statements in function.
So we need to either apply more comprehensive algorithm or remove them.
/cc @Oredi
The text was updated successfully, but these errors were encountered: