Browse Source

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: https://github.com/nodejs/node/pull/14078
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
v6
Rich Trott 7 years ago
parent
commit
85dacd63f0
  1. 4
      lib/_stream_readable.js
  2. 5
      lib/cluster.js
  3. 5
      lib/fs.js
  4. 6
      lib/internal/bootstrap_node.js
  5. 4
      lib/internal/child_process.js
  6. 13
      lib/url.js

4
lib/_stream_readable.js

@ -949,9 +949,7 @@ function fromListPartial(n, list, hasStrings) {
ret = list.shift(); ret = list.shift();
} else { } else {
// result spans more than one buffer // result spans more than one buffer
ret = (hasStrings ? ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
copyFromBufferString(n, list) :
copyFromBuffer(n, list));
} }
return ret; return ret;
} }

5
lib/cluster.js

@ -21,6 +21,5 @@
'use strict'; 'use strict';
module.exports = ('NODE_UNIQUE_ID' in process.env) ? const childOrMaster = 'NODE_UNIQUE_ID' in process.env ? 'child' : 'master';
require('internal/cluster/child') : module.exports = require(`internal/cluster/${childOrMaster}`);
require('internal/cluster/master');

5
lib/fs.js

@ -1357,9 +1357,8 @@ function FSWatcher() {
if (status < 0) { if (status < 0) {
self._handle.close(); self._handle.close();
const error = !filename ? const error = !filename ?
errnoException(status, 'Error watching file for changes:') : errnoException(status, 'Error watching file for changes:') :
errnoException(status, errnoException(status, `Error watching file ${filename} for changes:`);
`Error watching file ${filename} for changes:`);
error.filename = filename; error.filename = filename;
self.emit('error', error); self.emit('error', error);
} else { } else {

6
lib/internal/bootstrap_node.js

@ -275,9 +275,9 @@
enumerable: true, enumerable: true,
get: function() { get: function() {
if (!console) { if (!console) {
console = originalConsole === undefined ? console = (originalConsole === undefined) ?
NativeModule.require('console') : NativeModule.require('console') :
installInspectorConsole(originalConsole); installInspectorConsole(originalConsole);
} }
return console; return console;
} }

4
lib/internal/child_process.js

@ -883,8 +883,8 @@ function _validateStdio(stdio, sync) {
} else if (getHandleWrapType(stdio) || getHandleWrapType(stdio.handle) || } else if (getHandleWrapType(stdio) || getHandleWrapType(stdio.handle) ||
getHandleWrapType(stdio._handle)) { getHandleWrapType(stdio._handle)) {
var handle = getHandleWrapType(stdio) ? var handle = getHandleWrapType(stdio) ?
stdio : stdio :
getHandleWrapType(stdio.handle) ? stdio.handle : stdio._handle; getHandleWrapType(stdio.handle) ? stdio.handle : stdio._handle;
acc.push({ acc.push({
type: 'wrap', type: 'wrap',

13
lib/url.js

@ -395,10 +395,9 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) {
this.query = Object.create(null); this.query = Object.create(null);
} }
var firstIdx = (questionIdx !== -1 && const useQuestionIdx =
(hashIdx === -1 || questionIdx < hashIdx) ? questionIdx !== -1 && (hashIdx === -1 || questionIdx < hashIdx);
questionIdx : const firstIdx = useQuestionIdx ? questionIdx : hashIdx;
hashIdx);
if (firstIdx === -1) { if (firstIdx === -1) {
if (rest.length > 0) if (rest.length > 0)
this.pathname = rest; this.pathname = rest;
@ -585,9 +584,11 @@ Url.prototype.format = function format() {
if (this.host) { if (this.host) {
host = auth + this.host; host = auth + this.host;
} else if (this.hostname) { } else if (this.hostname) {
host = auth + (this.hostname.indexOf(':') === -1 ? host = auth + (
this.hostname.indexOf(':') === -1 ?
this.hostname : this.hostname :
'[' + this.hostname + ']'); '[' + this.hostname + ']'
);
if (this.port) { if (this.port) {
host += ':' + this.port; host += ':' + this.port;
} }

Loading…
Cancel
Save