Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: enforce use of trailing commas for functions #46629

Merged
merged 1 commit into from Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/.eslintrc.yaml
Expand Up @@ -5,7 +5,7 @@ rules:
comma-dangle: [error, {
arrays: always-multiline,
exports: always-multiline,
functions: only-multiline,
functions: always-multiline,
imports: always-multiline,
objects: only-multiline,
}]
Expand Down
2 changes: 1 addition & 1 deletion lib/_http_agent.js
Expand Up @@ -396,7 +396,7 @@ function installListeners(agent, s, options) {
// TODO(ronag): Always destroy, even if not in free list.
const sockets = agent.freeSockets;
if (ArrayPrototypeSome(ObjectKeys(sockets), (name) =>
ArrayPrototypeIncludes(sockets[name], s)
ArrayPrototypeIncludes(sockets[name], s),
)) {
return s.destroy();
}
Expand Down
8 changes: 4 additions & 4 deletions lib/_http_server.js
Expand Up @@ -609,7 +609,7 @@ function checkConnections() {

function connectionListener(socket) {
defaultTriggerAsyncIdScope(
getOrSetAsyncId(socket), connectionListenerInternal, this, socket
getOrSetAsyncId(socket), connectionListenerInternal, this, socket,
);
}

Expand Down Expand Up @@ -812,15 +812,15 @@ function onParserTimeout(server, socket) {
const noop = () => {};
const badRequestResponse = Buffer.from(
`HTTP/1.1 400 ${STATUS_CODES[400]}\r\n` +
'Connection: close\r\n\r\n', 'ascii'
'Connection: close\r\n\r\n', 'ascii',
);
const requestTimeoutResponse = Buffer.from(
`HTTP/1.1 408 ${STATUS_CODES[408]}\r\n` +
'Connection: close\r\n\r\n', 'ascii'
'Connection: close\r\n\r\n', 'ascii',
);
const requestHeaderFieldsTooLargeResponse = Buffer.from(
`HTTP/1.1 431 ${STATUS_CODES[431]}\r\n` +
'Connection: close\r\n\r\n', 'ascii'
'Connection: close\r\n\r\n', 'ascii',
);
function socketOnError(e) {
// Ignore further errors
Expand Down
20 changes: 10 additions & 10 deletions lib/_tls_wrap.js
Expand Up @@ -171,7 +171,7 @@ function onhandshakedone() {
function loadSession(hello) {
debug('server onclienthello',
'sessionid.len', hello.sessionId.length,
'ticket?', hello.tlsTicket
'ticket?', hello.tlsTicket,
);
const owner = this[owner_symbol];

Expand Down Expand Up @@ -350,7 +350,7 @@ function onPskServerCallback(identity, maxPskLen) {
throw new ERR_INVALID_ARG_TYPE(
'ret',
['Object', 'Buffer', 'TypedArray', 'DataView'],
ret
ret,
);
}
psk = ret.psk;
Expand All @@ -361,7 +361,7 @@ function onPskServerCallback(identity, maxPskLen) {
throw new ERR_INVALID_ARG_VALUE(
'psk',
psk,
`Pre-shared key exceeds ${maxPskLen} bytes`
`Pre-shared key exceeds ${maxPskLen} bytes`,
);
}

Expand All @@ -381,7 +381,7 @@ function onPskClientCallback(hint, maxPskLen, maxIdentityLen) {
throw new ERR_INVALID_ARG_VALUE(
'psk',
ret.psk,
`Pre-shared key exceeds ${maxPskLen} bytes`
`Pre-shared key exceeds ${maxPskLen} bytes`,
);
}

Expand All @@ -390,7 +390,7 @@ function onPskClientCallback(hint, maxPskLen, maxIdentityLen) {
throw new ERR_INVALID_ARG_VALUE(
'identity',
ret.identity,
`PSK identity exceeds ${maxIdentityLen} bytes`
`PSK identity exceeds ${maxIdentityLen} bytes`,
);
}

Expand Down Expand Up @@ -447,7 +447,7 @@ function initRead(tlsSocket, socket) {
debug('%s initRead',
tlsSocket._tlsOptions.isServer ? 'server' : 'client',
'handle?', !!tlsSocket._handle,
'buffered?', !!socket && socket.readableLength
'buffered?', !!socket && socket.readableLength,
);
// If we were destroyed already don't bother reading
if (!tlsSocket._handle)
Expand Down Expand Up @@ -689,7 +689,7 @@ TLSSocket.prototype._init = function(socket, wrap) {

debug('%s _init',
options.isServer ? 'server' : 'client',
'handle?', !!ssl
'handle?', !!ssl,
);

// Clients (!isServer) always request a cert, servers request a client cert
Expand Down Expand Up @@ -846,7 +846,7 @@ TLSSocket.prototype.renegotiate = function(options, callback) {

debug('%s renegotiate()',
this._tlsOptions.isServer ? 'server' : 'client',
'destroyed?', this.destroyed
'destroyed?', this.destroyed,
);

if (this.destroyed)
Expand Down Expand Up @@ -1456,7 +1456,7 @@ Server.prototype.addContext = function(servername, context) {

const re = new RegExp('^' + StringPrototypeReplaceAll(
RegExpPrototypeSymbolReplace(/([.^$+?\-\\[\]{}])/g, servername, '\\$1'),
'*', '[^.]*'
'*', '[^.]*',
) + '$');
ArrayPrototypePush(this._contexts,
[re, tls.createSecureContext(context).context]);
Expand Down Expand Up @@ -1680,7 +1680,7 @@ exports.connect = function connect(...args) {
'Setting the TLS ServerName to an IP address is not permitted by ' +
'RFC 6066. This will be ignored in a future version.',
'DeprecationWarning',
'DEP0123'
'DEP0123',
);
ipServernameWarned = true;
}
Expand Down
12 changes: 6 additions & 6 deletions lib/assert.js
Expand Up @@ -148,7 +148,7 @@ function fail(actual, expected, message, operator, stackStartFn) {
'assert.fail() with more than one argument is deprecated. ' +
'Please use assert.strictEqual() instead or only pass a message.',
'DeprecationWarning',
'DEP0094'
'DEP0094',
);
}
if (argsLen === 2)
Expand Down Expand Up @@ -807,13 +807,13 @@ function expectsError(stackStartFn, actual, error, message) {
if (actual.message === error) {
throw new ERR_AMBIGUOUS_ARGUMENT(
'error/message',
`The error message "${actual.message}" is identical to the message.`
`The error message "${actual.message}" is identical to the message.`,
);
}
} else if (actual === error) {
throw new ERR_AMBIGUOUS_ARGUMENT(
'error/message',
`The error "${actual}" is identical to the message.`
`The error "${actual}" is identical to the message.`,
);
}
message = error;
Expand Down Expand Up @@ -855,7 +855,7 @@ function hasMatchingError(actual, expected) {
return RegExpPrototypeExec(expected, str) !== null;
}
throw new ERR_INVALID_ARG_TYPE(
'expected', ['Function', 'RegExp'], expected
'expected', ['Function', 'RegExp'], expected,
);
}
// Guard instanceof against arrow functions as they don't have a prototype.
Expand Down Expand Up @@ -970,7 +970,7 @@ assert.ifError = function ifError(err) {
if (origStackStart !== -1) {
const originalFrames = StringPrototypeSplit(
StringPrototypeSlice(origStack, origStackStart + 1),
'\n'
'\n',
);
// Filter all frames existing in err.stack.
let newFrames = StringPrototypeSplit(newErr.stack, '\n');
Expand All @@ -996,7 +996,7 @@ assert.ifError = function ifError(err) {
function internalMatch(string, regexp, message, fn) {
if (!isRegExp(regexp)) {
throw new ERR_INVALID_ARG_TYPE(
'regexp', 'RegExp', regexp
'regexp', 'RegExp', regexp,
);
}
const match = fn === assert.match;
Expand Down
12 changes: 6 additions & 6 deletions lib/buffer.js
Expand Up @@ -326,7 +326,7 @@ Buffer.from = function from(value, encodingOrOffset, length) {
throw new ERR_INVALID_ARG_TYPE(
'first argument',
['string', 'Buffer', 'ArrayBuffer', 'Array', 'Array-like Object'],
value
value,
);
};

Expand Down Expand Up @@ -733,7 +733,7 @@ function byteLength(string, encoding) {
}

throw new ERR_INVALID_ARG_TYPE(
'string', ['string', 'Buffer', 'ArrayBuffer'], string
'string', ['string', 'Buffer', 'ArrayBuffer'], string,
);
}

Expand Down Expand Up @@ -954,7 +954,7 @@ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
}

throw new ERR_INVALID_ARG_TYPE(
'value', ['number', 'string', 'Buffer', 'Uint8Array'], val
'value', ['number', 'string', 'Buffer', 'Uint8Array'], val,
);
}

Expand Down Expand Up @@ -1210,7 +1210,7 @@ if (internalBinding('config').hasIntl) {
const code = icuErrName(result);
const err = genericNodeError(
`Unable to transcode Buffer [${code}]`,
{ code: code, errno: result }
{ code: code, errno: result },
);
throw err;
};
Expand Down Expand Up @@ -1362,10 +1362,10 @@ ObjectDefineProperties(module.exports, {
defineLazyProperties(
module.exports,
'internal/blob',
['Blob', 'resolveObjectURL']
['Blob', 'resolveObjectURL'],
);
defineLazyProperties(
module.exports,
'internal/file',
['File']
['File'],
);
4 changes: 2 additions & 2 deletions lib/child_process.js
Expand Up @@ -56,7 +56,7 @@ let debug = require('internal/util/debuglog').debuglog(
'child_process',
(fn) => {
debug = fn;
}
},
);
const { Buffer } = require('buffer');
const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap');
Expand Down Expand Up @@ -686,7 +686,7 @@ function normalizeSpawnArguments(file, args, options) {
}
sawKey.add(uppercaseKey);
return true;
}
},
);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/crypto.js
Expand Up @@ -317,7 +317,7 @@ function getRandomBytesAlias(key) {
configurable: true,
writable: true,
value: value
}
},
);
return value;
},
Expand All @@ -331,7 +331,7 @@ function getRandomBytesAlias(key) {
configurable: true,
writable: true,
value
}
},
);
}
};
Expand Down
6 changes: 3 additions & 3 deletions lib/dgram.js
Expand Up @@ -412,7 +412,7 @@ function _connect(port, address, callback) {
defaultTriggerAsyncIdScope(
this[async_id_symbol],
doConnect,
ex, this, ip, address, port, callback
ex, this, ip, address, port, callback,
);
};

