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
no-redeclare in a for loop scope seems wrong #955
Comments
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>
.
|
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. |
That makes sense. Thanks |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
It's pretty typical ES5 syntax to do this:
The
no-redeclare
has an issue with this becauseindex
is being defined twice. This isn't a problem when usinglet
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.The text was updated successfully, but these errors were encountered: