-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Enable block scoped var eslint rule #3151
Enable block scoped var eslint rule #3151
Conversation
55fd8c1
to
ccf1c16
Compare
A lot of these changes (but not all) seem unnecessary to me. A mass conversion to Not 100% sure about this, but I think I read somewhere that it's better to initialize your variables. |
@@ -21,6 +21,7 @@ tls.createServer({ | |||
|
|||
(function() { | |||
// 2**26 == 64M entries | |||
var junk; | |||
for (var i = 0, junk = [0]; i < 26; ++i) junk = junk.concat(junk); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd initialize it on the var line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Description from: http://eslint.org/docs/rules/block-scoped-var.html The block-scoped-var rule generates warnings when variables are used outside of the block in which they were defined. This emulates C-style block scope. Refer: nodejs#3118
As per block-scoped-var rule, the variables which were used before declaration or declared within a block and used outside are trated as linter errors. Refer: nodejs#3118
As per block-scoped-var rule, the variables which were used before declaration or declared within a block and used outside are trated as linter errors. Refer: nodejs#3118
ccf1c16
to
615be16
Compare
615be16
to
78a09d6
Compare
-1 Just because some people don't like this functionality does not mean it is in any way bad. |
I'm -0 on this. Personally I dig having my declarations yanked, but as @Fishrock123 said it's not necessarily a bad thing. So not sure it's worth the code churn. |
-1 for code churn. Why not just gradually change occurrences of |
I see no good reason to move to
|
With I don't really care either way on the |
Closing, as this rule is not preferred generally. |
Description from: http://eslint.org/docs/rules/block-scoped-var.html
The block-scoped-var rule generates warnings when variables are used
outside of the block in which they were defined. This emulates C-style
block scope.
Refer: #3118