-
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
tools: switch from closure-linter to eslint #1539
tools: switch from closure-linter to eslint #1539
Conversation
@@ -65,15 +65,13 @@ function Protocol() { | |||
} | |||
exports.Protocol = Protocol; | |||
|
|||
|
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.
Style guide is to put two blank newlines between top-level statements.
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 don't think the current linter enforces this, but if possible, I'd loosen that rule to permit double empty lines in jscs
. Otherwise, I'd be fine if we drop that requirement.
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.
thanks. two blank lines between functions is useful.
Would it be possible to re-cut these commits into commits per-lib-file, one commit removing gjslint, one commit adding eslint, and one commit adding the eslint config? My computer can't handle showing the diff right now. |
@@ -394,12 +393,12 @@ function setupChannel(target, channel) { | |||
} else if (handle instanceof UDP) { | |||
message.type = 'dgram.Native'; | |||
} else { | |||
throw new TypeError("This handle type can't be sent"); | |||
throw new TypeError(`This handle type can't be sent`); |
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 allow this through "quotes": [2, "single", "avoid-escape"]
I think generally we should keep unused args where possible, if just for future reference. I'd suggest "no-unused-vars": [2, {"vars": "all", "args": "none"}] For the DTRACE vars, I think we could create a custom rule. I'd be vary of template strings in performance-critical parts, I think they aren't optimized as well as regular string concatenation. Overall I like it as a first step, we can use this as a base to further tighten the rules later. |
@chrisdickinson @silverwind Thanks for your review.
But I have not fixed the I would like to discuss the rules. two blank newlinesUnfortunately, I could not find the "two blank newlines between top-level statements" on current If we don't have the interest to permit the rule, we set IMO, I would like to change the rule "two blank newlines" to "single newline". If so, no need to change current commits. :) |
I'd be fine with single newline, I love compact code. |
@silverwind Thanks! And we also discuss about the ES6 rules. "ecmaFeatures": {
"blockBindings": true,
"templateStrings": true,
"octalLiterals": true,
"binaryLiterals": true
},
And I just use templateStrings on some exception messages. |
Would like a quick TC consensus whether we should drop or keep the 'two empty lines' rule between top-level 'blocks' in JavaScript files. Me and @yosuke-furukawa would like to drop that rule. |
@@ -571,7 +567,8 @@ REPLServer.prototype.complete = function(line, callback) { | |||
this.context.constructor && | |||
this.context.constructor.name === 'Context') { | |||
var contextProto = this.context; | |||
while (contextProto = Object.getPrototypeOf(contextProto)) { | |||
while ( | |||
(contextProto = Object.getPrototypeOf(contextProto)) === true) { |
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.
() === true
is unnecesary
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.
IMO, we should use condition in conditional sentences.
I am happy if linter checks the following bug.
if (a = 'test') { // a == 'test' is really needed code
// ...
}
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.
Hmm, while assignment inside a condition is a common error, I like the conciseness of how it was before.
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.
The common practice for those assignments is to write them like this:
// good code
if ((a = 'test')) {
// ...
}
So additional parentheses are a signal to a linter that a developer is intended to write this code as is.
But this is very verbose and completely unnecessary:
// don't do this
if ((a = 'test') === true) {
// ...
}
I am +1 on moving to a more modern linter. I am very -1 on the current state of style changes. This is currently far too strict. (Also more than one-line-spacing shouldn't matter to the linter..) |
Protocol.prototype._newRes = function(raw) { | ||
this.res = { raw: raw || '', headers: {} }; | ||
this.res = {raw: raw || '', headers: {}}; |
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 feel like it's more common style to leave blank space on { }
. Could we leave that?
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.
Agree, looks subjectively cleaner with the spaces.
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.
Agree. We should change disallowSpacesInsideObjectBrackets
on .jscsrc
.
Same thought here. This PR is about changing linter, not changing code style. If eslint/jscs can't validate the existing code style, it is not a good reason to change the existing code (you know, I don't have much of experience with |
Agreed, we should first get the linter in with the minimal necessary changes. Further changes to the rules can be discussed in seperate PRs. |
Maybe enable only a minimal subset of eslint rules first (I personally use only 11 rules that detect most of the errors). After that we could discuss each and every rule you want to enable on top of that in separate PRs. |
Agreed. I should separate the eslint/jscs change request and code style change request. |
@chrisdickinson @silverwind @Fishrock123 @trevnorris @rlidwka I loosen the eslint and jscs rules and I applied the minimum rule sets. I just use semicolon, comma, comment rules. please see the following eslint / jscs rules.
LGTY???? |
I don't like that list of disabled rules in Maybe use I'm not familiar with |
@yosuke-furukawa can you rebase please? The recent revert of |
@silverwind Done. But If this pull request merged, I will re-rebase them. #1650 |
LGTM |
I'm ok with these style fixes. @iojs/collaborators ptal |
I'm fine with this! LGTM |
LGTM |
Great job keeping it as close to how things are currently done. LGTM |
Thank you for your review! I would like to push the changes. I will squash my commits to 3 commits like:
Is that OK??? Does anyone have some suggestions ? |
I'd do two commits, one for the whole of eslint, including settings, the other for style fixes. |
@silverwind No problem! |
PR-URL: #1539 Fixes: #1253 Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Chris Dickinson <[email protected]> Reviewed-By: Johan Bergström <[email protected]> Reviewed-By: Fedor Indutny <[email protected]>
PR-URL: #1539 Fixes: #1253 Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Chris Dickinson <[email protected]> Reviewed-By: Johan Bergström <[email protected]> Reviewed-By: Fedor Indutny <[email protected]>
PR-URL: #1539 Fixes: #1253 Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Chris Dickinson <[email protected]> Reviewed-By: Johan Bergström <[email protected]> Reviewed-By: Fedor Indutny <[email protected]>
PR-URL: #1539 Fixes: #1253 Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Chris Dickinson <[email protected]> Reviewed-By: Johan Bergström <[email protected]> Reviewed-By: Fedor Indutny <[email protected]>
PR-URL: nodejs#1539 Fixes: nodejs#1253 Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Chris Dickinson <[email protected]> Reviewed-By: Johan Bergström <[email protected]> Reviewed-By: Fedor Indutny <[email protected]>
PR-URL: nodejs#1539 Fixes: nodejs#1253 Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Chris Dickinson <[email protected]> Reviewed-By: Johan Bergström <[email protected]> Reviewed-By: Fedor Indutny <[email protected]>
Ref: #1539 PR-URL: #3018 Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Yosuke Furukawa <[email protected]>
Ref: #1539 PR-URL: #3018 Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Yosuke Furukawa <[email protected]>
As we discussed before #1253, I would like to propose to switch from closure-linter to other
ES6 friendly
linter.Because closure-linter does not recognize
template string literals
,class
syntax andarrow functions
, etc...I have a motivation to improve our code to ES6. closure linter may be a blocker.
Currently, I just switched the closure linter to eslint and jscs.
And I fixed eslint errors in our existing JS files without test folder.
If you have any concerns, please tell me.
Reviewer: @chrisdickinson
Reviewer: @silverwind