Skip to content

Commit

Permalink
lib: enforce use of trailing commas for functions
Browse files Browse the repository at this point in the history
PR-URL: #46629
Reviewed-By: Jacob Smith <[email protected]>
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Mohammed Keyvanzadeh <[email protected]>
  • Loading branch information
aduh95 authored and danielleadams committed Apr 3, 2023
1 parent f7c4796 commit 36e080c
Show file tree
Hide file tree
Showing 105 changed files with 380 additions and 380 deletions.
2 changes: 1 addition & 1 deletion lib/.eslintrc.yaml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,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
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ function checkConnections() {

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

Expand Down Expand Up @@ -807,15 +807,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
8 changes: 4 additions & 4 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,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 @@ -745,7 +745,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 @@ -966,7 +966,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 @@ -1222,7 +1222,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
4 changes: 2 additions & 2 deletions lib/child_process.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ function getRandomBytesAlias(key) {
configurable: true,
writable: true,
value: value
}
},
);
return value;
},
Expand All @@ -321,7 +321,7 @@ function getRandomBytesAlias(key) {
configurable: true,
writable: true,
value
}
},
);
}
};
Expand Down
6 changes: 3 additions & 3 deletions lib/dgram.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ const isOSX = process.platform === 'darwin';
const showStringCoercionDeprecation = deprecate(
() => {},
'Implicit coercion of objects with own toString property is deprecated.',
'DEP0162'
'DEP0162',
);
function showTruncateDeprecation() {
if (truncateWarn) {
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/assert/assertion_error.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,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
2 changes: 1 addition & 1 deletion lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const deprecationHandler = {
if (!this.warned) {
process.emitWarning(this.message, {
type: 'DeprecationWarning',
code: this.code
code: this.code,
});
this.warned = true;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/child_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
4 changes: 2 additions & 2 deletions lib/internal/console/constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ const consoleMethods = {
this[kGroupIndent] = StringPrototypeSlice(
this[kGroupIndent],
0,
this[kGroupIndent].length - this[kGroupIndentationWidth]
this[kGroupIndent].length - this[kGroupIndentationWidth],
);
},

Expand Down Expand Up @@ -654,7 +654,7 @@ function formatTime(ms) {
if (hours !== 0 || minutes !== 0) {
({ 0: seconds, 1: ms } = StringPrototypeSplit(
NumberPrototypeToFixed(seconds, 3),
'.'
'.',
));
const res = hours !== 0 ? `${hours}:${pad(minutes)}` : minutes;
return `${res}:${pad(seconds)}.${ms} (${hours !== 0 ? 'h:m' : ''}m:ss.mmm)`;
Expand Down
Loading

0 comments on commit 36e080c

Please sign in to comment.