-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Should no-redeclare also check functions? #2953
Comments
I know there have been conversations around this. Have you tried using |
This is not an issue |
What all |
In this particular case, I'm using |
Yeah, most likely a bug even though the docs would indicate otherwise. We should fix this and update the docs to be more accurate. |
I tried:
If you have turned Related: #2903 |
I can verify that |
If you have verified this then you can close. |
Actually, could we add tests for var a; function a() {} |
When we deployed the app, a bug I introduced in segmentio/app#e3fa8a1886cb17e8a3765d70c215b42591729c0d prevented the page from loading for all users. We needed to rollback, and I introduced a fix segmentio/app#7fb59a0602d55d8095c249d583fab6ddd75a975d that has fixed the issue. The problem was that I accidentally created a conflicting variable in the global scope for that module. (`var` up top, `function` way later) By adding `no-redeclare`, this will catch that same problem in the future. As noted in eslint/eslint#2953, this has already been fixed in `master`, so now we just await a new release. In the meantime, adding this rule will still be a good idea as it will catch other similar problems.
Update: adding some tests for no-redeclare to test named functions (fixes #2953)
I just got burned by a stupid mistake, but I think it should've been caught by
no-redeclare
.Given the following code:
If I turn on
no-redeclare: 2
, this is not treated as an error, but I think it should.To be clear, this was a stupid mistake on my part. I added a
var
to the top of a file that was named the same as a function declared much further down in my code. Nonetheless, I thinkno-redeclare
should take hoisted functions into account as well.The text was updated successfully, but these errors were encountered: