From 49336e1b88d0cd7df49dce7976aa4990359a567e Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 4 Jul 2017 17:59:36 -0700 Subject: [PATCH 1/5] 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. --- lib/_stream_readable.js | 4 +--- lib/cluster.js | 6 +++--- lib/fs.js | 5 ++--- lib/internal/bootstrap_node.js | 4 ++-- lib/internal/child_process.js | 4 ++-- lib/url.js | 12 ++++++------ 6 files changed, 16 insertions(+), 19 deletions(-) diff --git a/lib/_stream_readable.js b/lib/_stream_readable.js index a308e8baeda452..463ac3bfbcd33e 100644 --- a/lib/_stream_readable.js +++ b/lib/_stream_readable.js @@ -949,9 +949,7 @@ function fromListPartial(n, list, hasStrings) { ret = list.shift(); } else { // result spans more than one buffer - ret = (hasStrings ? - copyFromBufferString(n, list) : - copyFromBuffer(n, list)); + ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list); } return ret; } diff --git a/lib/cluster.js b/lib/cluster.js index 8d2f44f364df5c..3dfef6a6276dfa 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -21,6 +21,6 @@ 'use strict'; -module.exports = ('NODE_UNIQUE_ID' in process.env) ? - require('internal/cluster/child') : - require('internal/cluster/master'); +module.exports = require(`internal/cluster/${ + 'NODE_UNIQUE_ID' in process.env ? 'child' : 'master' +}`); diff --git a/lib/fs.js b/lib/fs.js index a2401acf31bc83..5bbd9f49466bd1 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -1357,9 +1357,8 @@ function FSWatcher() { if (status < 0) { self._handle.close(); const error = !filename ? - errnoException(status, 'Error watching file for changes:') : - errnoException(status, - `Error watching file ${filename} for changes:`); + errnoException(status, 'Error watching file for changes:') : + errnoException(status, `Error watching file ${filename} for changes:`); error.filename = filename; self.emit('error', error); } else { diff --git a/lib/internal/bootstrap_node.js b/lib/internal/bootstrap_node.js index e7d2d94c8654c0..1d493709e2d0b3 100644 --- a/lib/internal/bootstrap_node.js +++ b/lib/internal/bootstrap_node.js @@ -276,8 +276,8 @@ get: function() { if (!console) { console = originalConsole === undefined ? - NativeModule.require('console') : - installInspectorConsole(originalConsole); + NativeModule.require('console') : + installInspectorConsole(originalConsole); } return console; } diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index 46343325a16437..b0731ab7c2f24a 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -883,8 +883,8 @@ function _validateStdio(stdio, sync) { } else if (getHandleWrapType(stdio) || getHandleWrapType(stdio.handle) || getHandleWrapType(stdio._handle)) { var handle = getHandleWrapType(stdio) ? - stdio : - getHandleWrapType(stdio.handle) ? stdio.handle : stdio._handle; + stdio : + getHandleWrapType(stdio.handle) ? stdio.handle : stdio._handle; acc.push({ type: 'wrap', diff --git a/lib/url.js b/lib/url.js index b3b05f4a89e79b..b816e1d86f9cbd 100644 --- a/lib/url.js +++ b/lib/url.js @@ -395,10 +395,10 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) { this.query = Object.create(null); } - var firstIdx = (questionIdx !== -1 && - (hashIdx === -1 || questionIdx < hashIdx) ? - questionIdx : - hashIdx); + var firstIdx = + questionIdx !== -1 && (hashIdx === -1 || questionIdx < hashIdx) ? + questionIdx : + hashIdx; if (firstIdx === -1) { if (rest.length > 0) this.pathname = rest; @@ -586,8 +586,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 : + '[' + this.hostname + ']'); if (this.port) { host += ':' + this.port; } From 88e6138badd209c3e7274d83941d013cf7bd3e81 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 4 Jul 2017 19:49:35 -0700 Subject: [PATCH 2/5] squash: address mscdex nit --- lib/cluster.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/cluster.js b/lib/cluster.js index 3dfef6a6276dfa..848b2247a87b06 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -21,6 +21,5 @@ 'use strict'; -module.exports = require(`internal/cluster/${ - 'NODE_UNIQUE_ID' in process.env ? 'child' : 'master' -}`); +const childOrMaster = 'NODE_UNIQUE_ID' in process.env ? 'child' : 'master'; +module.exports = require(`internal/cluster/${childOrMaster}`); From c915b7e381cc7bc882602e8fa8f34818944a0cbf Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 4 Jul 2017 19:54:36 -0700 Subject: [PATCH 3/5] squash: first nit from refack --- lib/internal/bootstrap_node.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/internal/bootstrap_node.js b/lib/internal/bootstrap_node.js index 1d493709e2d0b3..efc66b1b232baf 100644 --- a/lib/internal/bootstrap_node.js +++ b/lib/internal/bootstrap_node.js @@ -275,7 +275,7 @@ enumerable: true, get: function() { if (!console) { - console = originalConsole === undefined ? + console = (originalConsole === undefined) ? NativeModule.require('console') : installInspectorConsole(originalConsole); } From 5da6124a3a0f3512656dec99bca7e118fa984e89 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 4 Jul 2017 20:02:39 -0700 Subject: [PATCH 4/5] squash: second refack nit --- lib/url.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/url.js b/lib/url.js index b816e1d86f9cbd..97ea9f8050440c 100644 --- a/lib/url.js +++ b/lib/url.js @@ -395,10 +395,9 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) { this.query = Object.create(null); } - var firstIdx = - questionIdx !== -1 && (hashIdx === -1 || questionIdx < hashIdx) ? - questionIdx : - hashIdx; + const useQuestionIdx = + questionIdx !== -1 && (hashIdx === -1 || questionIdx < hashIdx); + const firstIdx = useQuestionIdx ? questionIdx : hashIdx; if (firstIdx === -1) { if (rest.length > 0) this.pathname = rest; From a1f4bfb5d1e4366901d5551ddab12d26de6fcd57 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Tue, 4 Jul 2017 20:36:43 -0700 Subject: [PATCH 5/5] squash: address third refack nit --- lib/url.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/url.js b/lib/url.js index 97ea9f8050440c..70584f8d0763c3 100644 --- a/lib/url.js +++ b/lib/url.js @@ -584,9 +584,11 @@ Url.prototype.format = function format() { if (this.host) { host = auth + this.host; } else if (this.hostname) { - host = auth + (this.hostname.indexOf(':') === -1 ? - this.hostname : - '[' + this.hostname + ']'); + host = auth + ( + this.hostname.indexOf(':') === -1 ? + this.hostname : + '[' + this.hostname + ']' + ); if (this.port) { host += ':' + this.port; }