From d56e8268f969c761ae6fcc7145774595b7193e72 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 6 Feb 2021 05:36:58 -0800 Subject: [PATCH] doc,lib: prepare for stricter multi-line array linting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We're about to turn on a requirement for dangling commas. PR-URL: https://github.com/nodejs/node/pull/37088 Reviewed-By: Michaƫl Zasso Reviewed-By: Antoine du Hamel --- doc/api/child_process.md | 4 ++-- doc/api/dns.md | 8 ++++---- doc/api/os.md | 2 +- doc/api/url.md | 6 +++--- lib/assert.js | 4 ++-- lib/internal/bootstrap/loaders.js | 2 +- lib/internal/bootstrap/pre_execution.js | 2 +- lib/internal/console/constructor.js | 2 +- lib/internal/crypto/random.js | 2 +- lib/internal/encoding.js | 2 +- lib/internal/errors.js | 2 +- lib/internal/freeze_intrinsics.js | 4 ++-- lib/internal/http2/util.js | 6 +++--- lib/internal/main/print_help.js | 6 +++--- lib/internal/modules/cjs/loader.js | 2 +- lib/internal/process/per_thread.js | 2 +- lib/internal/querystring.js | 2 +- lib/internal/streams/pipeline.js | 2 +- lib/internal/tty.js | 2 +- lib/internal/url.js | 2 +- lib/internal/util/comparisons.js | 2 +- lib/internal/util/inspect.js | 8 ++++---- lib/internal/v8_prof_processor.js | 2 +- lib/perf_hooks.js | 2 +- lib/querystring.js | 4 ++-- lib/readline.js | 2 +- lib/repl.js | 2 +- lib/url.js | 10 +++++----- 28 files changed, 48 insertions(+), 48 deletions(-) diff --git a/doc/api/child_process.md b/doc/api/child_process.md index 60fe875ace69eb..c209dff8b0d2c8 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -1326,7 +1326,7 @@ const subprocess = spawn( '-c', `node -e "setInterval(() => { console.log(process.pid, 'is alive') - }, 500);"` + }, 500);"`, ], { stdio: ['inherit', 'inherit', 'inherit'] } @@ -1661,7 +1661,7 @@ const subprocess = child_process.spawn('ls', { stdio: [ 0, // Use parent's stdin for child. 'pipe', // Pipe child's stdout to parent. - fs.openSync('err.out', 'w') // Direct child's stderr to a file. + fs.openSync('err.out', 'w'), // Direct child's stderr to a file. ] }); diff --git a/doc/api/dns.md b/doc/api/dns.md index 9baaf333a3cdd6..1dc93463fd0ba8 100644 --- a/doc/api/dns.md +++ b/doc/api/dns.md @@ -160,7 +160,7 @@ section if a custom port is used. '4.4.4.4', '2001:4860:4860::8888', '4.4.4.4:1053', - '[2001:4860:4860::8888]:1053' + '[2001:4860:4860::8888]:1053', ] ``` @@ -666,7 +666,7 @@ dns.setServers([ '4.4.4.4', '[2001:4860:4860::8888]', '4.4.4.4:1053', - '[2001:4860:4860::8888]:1053' + '[2001:4860:4860::8888]:1053', ]); ``` @@ -773,7 +773,7 @@ section if a custom port is used. '4.4.4.4', '2001:4860:4860::8888', '4.4.4.4:1053', - '[2001:4860:4860::8888]:1053' + '[2001:4860:4860::8888]:1053', ] ``` @@ -1184,7 +1184,7 @@ dnsPromises.setServers([ '4.4.4.4', '[2001:4860:4860::8888]', '4.4.4.4:1053', - '[2001:4860:4860::8888]:1053' + '[2001:4860:4860::8888]:1053', ]); ``` diff --git a/doc/api/os.md b/doc/api/os.md index ab39a81904149f..0f6e1d5dd23d83 100644 --- a/doc/api/os.md +++ b/doc/api/os.md @@ -115,7 +115,7 @@ The properties included on each object include: idle: 1070905480, irq: 20 } - } + }, ] ``` diff --git a/doc/api/url.md b/doc/api/url.md index 07311bd64c458f..ed9bfd4244181c 100644 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -573,7 +573,7 @@ with [`JSON.stringify()`][]. ```js const myURLs = [ new URL('https://www.example.com'), - new URL('https://test.example.org') + new URL('https://test.example.org'), ]; console.log(JSON.stringify(myURLs)); // Prints ["https://www.example.com/","https://test.example.org/"] @@ -710,7 +710,7 @@ let params; params = new URLSearchParams([ ['user', 'abc'], ['query', 'first'], - ['query', 'second'] + ['query', 'second'], ]); console.log(params.toString()); // Prints 'user=abc&query=first&query=second' @@ -735,7 +735,7 @@ console.log(params.toString()); // Each key-value pair must have exactly two elements new URLSearchParams([ - ['user', 'abc', 'error'] + ['user', 'abc', 'error'], ]); // Throws TypeError [ERR_INVALID_TUPLE]: // Each query pair must be an iterable [name, value] tuple diff --git a/lib/assert.js b/lib/assert.js index f0118f698dfa1a..deb73bc54b92ea 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -91,7 +91,7 @@ const meta = [ '\\u000f', '\\u0010', '\\u0011', '\\u0012', '\\u0013', '\\u0014', '\\u0015', '\\u0016', '\\u0017', '\\u0018', '\\u0019', '\\u001a', '\\u001b', '\\u001c', '\\u001d', - '\\u001e', '\\u001f' + '\\u001e', '\\u001f', ]; const escapeFn = (str) => meta[StringPrototypeCharCodeAt(str, 0)]; @@ -268,7 +268,7 @@ function parseCode(code, offset) { node.node.start, StringPrototypeReplace(StringPrototypeSlice(code, node.node.start, node.node.end), - escapeSequencesRegExp, escapeFn) + escapeSequencesRegExp, escapeFn), ]; } diff --git a/lib/internal/bootstrap/loaders.js b/lib/internal/bootstrap/loaders.js index 10a4e0b1b87e09..852aca8e622032 100644 --- a/lib/internal/bootstrap/loaders.js +++ b/lib/internal/bootstrap/loaders.js @@ -103,7 +103,7 @@ const internalBindingAllowlist = new SafeSet([ 'util', 'uv', 'v8', - 'zlib' + 'zlib', ]); // Set up process.binding() and process._linkedBinding(). diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js index 7cfe3f994f67bd..c87592661e1db9 100644 --- a/lib/internal/bootstrap/pre_execution.js +++ b/lib/internal/bootstrap/pre_execution.js @@ -252,7 +252,7 @@ function initializeDeprecations() { 'isSetIterator', 'isTypedArray', 'isUint8Array', - 'isAnyArrayBuffer' + 'isAnyArrayBuffer', ]) { utilBinding[name] = pendingDeprecation ? deprecate(types[name], diff --git a/lib/internal/console/constructor.js b/lib/internal/console/constructor.js index 34d187964eb296..c3716a8acda8b5 100644 --- a/lib/internal/console/constructor.js +++ b/lib/internal/console/constructor.js @@ -532,7 +532,7 @@ const consoleMethods = { } } return final([ - iterKey, keyKey, valuesKey + iterKey, keyKey, valuesKey, ], [ getIndexArray(length), keys, diff --git a/lib/internal/crypto/random.js b/lib/internal/crypto/random.js index 4425183537a4df..21eb9aa125bc2f 100644 --- a/lib/internal/crypto/random.js +++ b/lib/internal/crypto/random.js @@ -223,7 +223,7 @@ function handleError(ex, buf) { const kHexDigits = [ 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 97, 98, 99, 100, 101, 102 + 56, 57, 97, 98, 99, 100, 101, 102, ]; const kBatchSize = 128; diff --git a/lib/internal/encoding.js b/lib/internal/encoding.js index 8f1cd57ade8e9f..f6e52238a1270c 100644 --- a/lib/internal/encoding.js +++ b/lib/internal/encoding.js @@ -286,7 +286,7 @@ const encodings = new SafeMap([ ['windows-949', 'euc-kr'], ['utf-16be', 'utf-16be'], ['utf-16le', 'utf-16le'], - ['utf-16', 'utf-16le'] + ['utf-16', 'utf-16le'], ]); // Unfortunately, String.prototype.trim also removes non-ascii whitespace, diff --git a/lib/internal/errors.js b/lib/internal/errors.js index cac666ae93a4ca..2e0cc23a2b2929 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -70,7 +70,7 @@ const kTypes = [ 'Object', 'boolean', 'bigint', - 'symbol' + 'symbol', ]; const MainContextError = Error; diff --git a/lib/internal/freeze_intrinsics.js b/lib/internal/freeze_intrinsics.js index d4a72ccebabd55..b5dd48ee07ceda 100644 --- a/lib/internal/freeze_intrinsics.js +++ b/lib/internal/freeze_intrinsics.js @@ -212,7 +212,7 @@ module.exports = function() { WebAssembly.CompileError.prototype, WebAssembly.LinkError.prototype, WebAssembly.RuntimeError.prototype, - SharedArrayBuffer.prototype + SharedArrayBuffer.prototype, ]; const intrinsics = [ // Anonymous Intrinsics @@ -326,7 +326,7 @@ module.exports = function() { BigInt, Atomics, WebAssembly, - SharedArrayBuffer + SharedArrayBuffer, ]; if (typeof Intl !== 'undefined') { diff --git a/lib/internal/http2/util.js b/lib/internal/http2/util.js index 10080dc71a1b00..414ce3649a49fc 100644 --- a/lib/internal/http2/util.js +++ b/lib/internal/http2/util.js @@ -103,7 +103,7 @@ const kValidPseudoHeaders = new Set([ HTTP2_HEADER_AUTHORITY, HTTP2_HEADER_SCHEME, HTTP2_HEADER_PATH, - HTTP2_HEADER_PROTOCOL + HTTP2_HEADER_PROTOCOL, ]); // This set contains headers that are permitted to have only a single @@ -147,7 +147,7 @@ const kSingleValueHeaders = new Set([ HTTP2_HEADER_TK, HTTP2_HEADER_UPGRADE_INSECURE_REQUESTS, HTTP2_HEADER_USER_AGENT, - HTTP2_HEADER_X_CONTENT_TYPE_OPTIONS + HTTP2_HEADER_X_CONTENT_TYPE_OPTIONS, ]); // The HTTP methods in this set are specifically defined as assigning no @@ -157,7 +157,7 @@ const kSingleValueHeaders = new Set([ const kNoPayloadMethods = new Set([ HTTP2_METHOD_DELETE, HTTP2_METHOD_GET, - HTTP2_METHOD_HEAD + HTTP2_METHOD_HEAD, ]); // The following ArrayBuffer instances are used to share memory more efficiently diff --git a/lib/internal/main/print_help.js b/lib/internal/main/print_help.js index 70ef8e33c8f263..6aa422c657b2d0 100644 --- a/lib/internal/main/print_help.js +++ b/lib/internal/main/print_help.js @@ -60,13 +60,13 @@ const envVars = new SafeMap(ArrayPrototypeConcat([ ['NODE_V8_COVERAGE', { helpText: 'directory to output v8 coverage JSON ' + 'to' }], ['UV_THREADPOOL_SIZE', { helpText: 'sets the number of threads used in ' + - 'libuv\'s threadpool' }] + 'libuv\'s threadpool' }], ], hasIntl ? [ ['NODE_ICU_DATA', { helpText: 'data path for ICU (Intl object) data' + - hasSmallICU ? '' : ' (will extend linked-in data)' }] + hasSmallICU ? '' : ' (will extend linked-in data)' }], ] : []), (hasNodeOptions ? [ ['NODE_OPTIONS', { helpText: 'set CLI options in the environment via a ' + - 'space-separated list' }] + 'space-separated list' }], ] : []), hasCrypto ? [ ['OPENSSL_CONF', { helpText: 'load OpenSSL configuration from file' }], ['SSL_CERT_DIR', { helpText: 'sets OpenSSL\'s directory of trusted ' + diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index 33ae5eb6ed9686..92071f641a7169 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -196,7 +196,7 @@ let wrap = function(script) { const wrapper = [ '(function (exports, require, module, __filename, __dirname) { ', - '\n});' + '\n});', ]; let wrapperProxy = new Proxy(wrapper, { diff --git a/lib/internal/process/per_thread.js b/lib/internal/process/per_thread.js index 61e4b35c03385f..44a724073c4511 100644 --- a/lib/internal/process/per_thread.js +++ b/lib/internal/process/per_thread.js @@ -138,7 +138,7 @@ function wrapProcessMethods(binding) { return [ hrValues[0] * 0x100000000 + hrValues[1], - hrValues[2] + hrValues[2], ]; } diff --git a/lib/internal/querystring.js b/lib/internal/querystring.js index 505950e462e7ad..68f52c90c27237 100644 --- a/lib/internal/querystring.js +++ b/lib/internal/querystring.js @@ -33,7 +33,7 @@ const isHexTable = new Int8Array([ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // ... 256 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // ... 256 ]); /** diff --git a/lib/internal/streams/pipeline.js b/lib/internal/streams/pipeline.js index 6483e9829eddc3..16a5d2bbce9feb 100644 --- a/lib/internal/streams/pipeline.js +++ b/lib/internal/streams/pipeline.js @@ -221,7 +221,7 @@ function pipeline(...streams) { pt.end(val); }, (err) => { pt.destroy(err); - } + }, ]); } else if (isIterable(ret, true)) { finishCount++; diff --git a/lib/internal/tty.js b/lib/internal/tty.js index f4f05f971c2713..5a247c7928c346 100644 --- a/lib/internal/tty.js +++ b/lib/internal/tty.js @@ -77,7 +77,7 @@ const TERM_ENVS_REG_EXP = [ /^rxvt/, /^screen/, /^xterm/, - /^vt100/ + /^vt100/, ]; let warned = false; diff --git a/lib/internal/url.js b/lib/internal/url.js index e8568a68ed043a..c85c44361c069a 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -844,7 +844,7 @@ const noEscape = new Int8Array([ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40 - 0x4F 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, // 0x50 - 0x5F 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 - 0x6F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 // 0x70 - 0x7F + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, // 0x70 - 0x7F ]); // Special version of hexTable that uses `+` for U+0020 SPACE. diff --git a/lib/internal/util/comparisons.js b/lib/internal/util/comparisons.js index 5f0fa88247565b..d4f4597d9b0908 100644 --- a/lib/internal/util/comparisons.js +++ b/lib/internal/util/comparisons.js @@ -142,7 +142,7 @@ function isIdenticalTypedArrayType(a, b) { isBigInt64Array, isBigUint64Array, isUint8ClampedArray, - isUint8Array + isUint8Array, ]) { if (check(a)) { return check(b); diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index eae2e7bb7836b4..f1d4e283df2dd0 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -695,7 +695,7 @@ function formatProxy(ctx, proxy, recurseTimes) { ctx.indentationLvl += 2; const res = [ formatValue(ctx, proxy[0], recurseTimes), - formatValue(ctx, proxy[1], recurseTimes) + formatValue(ctx, proxy[1], recurseTimes), ]; ctx.indentationLvl -= 2; return reduceToSingleString( @@ -1513,7 +1513,7 @@ function formatTypedArray(value, length, ctx, ignored, recurseTimes) { 'length', 'byteLength', 'byteOffset', - 'buffer' + 'buffer', ]) { const str = formatValue(ctx, value[key], recurseTimes, true); output.push(`[${key}]: ${str}`); @@ -1591,7 +1591,7 @@ function formatMapIterInner(ctx, recurseTimes, entries, state) { const pos = i * 2; const res = [ formatValue(ctx, entries[pos], recurseTimes), - formatValue(ctx, entries[pos + 1], recurseTimes) + formatValue(ctx, entries[pos + 1], recurseTimes), ]; output[i] = reduceToSingleString( ctx, res, '', ['[', ']'], kArrayExtrasType, recurseTimes); @@ -1641,7 +1641,7 @@ function formatPromise(ctx, value, recurseTimes) { output = [ state === kRejected ? `${ctx.stylize('', 'special')} ${str}` : - str + str, ]; } return output; diff --git a/lib/internal/v8_prof_processor.js b/lib/internal/v8_prof_processor.js index daae650b2ad8ef..0136bc7ba48623 100644 --- a/lib/internal/v8_prof_processor.js +++ b/lib/internal/v8_prof_processor.js @@ -20,7 +20,7 @@ const scriptFiles = [ 'internal/deps/v8/tools/arguments', 'internal/deps/v8/tools/tickprocessor', 'internal/deps/v8/tools/SourceMap', - 'internal/deps/v8/tools/tickprocessor-driver' + 'internal/deps/v8/tools/tickprocessor-driver', ]; let script = ''; diff --git a/lib/perf_hooks.js b/lib/perf_hooks.js index b5544db68ff3de..40e20cbc3e2540 100644 --- a/lib/perf_hooks.js +++ b/lib/perf_hooks.js @@ -94,7 +94,7 @@ const observerableTypes = [ 'gc', 'function', 'http2', - 'http' + 'http', ]; const IDX_STREAM_STATS_ID = 0; diff --git a/lib/querystring.js b/lib/querystring.js index 84e93817f96e89..5bcfa13a6a5b13 100644 --- a/lib/querystring.js +++ b/lib/querystring.js @@ -74,7 +74,7 @@ const unhexTable = new Int8Array([ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 // ... 255 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // ... 255 ]); /** * A safe fast alternative to decodeURIComponent @@ -152,7 +152,7 @@ const noEscape = new Int8Array([ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 64 - 79 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, // 80 - 95 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 96 - 111 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0 // 112 - 127 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, // 112 - 127 ]); /** diff --git a/lib/readline.js b/lib/readline.js index 8e1168b4286dc2..32737b37dccf14 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -144,7 +144,7 @@ function Interface(input, output, completer, terminal) { this.escapeCodeTimeout = ESCAPE_CODE_TIMEOUT; this.tabSize = 8; - FunctionPrototypeCall(EventEmitter, this,); + FunctionPrototypeCall(EventEmitter, this); let history; let historySize; let removeHistoryDuplicates = false; diff --git a/lib/repl.js b/lib/repl.js index 79917beb3ca3b2..743a7b78bde074 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -1631,7 +1631,7 @@ function addCommonWords(completionGroups) { 'debugger', 'default', 'delete', 'do', 'else', 'export', 'false', 'finally', 'for', 'function', 'if', 'import', 'in', 'instanceof', 'let', 'new', 'null', 'return', 'switch', 'this', 'throw', 'true', 'try', - 'typeof', 'var', 'void', 'while', 'with', 'yield' + 'typeof', 'var', 'void', 'while', 'with', 'yield', ]); } diff --git a/lib/url.js b/lib/url.js index 0fb81e277c512b..177bd9eb59ca44 100644 --- a/lib/url.js +++ b/lib/url.js @@ -86,12 +86,12 @@ const hostnameMaxLen = 255; // Protocols that can allow "unsafe" and "unwise" chars. const unsafeProtocol = new SafeSet([ 'javascript', - 'javascript:' + 'javascript:', ]); // Protocols that never have a hostname. const hostlessProtocol = new SafeSet([ 'javascript', - 'javascript:' + 'javascript:', ]); // Protocols that always contain a // bit. const slashedProtocol = new SafeSet([ @@ -108,7 +108,7 @@ const slashedProtocol = new SafeSet([ 'ws', 'ws:', 'wss', - 'wss:' + 'wss:', ]); const { CHAR_SPACE, @@ -516,7 +516,7 @@ const escapedCodes = [ /* 90 - 99 */ '', '', '%5C', '', '%5E', '', '%60', '', '', '', /* 100 - 109 */ '', '', '', '', '', '', '', '', '', '', /* 110 - 119 */ '', '', '', '', '', '', '', '', '', '', - /* 120 - 125 */ '', '', '', '%7B', '%7C', '%7D' + /* 120 - 125 */ '', '', '', '%7B', '%7C', '%7D', ]; // Automatically escape all delimiters and unwise characters from RFC 2396. @@ -580,7 +580,7 @@ const noEscapeAuth = new Int8Array([ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40 - 0x4F 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, // 0x50 - 0x5F 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 - 0x6F - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0 // 0x70 - 0x7F + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, // 0x70 - 0x7F ]); Url.prototype.format = function format() {