Expand Down Expand Up @@ -662,7 +662,7 @@ Socket.prototype.send = function(buffer,
defaultTriggerAsyncIdScope(
this[async_id_symbol],
doSend,
ex, this, ip, list, address, port, callback
ex, this, ip, list, address, port, callback,
);
};

Expand Down Expand Up @@ -1066,7 +1066,7 @@ module.exports = {
_createSocketHandle: deprecate(
_createSocketHandle,
'dgram._createSocketHandle() is deprecated',
'DEP0112'
'DEP0112',
),
createSocket,
Socket
Expand Down
2 changes: 1 addition & 1 deletion lib/dns.js
Expand Up @@ -219,7 +219,7 @@ function lookup(hostname, options, callback) {
req.oncomplete = all ? onlookupall : onlookup;

const err = cares.getaddrinfo(
req, toASCII(hostname), family, hints, verbatim
req, toASCII(hostname), family, hints, verbatim,
);
if (err) {
process.nextTick(callback, dnsException(err, 'getaddrinfo', hostname));
Expand Down
2 changes: 1 addition & 1 deletion lib/fs.js
Expand Up @@ -3109,7 +3109,7 @@ module.exports = fs = {
defineLazyProperties(
fs,
'internal/fs/dir',
['Dir', 'opendir', 'opendirSync']
['Dir', 'opendir', 'opendirSync'],
);

ObjectDefineProperties(fs, {
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/assert/assertion_error.js
Expand Up @@ -72,7 +72,7 @@ function inspectValue(val) {
sorted: true,
// Inspect getters as we also check them when comparing entries.
getters: true,
}
},
);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/internal/async_hooks.js
Expand Up @@ -201,7 +201,7 @@ function emitInitNative(asyncId, type, triggerAsyncId, resource) {
if (typeof active_hooks.array[i][init_symbol] === 'function') {
active_hooks.array[i][init_symbol](
asyncId, type, triggerAsyncId,
resource
resource,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/bootstrap/loaders.js
Expand Up @@ -201,7 +201,7 @@ class BuiltinModule {
* @type {Map<string, BuiltinModule>}
*/
static map = new SafeMap(
ArrayPrototypeMap(builtinIds, (id) => [id, new BuiltinModule(id)])
ArrayPrototypeMap(builtinIds, (id) => [id, new BuiltinModule(id)]),
);

constructor(id) {
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/bootstrap/node.js
Expand Up @@ -223,13 +223,13 @@ defineOperation(globalThis, 'setImmediate', timers.setImmediate);
defineLazyProperties(
globalThis,
'internal/structured_clone',
['structuredClone']
['structuredClone'],
);

exposeLazyInterfaces(
globalThis,
'internal/worker/io',
['BroadcastChannel']
['BroadcastChannel'],
);
// Set the per-Environment callback that will be called
// when the TrackingTraceStateObserver updates trace state.
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/child_process.js
Expand Up @@ -947,7 +947,7 @@ function setupChannel(target, channel, serializationMode) {

ArrayPrototypePush(
target.channel[kPendingMessages],
[event, message, handle]
[event, message, handle],
);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/internal/child_process/serialization.js
Expand Up @@ -82,11 +82,11 @@ const advanced = {
channel[kMessageBuffer][0] :
Buffer.concat(
channel[kMessageBuffer],
channel[kMessageBufferSize]
channel[kMessageBufferSize],
);

const deserializer = new ChildProcessDeserializer(
TypedArrayPrototypeSubarray(concatenatedBuffer, 4, fullMessageSize)
TypedArrayPrototypeSubarray(concatenatedBuffer, 4, fullMessageSize),
);

messageBufferHead = TypedArrayPrototypeSubarray(concatenatedBuffer, fullMessageSize);
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/cluster/worker.js
Expand Up @@ -29,10 +29,10 @@ function Worker(options) {
if (options.process) {
this.process = options.process;
this.process.on('error', (code, signal) =>
this.emit('error', code, signal)
this.emit('error', code, signal),
);
this.process.on('message', (message, handle) =>
this.emit('message', message, handle)
this.emit('message', message, handle),
);
}
}
Expand Down