Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upno-redeclare in a for loop scope seems wrong #955
Comments
This comment has been minimized.
This comment has been minimized.
|
Like you said, the solution is to declare index at the top of the file. I
also regularly run into this, but I don't mind it too much haha
…On Tue, Jul 18, 2017, 21:26 Jake Wilson ***@***.***> wrote:
It's pretty typical ES5 syntax to do this:
for (var index = 0; index < arrayOne.length; index++ ) {
// code
}
for (var index = 0; index < arrayTwo.length; index++ ) {
// code
}
The no-redeclare has an issue with this because index is being defined
twice. This isn't a problem when using let but a lot of people still use
ES5 on the frontend and Babel and Webpack are transpilling ot ES5 for
frontend client side code as well.
Are there any thoughts on this? Obviously the solution is to declare index
by itself at the top of the code, but I'm just looking to keep my code
simple.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#955>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACWlev204qYhyv8O4O2TbgKc4Drsj4Mbks5sPQb5gaJpZM4Obz8U>
.
|
This comment has been minimized.
This comment has been minimized.
|
Standard should lint the pre-compile side of babel. Machine generated code shouldn't require linting. With hoisting the above code actually turns into: var index
for (index = 0; index < arrayOne.length; index++ ) {
// code
}
for (index = 0; index < arrayTwo.length; index++ ) {
// code
}The rule is to remind you of this, and to make sure you don't run into the pitfalls surrounding it. Closing for now. Please let me know if there are undressed issues here and we can reopen. |
bcomnes
closed this
Jul 18, 2017
This comment has been minimized.
This comment has been minimized.
|
That makes sense. Thanks |
lock
bot
locked as resolved and limited conversation to collaborators
May 10, 2018
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.


Jakobud commentedJul 18, 2017
•
edited
It's pretty typical ES5 syntax to do this:
The
no-redeclarehas an issue with this becauseindexis being defined twice. This isn't a problem when usingletbut a lot of people still use ES5 on the frontend and Babel and Webpack are transpilling ot ES5 for frontend client side code as well.Are there any thoughts on this? Obviously the solution is to declare
indexby itself at the top of the code, but I'm just looking to keep my code simple.