Skip to content

Commit a1c342d

Browse files
TrottFishrock123
authored andcommitted
lib: use consistent indentation for ternaries
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]>
1 parent 7d610d4 commit a1c342d

File tree

6 files changed

+17
-20
lines changed

6 files changed

+17
-20
lines changed

lib/_stream_readable.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -949,9 +949,7 @@ function fromListPartial(n, list, hasStrings) {
949949
ret = list.shift();
950950
} else {
951951
// result spans more than one buffer
952-
ret = (hasStrings ?
953-
copyFromBufferString(n, list) :
954-
copyFromBuffer(n, list));
952+
ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
955953
}
956954
return ret;
957955
}

lib/cluster.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,5 @@
2121

2222
'use strict';
2323

24-
module.exports = ('NODE_UNIQUE_ID' in process.env) ?
25-
require('internal/cluster/child') :
26-
require('internal/cluster/master');
24+
const childOrMaster = 'NODE_UNIQUE_ID' in process.env ? 'child' : 'master';
25+
module.exports = require(`internal/cluster/${childOrMaster}`);

lib/fs.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -1357,9 +1357,8 @@ function FSWatcher() {
13571357
if (status < 0) {
13581358
self._handle.close();
13591359
const error = !filename ?
1360-
errnoException(status, 'Error watching file for changes:') :
1361-
errnoException(status,
1362-
`Error watching file ${filename} for changes:`);
1360+
errnoException(status, 'Error watching file for changes:') :
1361+
errnoException(status, `Error watching file ${filename} for changes:`);
13631362
error.filename = filename;
13641363
self.emit('error', error);
13651364
} else {

lib/internal/bootstrap_node.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,9 @@
275275
enumerable: true,
276276
get: function() {
277277
if (!console) {
278-
console = originalConsole === undefined ?
279-
NativeModule.require('console') :
280-
installInspectorConsole(originalConsole);
278+
console = (originalConsole === undefined) ?
279+
NativeModule.require('console') :
280+
installInspectorConsole(originalConsole);
281281
}
282282
return console;
283283
}

lib/internal/child_process.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -875,8 +875,8 @@ function _validateStdio(stdio, sync) {
875875
} else if (getHandleWrapType(stdio) || getHandleWrapType(stdio.handle) ||
876876
getHandleWrapType(stdio._handle)) {
877877
var handle = getHandleWrapType(stdio) ?
878-
stdio :
879-
getHandleWrapType(stdio.handle) ? stdio.handle : stdio._handle;
878+
stdio :
879+
getHandleWrapType(stdio.handle) ? stdio.handle : stdio._handle;
880880

881881
acc.push({
882882
type: 'wrap',

lib/url.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,9 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
393393
this.query = Object.create(null);
394394
}
395395

396-
var firstIdx = (questionIdx !== -1 &&
397-
(hashIdx === -1 || questionIdx < hashIdx) ?
398-
questionIdx :
399-
hashIdx);
396+
const useQuestionIdx =
397+
questionIdx !== -1 && (hashIdx === -1 || questionIdx < hashIdx);
398+
const firstIdx = useQuestionIdx ? questionIdx : hashIdx;
400399
if (firstIdx === -1) {
401400
if (rest.length > 0)
402401
this.pathname = rest;
@@ -583,9 +582,11 @@ Url.prototype.format = function format() {
583582
if (this.host) {
584583
host = auth + this.host;
585584
} else if (this.hostname) {
586-
host = auth + (this.hostname.indexOf(':') === -1 ?
585+
host = auth + (
586+
this.hostname.indexOf(':') === -1 ?
587587
this.hostname :
588-
'[' + this.hostname + ']');
588+
'[' + this.hostname + ']'
589+
);
589590
if (this.port) {
590591
host += ':' + this.port;
591592
}

0 commit comments

Comments
 (0)