-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
eslintrc,lib,test: enable prefer-const rule #3152
eslintrc,lib,test: enable prefer-const rule #3152
Conversation
LGTM |
LGTM if tests pass. |
CI is green except an unrelated issue which I'm handling in #3167. |
@silverwind LGTY? |
key: fs.readFileSync(common.fixturesDir + '/keys/ec-key.pem'), | ||
cert: fs.readFileSync(common.fixturesDir + '/keys/ec-cert.pem') | ||
}; | ||
let server = tls.createServer(options, noop).listen(common.PORT, function() { | ||
const server = tls.createServer(options).listen(common.PORT, function() { |
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.
We sure that removing this listener won't change behaviour?
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.
@silverwind I don't think it will affect the behaviour as noop
has no executable statements, so in this particular case, it is as good as not attaching.
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.
Well, I'd be careful nonetheless. Some parts (which I can't rembember) of our API do behave different when you pass undefined
vs a noop. I'd rather leave that there unless we can be absolutely sure.
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.
@silverwind I agree. I changed it now. PTAL.
LGTM with a question. |
30a0cd6
to
75d1381
Compare
LGTM now 😉 |
I am thinking about splitting the commit into two, one to enable the rule and the other to make the changes. Sounds okay? |
Fine with me, we did that on the previous rule additions too. |
75d1381
to
1dedb84
Compare
People, few other commits landed after this PR was created and they also violate this rule. So, I updated the files and force pushed. PTAL and give go/no-go. |
@@ -83,6 +83,9 @@ rules: | |||
# Custom rules in tools/eslint-rules | |||
require-buffer: 2 | |||
|
|||
# Suggest using `const` wherever possible | |||
prefer-const: 2 | |||
|
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.
Oh, btw: We try to section rules like on this page: http://eslint.org/docs/rules/. Could you move it above the custom rules and add modify it like this:
# ECMAScript 6
# list: http://eslint.org/docs/rules/#ecmascript-6
## Suggest using 'const' wherever possible
prefer-const: 2
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.
@silverwind This has been taken care in the latest force push. Thanks :-)
1dedb84
to
a9fa79f
Compare
Is it okay to land this people? cc @nodejs/collaborators |
Description from: http://eslint.org/docs/rules/prefer-const.html If a variable is never modified, using the `const` declaration is better. `const` declaration tells readers, "this variable is never modified," reducing cognitive load and improving maintainability. Refer: nodejs#3118 PR-URL: nodejs#3152 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
As per the `prefer-const` eslint rule, few instances of `let` have been identified to be better with `const`. This patch updates all those instances. Refer: nodejs#3118 PR-URL: nodejs#3152 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io>
a9fa79f
to
06d5aee
Compare
Isn't there still an issue with the REPL and this change? |
@cjihrig Files in |
Right, I get that. I guess my question is, will any Node APIs fail in the REPL after this change? If certain user entered code is already failing in the REPL in sloppy mode, and is unrelated to this change, then it's fine. |
Except |
I'm good with it then. |
@Trott @silverwind @targos LGTY guys? |
LGTM if CI is still happy |
"eslintrc" isn't a valid subsystem :) "tools" is probably better? |
LGTM. Those CI results seem to get harder to navigate every day. 😭 |
Description from: http://eslint.org/docs/rules/prefer-const.html If a variable is never modified, using the `const` declaration is better. `const` declaration tells readers, "this variable is never modified," reducing cognitive load and improving maintainability. Refer: #3118 PR-URL: #3152 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
As per the `prefer-const` eslint rule, few instances of `let` have been identified to be better with `const`. This patch updates all those instances. Refer: #3118 PR-URL: #3152 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Thanks for the review people. Changes landed at aaf9b48 and b0e7b36. @Fishrock123 The commit message's title has |
Description from: http://eslint.org/docs/rules/prefer-const.html If a variable is never modified, using the `const` declaration is better. `const` declaration tells readers, "this variable is never modified," reducing cognitive load and improving maintainability. Refer: nodejs#3118 PR-URL: nodejs#3152 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
As per the `prefer-const` eslint rule, few instances of `let` have been identified to be better with `const`. This patch updates all those instances. Refer: nodejs#3118 PR-URL: nodejs#3152 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Landing in LTS primarily to ensure easier cherry picking of commits later |
As per the `prefer-const` eslint rule, few instances of `let` have been identified to be better with `const`. This patch updates all those instances. Refer: #3118 PR-URL: #3152 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Description from: http://eslint.org/docs/rules/prefer-const.html If a variable is never modified, using the `const` declaration is better. `const` declaration tells readers, "this variable is never modified," reducing cognitive load and improving maintainability. Refer: #3118 PR-URL: #3152 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
As per the `prefer-const` eslint rule, few instances of `let` have been identified to be better with `const`. This patch updates all those instances. Refer: #3118 PR-URL: #3152 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Description from: http://eslint.org/docs/rules/prefer-const.html If a variable is never modified, using the `const` declaration is better. `const` declaration tells readers, "this variable is never modified," reducing cognitive load and improving maintainability. Refer: #3118 PR-URL: #3152 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Description from: http://eslint.org/docs/rules/prefer-const.html
If a variable is never modified, using the
const
declaration isbetter.
const
declaration tells readers, "this variable is nevermodified," reducing cognitive load and improving maintainability.
Refer: #3118