-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
lib: use consistent indentation for ternaries #14078
Conversation
lib/cluster.js
Outdated
module.exports = ('NODE_UNIQUE_ID' in process.env) ? | ||
require('internal/cluster/child') : | ||
require('internal/cluster/master'); | ||
module.exports = require(`internal/cluster/${ |
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'm not particularly a fan of this multi-line inline substitution stuff. Can't we just set it to a variable and use the variable name instead?
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 agree. Yes, I did it, but I did not feel good about it. Will fix.
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.
It's better than before, but could use a touch-up
lib/internal/bootstrap_node.js
Outdated
@@ -276,8 +276,8 @@ | |||
get: function() { | |||
if (!console) { | |||
console = originalConsole === undefined ? |
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.
Maybe parans around the conditional?
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.
Sure, will do.
lib/url.js
Outdated
questionIdx : | ||
hashIdx); | ||
var firstIdx = | ||
questionIdx !== -1 && (hashIdx === -1 || questionIdx < hashIdx) ? |
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.
nit: assign the condition to a variable, and fit it in one line (useQuestionIdx
)
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.
Sure, done.
lib/url.js
Outdated
@@ -585,8 +585,8 @@ Url.prototype.format = function format() { | |||
host = auth + this.host; | |||
} else if (this.hostname) { | |||
host = auth + (this.hostname.indexOf(':') === -1 ? | |||
this.hostname : | |||
'[' + this.hostname + ']'); | |||
this.hostname : |
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 think I was once asked to explain this snippet in a job interview 😵
Maybe break after the open paran into an indented block:
host = auth + (
this.hostname.indexOf(':') === -1 ?
this.hostname :
'[' + this.hostname + ']'
);
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.
This one is tricky to fix that way because the custom align-multiline-assignment
rule seems to conflict with the newer indent stuff. I'd been thinking it might be good to remove that custom rule anyway, but I don't want to do it ahead of time.
There are some other ways to make this code clearer, but they will require benchmarks to confirm that they don't adversely affect performance. Stay tuned.
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.
Obviously my comment can be deffered, or replaced with a TODO
This will not lint cleanly without first removing the custom align-multiline-assignment rule. Marking as blocked. |
In anticipation of stricter linting for indentation issues, modify ternary operators in lib that do not conform with the expected ESLint settings.
306ea50
to
a1f4bfb
Compare
This is now unblocked. |
Landed in 85dacd6 |
In anticipation of stricter linting for indentation issues, modify ternary operators in lib that do not conform with the expected ESLint settings. PR-URL: #14078 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
In anticipation of stricter linting for indentation issues, modify ternary operators in lib that do not conform with the expected ESLint settings. PR-URL: #14078 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
In anticipation of stricter linting for indentation issues, modify ternary operators in lib that do not conform with the expected ESLint settings. PR-URL: #14078 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
In anticipation of stricter linting for indentation issues, modify ternary operators in lib that do not conform with the expected ESLint settings. PR-URL: #14078 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
Can you backport trott? |
In anticipation of stricter linting for indentation issues, modify ternary operators in lib that do not conform with the expected ESLint settings. PR-URL: nodejs#14078 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
In anticipation of stricter linting for indentation issues, modify ternary operators in lib that do not conform with the expected ESLint settings. Backport-PR-URL: #14835 PR-URL: #14078 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
In anticipation of stricter linting for indentation issues, modify ternary operators in lib that do not conform with the expected ESLint settings. Backport-PR-URL: #14835 PR-URL: #14078 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
In anticipation of stricter linting for indentation issues, modify
ternary operators in lib that do not conform with the expected ESLint
settings.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
lib tools