diff --git a/.eslintrc.js b/.eslintrc.js index 53d0b39d0aea44..0d80cc3b743d2d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -145,7 +145,7 @@ module.exports = { { property: '__defineSetter__', message: '__defineSetter__ is deprecated.', - } + }, ], /* eslint-disable max-len, quotes */ // If this list is modified, please copy the change to lib/.eslintrc.yaml @@ -178,7 +178,7 @@ module.exports = { { selector: 'ThrowStatement > CallExpression[callee.name=/Error$/]', message: 'Use new keyword when throwing an Error.', - } + }, ], /* eslint-enable max-len, quotes */ 'no-return-await': 'error', diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index 80cada0b8c9ecc..98d6f58f97353f 100644 --- a/lib/.eslintrc.yaml +++ b/lib/.eslintrc.yaml @@ -25,6 +25,15 @@ rules: node-core/no-let-in-for-declaration: error node-core/lowercase-name-for-primitive: error node-core/non-ascii-character: error + # Rules specific to /lib + comma-dangle: [error, { + arrays: "always-multiline", + objects: "only-multiline", + imports: "only-multiline", + exports: "only-multiline", + functions: "only-multiline" + }] + globals: CHECK: false CHECK_EQ: false diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index d85d85752b631b..8d99de6dd1a8ab 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -347,7 +347,7 @@ var proxiedMethods = [ 'setSimultaneousAccepts', 'setBlocking', // PipeWrap - 'setPendingInstances' + 'setPendingInstances', ]; // Proxy HandleWrap, PipeWrap and TCPWrap methods diff --git a/lib/assert.js b/lib/assert.js index 45ddbe5f817d36..541618c7ebd766 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -48,7 +48,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[str.charCodeAt(0)]; diff --git a/lib/console.js b/lib/console.js index 46b7f7627eddae..d814738d388af6 100644 --- a/lib/console.js +++ b/lib/console.js @@ -355,7 +355,7 @@ Console.prototype.table = function(tabularData, properties) { length++; } return final([ - iterKey, keyKey, valuesKey + iterKey, keyKey, valuesKey, ], [ getIndexArray(length), keys, diff --git a/lib/dns.js b/lib/dns.js index 62faf32b690735..c219489d1d5a10 100644 --- a/lib/dns.js +++ b/lib/dns.js @@ -346,7 +346,7 @@ const resolverKeys = [ 'resolvePtr', 'resolveNaptr', 'resolveSoa', - 'reverse' + 'reverse', ]; function setExportsFunctions() { diff --git a/lib/internal/bootstrap/loaders.js b/lib/internal/bootstrap/loaders.js index 828370f6eadd01..1fa259a128f48a 100644 --- a/lib/internal/bootstrap/loaders.js +++ b/lib/internal/bootstrap/loaders.js @@ -190,7 +190,7 @@ NativeModule.wrapper = [ '(function (exports, require, module, process) {', - '\n});' + '\n});', ]; NativeModule.prototype.compile = function() { diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js index 5993cc71f7d404..7b974d96f03a38 100644 --- a/lib/internal/bootstrap/node.js +++ b/lib/internal/bootstrap/node.js @@ -130,7 +130,7 @@ 'isArrayBuffer', 'isArrayBufferView', 'isAsyncFunction', 'isDataView', 'isDate', 'isExternal', 'isMap', 'isMapIterator', 'isNativeError', 'isPromise', 'isRegExp', 'isSet', 'isSetIterator', - 'isTypedArray', 'isUint8Array', 'isAnyArrayBuffer' + 'isTypedArray', 'isUint8Array', 'isAnyArrayBuffer', ]) { utilBinding[name] = pendingDeprecation ? deprecate(types[name], diff --git a/lib/internal/encoding.js b/lib/internal/encoding.js index ae874c530ccce9..a8397dabfc4584 100644 --- a/lib/internal/encoding.js +++ b/lib/internal/encoding.js @@ -271,7 +271,7 @@ const encodings = new Map([ ['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/http2/util.js b/lib/internal/http2/util.js index bf5d07219391e2..e559253c4f4ec8 100644 --- a/lib/internal/http2/util.js +++ b/lib/internal/http2/util.js @@ -78,7 +78,7 @@ const kValidPseudoHeaders = new Set([ HTTP2_HEADER_METHOD, HTTP2_HEADER_AUTHORITY, HTTP2_HEADER_SCHEME, - HTTP2_HEADER_PATH + HTTP2_HEADER_PATH, ]); // This set contains headers that are permitted to have only a single @@ -121,7 +121,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 @@ -131,7 +131,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/modules/cjs/helpers.js b/lib/internal/modules/cjs/helpers.js index 60346c5841c7df..8b7820d2d8a9d6 100644 --- a/lib/internal/modules/cjs/helpers.js +++ b/lib/internal/modules/cjs/helpers.js @@ -102,7 +102,7 @@ const builtinLibs = [ 'dgram', 'dns', 'domain', 'events', 'fs', 'http', 'http2', 'https', 'net', 'os', 'path', 'perf_hooks', 'punycode', 'querystring', 'readline', 'repl', 'stream', 'string_decoder', 'tls', 'trace_events', 'tty', 'url', 'util', - 'v8', 'vm', 'zlib' + 'v8', 'vm', 'zlib', ]; if (typeof process.binding('inspector').open === 'function') { diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index 8a4974225049ce..f68634d3a7e517 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -118,7 +118,7 @@ Module.wrap = function(script) { Module.wrapper = [ '(function (exports, require, module, __filename, __dirname) { ', - '\n});' + '\n});', ]; const debug = util.debuglog('module'); diff --git a/lib/internal/process.js b/lib/internal/process.js index cc8318cbe3ce53..6587a1982781d7 100644 --- a/lib/internal/process.js +++ b/lib/internal/process.js @@ -119,7 +119,7 @@ function setup_hrtime() { return [ hrValues[0] * 0x100000000 + hrValues[1], - hrValues[2] + hrValues[2], ]; }; } diff --git a/lib/internal/process/next_tick.js b/lib/internal/process/next_tick.js index dbe0ce8cdbdacf..55322e15d5893d 100644 --- a/lib/internal/process/next_tick.js +++ b/lib/internal/process/next_tick.js @@ -25,7 +25,7 @@ function setupNextTick() { // runMicrotasks is used to run V8's micro task queue. const [ tickInfo, - runMicrotasks + runMicrotasks, ] = process._setupNextTick(_tickCallback); // *Must* match Environment::TickInfo::Fields in src/env.h. diff --git a/lib/internal/querystring.js b/lib/internal/querystring.js index d1684418097100..6e4e6707a64053 100644 --- a/lib/internal/querystring.js +++ b/lib/internal/querystring.js @@ -20,7 +20,7 @@ const isHexTable = [ 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 ]; module.exports = { diff --git a/lib/internal/safe_globals.js b/lib/internal/safe_globals.js index ad58fa662b53ef..4357f8a14afc29 100644 --- a/lib/internal/safe_globals.js +++ b/lib/internal/safe_globals.js @@ -2,7 +2,7 @@ const copyProps = (unsafe, safe) => { for (const key of [...Object.getOwnPropertyNames(unsafe), - ...Object.getOwnPropertySymbols(unsafe) + ...Object.getOwnPropertySymbols(unsafe), ]) { if (!Object.getOwnPropertyDescriptor(safe, key)) { Object.defineProperty( diff --git a/lib/internal/tty.js b/lib/internal/tty.js index c4edab24fb87ab..c41675e05b5aee 100644 --- a/lib/internal/tty.js +++ b/lib/internal/tty.js @@ -52,7 +52,7 @@ const TERM_ENVS = [ 'mlterm', 'putty', 'st', - 'terminator' + 'terminator', ]; const TERM_ENVS_REG_EXP = [ @@ -63,7 +63,7 @@ const TERM_ENVS_REG_EXP = [ /^rxvt/, /^screen/, /^xterm/, - /^vt100/ + /^vt100/, ]; // The `getColorDepth` API got inspired by multiple sources such as diff --git a/lib/internal/url.js b/lib/internal/url.js index d9daef1524787d..970c9c6b4cd8d1 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -811,7 +811,7 @@ const noEscape = [ 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/v8_prof_processor.js b/lib/internal/v8_prof_processor.js index 6c7a4db6641935..ff317ac1456078 100644 --- a/lib/internal/v8_prof_processor.js +++ b/lib/internal/v8_prof_processor.js @@ -14,7 +14,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', ]; var script = ''; diff --git a/lib/perf_hooks.js b/lib/perf_hooks.js index 9080cc7f26ca29..fe3354c2572dd6 100644 --- a/lib/perf_hooks.js +++ b/lib/perf_hooks.js @@ -63,7 +63,7 @@ const observerableTypes = [ 'measure', 'gc', 'function', - 'http2' + 'http2', ]; const IDX_STREAM_STATS_ID = 0; diff --git a/lib/querystring.js b/lib/querystring.js index ba676d8c6d7fab..f4d6edc4d7a7d5 100644 --- a/lib/querystring.js +++ b/lib/querystring.js @@ -60,7 +60,7 @@ const unhexTable = [ -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 function unescapeBuffer(s, decodeSpaces) { @@ -129,7 +129,7 @@ const noEscape = [ 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 ]; // QueryString.escape() replaces encodeURIComponent() // http://www.ecma-international.org/ecma-262/5.1/#sec-15.1.3.4 diff --git a/lib/repl.js b/lib/repl.js index 600816a6058fbc..0336013423017f 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -81,7 +81,7 @@ const GLOBAL_OBJECT_PROPERTIES = [ 'isFinite', 'decodeURI', 'decodeURIComponent', 'encodeURI', 'encodeURIComponent', 'Object', 'Function', 'Array', 'String', 'Boolean', 'Number', 'Date', 'RegExp', 'Error', 'EvalError', 'RangeError', - 'ReferenceError', 'SyntaxError', 'TypeError', 'URIError', 'Math', 'JSON' + 'ReferenceError', 'SyntaxError', 'TypeError', 'URIError', 'Math', 'JSON', ]; const GLOBAL_OBJECT_PROPERTY_MAP = {}; for (var n = 0; n < GLOBAL_OBJECT_PROPERTIES.length; n++) { @@ -1356,7 +1356,7 @@ function addStandardGlobals(completionGroups, filter) { 'debugger', 'default', 'delete', 'do', 'else', 'export', 'false', 'finally', 'for', 'function', 'if', 'import', 'in', 'instanceof', 'let', 'new', 'null', 'return', 'switch', 'this', 'throw', 'true', 'try', - 'typeof', 'undefined', 'var', 'void', 'while', 'with', 'yield' + 'typeof', 'undefined', 'var', 'void', 'while', 'with', 'yield', ]); } } diff --git a/lib/url.js b/lib/url.js index e4326e80b5d948..70a51ebc00ba9f 100644 --- a/lib/url.js +++ b/lib/url.js @@ -491,7 +491,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. @@ -555,7 +555,7 @@ const noEscapeAuth = [ 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() { diff --git a/lib/util.js b/lib/util.js index 45d98de194c836..cce84558aa51fa 100644 --- a/lib/util.js +++ b/lib/util.js @@ -121,7 +121,7 @@ const meta = [ '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', - '', '', '', '', '', '', '', '\\\\' + '', '', '', '', '', '', '', '\\\\', ]; const escapeFn = (str) => meta[str.charCodeAt(0)]; @@ -445,7 +445,7 @@ function formatValue(ctx, value, recurseTimes, ln) { ctx.indentationLvl += 2; const res = [ formatValue(ctx, proxy[0], recurseTimes), - formatValue(ctx, proxy[1], recurseTimes) + formatValue(ctx, proxy[1], recurseTimes), ]; ctx.indentationLvl -= 2; const str = reduceToSingleString(ctx, res, '', ['[', ']']); @@ -867,7 +867,7 @@ function formatTypedArray(ctx, value, recurseTimes, keys) { 'length', 'byteLength', 'byteOffset', - 'buffer' + 'buffer', ]; for (i = 0; i < extraKeys.length; i++) { const str = formatValue(ctx, value[extraKeys[i]], recurseTimes);