diff options
author | Roman Reiss <me@silverwind.io> | 2019-05-08 20:45:10 +0200 |
---|---|---|
committer | Roman Reiss <me@silverwind.io> | 2019-05-10 16:58:49 +0200 |
commit | 55b80f9029fb7d6a8b4212a9eebabdae970f7e52 (patch) | |
tree | fa4dfecd46f9b3816c5063adc208fc085f40577c /lib | |
parent | 99b196d4ba3c8919c9f35b406265b40e858d145a (diff) | |
download | android-node-v8-55b80f9029fb7d6a8b4212a9eebabdae970f7e52.tar.gz android-node-v8-55b80f9029fb7d6a8b4212a9eebabdae970f7e52.tar.bz2 android-node-v8-55b80f9029fb7d6a8b4212a9eebabdae970f7e52.zip |
tools: enable block-scoped-var eslint rule
PR-URL: https://github.com/nodejs/node/pull/27616
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dgram.js | 3 | ||||
-rw-r--r-- | lib/internal/child_process.js | 4 | ||||
-rw-r--r-- | lib/internal/util.js | 5 | ||||
-rw-r--r-- | lib/internal/util/inspect.js | 14 | ||||
-rw-r--r-- | lib/url.js | 5 |
5 files changed, 19 insertions, 12 deletions
diff --git a/lib/dgram.js b/lib/dgram.js index b38aa39c21..cb20c4499a 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -91,8 +91,9 @@ function Socket(type, listener) { let recvBufferSize; let sendBufferSize; + let options; if (type !== null && typeof type === 'object') { - var options = type; + options = type; type = options.type; lookup = options.lookup; recvBufferSize = options.recvBufferSize; diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index 03c0ed9159..2f081d9111 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -693,6 +693,8 @@ function setupChannel(target, channel) { options = { swallowErrors: options }; } + let obj; + // Package messages with a handle object if (handle) { // This message will be handled by an internalMessage event handler @@ -727,7 +729,7 @@ function setupChannel(target, channel) { return this._handleQueue.length === 1; } - var obj = handleConversion[message.type]; + obj = handleConversion[message.type]; // convert TCP object to native handle object handle = handleConversion[message.type].send.call(target, diff --git a/lib/internal/util.js b/lib/internal/util.js index 14c8baa68c..ed2493d9b4 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -316,12 +316,13 @@ promisify.custom = kCustomPromisifiedSymbol; function join(output, separator) { let str = ''; if (output.length !== 0) { - for (var i = 0; i < output.length - 1; i++) { + const lastIndex = output.length - 1; + for (let i = 0; i < lastIndex; i++) { // It is faster not to use a template string here str += output[i]; str += separator; } - str += output[i]; + str += output[lastIndex]; } return str; } diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 21b9921dbe..1e7277ef38 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -312,7 +312,8 @@ function strEscape(str) { let result = ''; let last = 0; - for (var i = 0; i < str.length; i++) { + const lastIndex = str.length; + for (let i = 0; i < lastIndex; i++) { const point = str.charCodeAt(i); if (point === singleQuote || point === 92 || point < 32) { if (last === i) { @@ -324,7 +325,7 @@ function strEscape(str) { } } - if (last !== i) { + if (last !== lastIndex) { result += str.slice(last); } return addQuotes(result, singleQuote); @@ -1061,10 +1062,11 @@ function formatPrimitive(fn, value, ctx) { if (matches.length > 1) { const indent = ' '.repeat(ctx.indentationLvl); let res = `${fn(strEscape(matches[0]), 'string')} +\n`; - for (var i = 1; i < matches.length - 1; i++) { + const lastIndex = matches.length - 1; + for (let i = 1; i < lastIndex; i++) { res += `${indent} ${fn(strEscape(matches[i]), 'string')} +\n`; } - res += `${indent} ${fn(strEscape(matches[i]), 'string')}`; + res += `${indent} ${fn(strEscape(matches[lastIndex]), 'string')}`; return res; } } @@ -1187,10 +1189,10 @@ function formatTypedArray(ctx, value, recurseTimes) { const elementFormatter = value.length > 0 && typeof value[0] === 'number' ? formatNumber : formatBigInt; - for (var i = 0; i < maxLength; ++i) + for (let i = 0; i < maxLength; ++i) output[i] = elementFormatter(ctx.stylize, value[i]); if (remaining > 0) { - output[i] = `... ${remaining} more item${remaining > 1 ? 's' : ''}`; + output[maxLength] = `... ${remaining} more item${remaining > 1 ? 's' : ''}`; } if (ctx.showHidden) { // .buffer goes last, it's not a primitive like the others. diff --git a/lib/url.js b/lib/url.js index be483ae2bc..665bd43614 100644 --- a/lib/url.js +++ b/lib/url.js @@ -267,9 +267,10 @@ Url.prototype.parse = function parse(url, parseQueryString, slashesDenoteHost) { // user@server is *always* interpreted as a hostname, and url // resolution will treat //foo/bar as host=foo,path=bar because that's // how the browser resolves relative URLs. + let slashes; if (slashesDenoteHost || proto || hostPattern.test(rest)) { - var slashes = rest.charCodeAt(0) === CHAR_FORWARD_SLASH && - rest.charCodeAt(1) === CHAR_FORWARD_SLASH; + slashes = rest.charCodeAt(0) === CHAR_FORWARD_SLASH && + rest.charCodeAt(1) === CHAR_FORWARD_SLASH; if (slashes && !(proto && hostlessProtocol.has(lowerProto))) { rest = rest.slice(2); this.slashes = true; |