Skip to content

Commit 36e080c

Browse files
aduh95danielleadams
authored andcommitted
lib: enforce use of trailing commas for functions
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]>
1 parent f7c4796 commit 36e080c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+380
-380
lines changed

lib/.eslintrc.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ rules:
55
comma-dangle: [error, {
66
arrays: always-multiline,
77
exports: always-multiline,
8-
functions: only-multiline,
8+
functions: always-multiline,
99
imports: always-multiline,
1010
objects: only-multiline,
1111
}]

lib/_http_agent.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ function installListeners(agent, s, options) {
395395
// TODO(ronag): Always destroy, even if not in free list.
396396
const sockets = agent.freeSockets;
397397
if (ArrayPrototypeSome(ObjectKeys(sockets), (name) =>
398-
ArrayPrototypeIncludes(sockets[name], s)
398+
ArrayPrototypeIncludes(sockets[name], s),
399399
)) {
400400
return s.destroy();
401401
}

lib/_http_server.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ function checkConnections() {
604604

605605
function connectionListener(socket) {
606606
defaultTriggerAsyncIdScope(
607-
getOrSetAsyncId(socket), connectionListenerInternal, this, socket
607+
getOrSetAsyncId(socket), connectionListenerInternal, this, socket,
608608
);
609609
}
610610

@@ -807,15 +807,15 @@ function onParserTimeout(server, socket) {
807807
const noop = () => {};
808808
const badRequestResponse = Buffer.from(
809809
`HTTP/1.1 400 ${STATUS_CODES[400]}\r\n` +
810-
'Connection: close\r\n\r\n', 'ascii'
810+
'Connection: close\r\n\r\n', 'ascii',
811811
);
812812
const requestTimeoutResponse = Buffer.from(
813813
`HTTP/1.1 408 ${STATUS_CODES[408]}\r\n` +
814-
'Connection: close\r\n\r\n', 'ascii'
814+
'Connection: close\r\n\r\n', 'ascii',
815815
);
816816
const requestHeaderFieldsTooLargeResponse = Buffer.from(
817817
`HTTP/1.1 431 ${STATUS_CODES[431]}\r\n` +
818-
'Connection: close\r\n\r\n', 'ascii'
818+
'Connection: close\r\n\r\n', 'ascii',
819819
);
820820
function socketOnError(e) {
821821
// Ignore further errors

lib/_tls_wrap.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ function onhandshakedone() {
171171
function loadSession(hello) {
172172
debug('server onclienthello',
173173
'sessionid.len', hello.sessionId.length,
174-
'ticket?', hello.tlsTicket
174+
'ticket?', hello.tlsTicket,
175175
);
176176
const owner = this[owner_symbol];
177177

@@ -350,7 +350,7 @@ function onPskServerCallback(identity, maxPskLen) {
350350
throw new ERR_INVALID_ARG_TYPE(
351351
'ret',
352352
['Object', 'Buffer', 'TypedArray', 'DataView'],
353-
ret
353+
ret,
354354
);
355355
}
356356
psk = ret.psk;
@@ -361,7 +361,7 @@ function onPskServerCallback(identity, maxPskLen) {
361361
throw new ERR_INVALID_ARG_VALUE(
362362
'psk',
363363
psk,
364-
`Pre-shared key exceeds ${maxPskLen} bytes`
364+
`Pre-shared key exceeds ${maxPskLen} bytes`,
365365
);
366366
}
367367

@@ -381,7 +381,7 @@ function onPskClientCallback(hint, maxPskLen, maxIdentityLen) {
381381
throw new ERR_INVALID_ARG_VALUE(
382382
'psk',
383383
ret.psk,
384-
`Pre-shared key exceeds ${maxPskLen} bytes`
384+
`Pre-shared key exceeds ${maxPskLen} bytes`,
385385
);
386386
}
387387

@@ -390,7 +390,7 @@ function onPskClientCallback(hint, maxPskLen, maxIdentityLen) {
390390
throw new ERR_INVALID_ARG_VALUE(
391391
'identity',
392392
ret.identity,
393-
`PSK identity exceeds ${maxIdentityLen} bytes`
393+
`PSK identity exceeds ${maxIdentityLen} bytes`,
394394
);
395395
}
396396

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

690690
debug('%s _init',
691691
options.isServer ? 'server' : 'client',
692-
'handle?', !!ssl
692+
'handle?', !!ssl,
693693
);
694694

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

847847
debug('%s renegotiate()',
848848
this._tlsOptions.isServer ? 'server' : 'client',
849-
'destroyed?', this.destroyed
849+
'destroyed?', this.destroyed,
850850
);
851851

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

14571457
const re = new RegExp('^' + StringPrototypeReplaceAll(
14581458
RegExpPrototypeSymbolReplace(/([.^$+?\-\\[\]{}])/g, servername, '\\$1'),
1459-
'*', '[^.]*'
1459+
'*', '[^.]*',
14601460
) + '$');
14611461
ArrayPrototypePush(this._contexts,
14621462
[re, tls.createSecureContext(context).context]);
@@ -1680,7 +1680,7 @@ exports.connect = function connect(...args) {
16801680
'Setting the TLS ServerName to an IP address is not permitted by ' +
16811681
'RFC 6066. This will be ignored in a future version.',
16821682
'DeprecationWarning',
1683-
'DEP0123'
1683+
'DEP0123',
16841684
);
16851685
ipServernameWarned = true;
16861686
}

lib/assert.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ function fail(actual, expected, message, operator, stackStartFn) {
148148
'assert.fail() with more than one argument is deprecated. ' +
149149
'Please use assert.strictEqual() instead or only pass a message.',
150150
'DeprecationWarning',
151-
'DEP0094'
151+
'DEP0094',
152152
);
153153
}
154154
if (argsLen === 2)
@@ -807,13 +807,13 @@ function expectsError(stackStartFn, actual, error, message) {
807807
if (actual.message === error) {
808808
throw new ERR_AMBIGUOUS_ARGUMENT(
809809
'error/message',
810-
`The error message "${actual.message}" is identical to the message.`
810+
`The error message "${actual.message}" is identical to the message.`,
811811
);
812812
}
813813
} else if (actual === error) {
814814
throw new ERR_AMBIGUOUS_ARGUMENT(
815815
'error/message',
816-
`The error "${actual}" is identical to the message.`
816+
`The error "${actual}" is identical to the message.`,
817817
);
818818
}
819819
message = error;
@@ -855,7 +855,7 @@ function hasMatchingError(actual, expected) {
855855
return RegExpPrototypeExec(expected, str) !== null;
856856
}
857857
throw new ERR_INVALID_ARG_TYPE(
858-
'expected', ['Function', 'RegExp'], expected
858+
'expected', ['Function', 'RegExp'], expected,
859859
);
860860
}
861861
// Guard instanceof against arrow functions as they don't have a prototype.
@@ -970,7 +970,7 @@ assert.ifError = function ifError(err) {
970970
if (origStackStart !== -1) {
971971
const originalFrames = StringPrototypeSplit(
972972
StringPrototypeSlice(origStack, origStackStart + 1),
973-
'\n'
973+
'\n',
974974
);
975975
// Filter all frames existing in err.stack.
976976
let newFrames = StringPrototypeSplit(newErr.stack, '\n');
@@ -996,7 +996,7 @@ assert.ifError = function ifError(err) {
996996
function internalMatch(string, regexp, message, fn) {
997997
if (!isRegExp(regexp)) {
998998
throw new ERR_INVALID_ARG_TYPE(
999-
'regexp', 'RegExp', regexp
999+
'regexp', 'RegExp', regexp,
10001000
);
10011001
}
10021002
const match = fn === assert.match;

lib/buffer.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ Buffer.from = function from(value, encodingOrOffset, length) {
335335
throw new ERR_INVALID_ARG_TYPE(
336336
'first argument',
337337
['string', 'Buffer', 'ArrayBuffer', 'Array', 'Array-like Object'],
338-
value
338+
value,
339339
);
340340
};
341341

@@ -745,7 +745,7 @@ function byteLength(string, encoding) {
745745
}
746746

747747
throw new ERR_INVALID_ARG_TYPE(
748-
'string', ['string', 'Buffer', 'ArrayBuffer'], string
748+
'string', ['string', 'Buffer', 'ArrayBuffer'], string,
749749
);
750750
}
751751

@@ -966,7 +966,7 @@ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
966966
}
967967

968968
throw new ERR_INVALID_ARG_TYPE(
969-
'value', ['number', 'string', 'Buffer', 'Uint8Array'], val
969+
'value', ['number', 'string', 'Buffer', 'Uint8Array'], val,
970970
);
971971
}
972972

@@ -1222,7 +1222,7 @@ if (internalBinding('config').hasIntl) {
12221222
const code = icuErrName(result);
12231223
const err = genericNodeError(
12241224
`Unable to transcode Buffer [${code}]`,
1225-
{ code: code, errno: result }
1225+
{ code: code, errno: result },
12261226
);
12271227
throw err;
12281228
};

lib/child_process.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ let debug = require('internal/util/debuglog').debuglog(
5656
'child_process',
5757
(fn) => {
5858
debug = fn;
59-
}
59+
},
6060
);
6161
const { Buffer } = require('buffer');
6262
const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap');
@@ -686,7 +686,7 @@ function normalizeSpawnArguments(file, args, options) {
686686
}
687687
sawKey.add(uppercaseKey);
688688
return true;
689-
}
689+
},
690690
);
691691
}
692692

lib/crypto.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ function getRandomBytesAlias(key) {
307307
configurable: true,
308308
writable: true,
309309
value: value
310-
}
310+
},
311311
);
312312
return value;
313313
},
@@ -321,7 +321,7 @@ function getRandomBytesAlias(key) {
321321
configurable: true,
322322
writable: true,
323323
value
324-
}
324+
},
325325
);
326326
}
327327
};

lib/dgram.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ function _connect(port, address, callback) {
412412
defaultTriggerAsyncIdScope(
413413
this[async_id_symbol],
414414
doConnect,
415-
ex, this, ip, address, port, callback
415+
ex, this, ip, address, port, callback,
416416
);
417417
};
418418

@@ -662,7 +662,7 @@ Socket.prototype.send = function(buffer,
662662
defaultTriggerAsyncIdScope(
663663
this[async_id_symbol],
664664
doSend,
665-
ex, this, ip, list, address, port, callback
665+
ex, this, ip, list, address, port, callback,
666666
);
667667
};
668668

@@ -1066,7 +1066,7 @@ module.exports = {
10661066
_createSocketHandle: deprecate(
10671067
_createSocketHandle,
10681068
'dgram._createSocketHandle() is deprecated',
1069-
'DEP0112'
1069+
'DEP0112',
10701070
),
10711071
createSocket,
10721072
Socket

lib/dns.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ function lookup(hostname, options, callback) {
219219
req.oncomplete = all ? onlookupall : onlookup;
220220

221221
const err = cares.getaddrinfo(
222-
req, toASCII(hostname), family, hints, verbatim
222+
req, toASCII(hostname), family, hints, verbatim,
223223
);
224224
if (err) {
225225
process.nextTick(callback, dnsException(err, 'getaddrinfo', hostname));

lib/fs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ const isOSX = process.platform === 'darwin';
171171
const showStringCoercionDeprecation = deprecate(
172172
() => {},
173173
'Implicit coercion of objects with own toString property is deprecated.',
174-
'DEP0162'
174+
'DEP0162',
175175
);
176176
function showTruncateDeprecation() {
177177
if (truncateWarn) {

lib/internal/assert/assertion_error.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function inspectValue(val) {
7373
sorted: true,
7474
// Inspect getters as we also check them when comparing entries.
7575
getters: true,
76-
}
76+
},
7777
);
7878
}
7979

lib/internal/async_hooks.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ function emitInitNative(asyncId, type, triggerAsyncId, resource) {
201201
if (typeof active_hooks.array[i][init_symbol] === 'function') {
202202
active_hooks.array[i][init_symbol](
203203
asyncId, type, triggerAsyncId,
204-
resource
204+
resource,
205205
);
206206
}
207207
}

lib/internal/bootstrap/loaders.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class BuiltinModule {
202202
* @type {Map<string, BuiltinModule>}
203203
*/
204204
static map = new SafeMap(
205-
ArrayPrototypeMap(builtinIds, (id) => [id, new BuiltinModule(id)])
205+
ArrayPrototypeMap(builtinIds, (id) => [id, new BuiltinModule(id)]),
206206
);
207207

208208
constructor(id) {

lib/internal/bootstrap/node.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ const deprecationHandler = {
115115
if (!this.warned) {
116116
process.emitWarning(this.message, {
117117
type: 'DeprecationWarning',
118-
code: this.code
118+
code: this.code,
119119
});
120120
this.warned = true;
121121
}

lib/internal/child_process.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ function setupChannel(target, channel, serializationMode) {
940940

941941
ArrayPrototypePush(
942942
target.channel[kPendingMessages],
943-
[event, message, handle]
943+
[event, message, handle],
944944
);
945945
}
946946

lib/internal/child_process/serialization.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ const advanced = {
8282
channel[kMessageBuffer][0] :
8383
Buffer.concat(
8484
channel[kMessageBuffer],
85-
channel[kMessageBufferSize]
85+
channel[kMessageBufferSize],
8686
);
8787

8888
const deserializer = new ChildProcessDeserializer(
89-
TypedArrayPrototypeSubarray(concatenatedBuffer, 4, fullMessageSize)
89+
TypedArrayPrototypeSubarray(concatenatedBuffer, 4, fullMessageSize),
9090
);
9191

9292
messageBufferHead = TypedArrayPrototypeSubarray(concatenatedBuffer, fullMessageSize);

lib/internal/cluster/worker.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ function Worker(options) {
2929
if (options.process) {
3030
this.process = options.process;
3131
this.process.on('error', (code, signal) =>
32-
this.emit('error', code, signal)
32+
this.emit('error', code, signal),
3333
);
3434
this.process.on('message', (message, handle) =>
35-
this.emit('message', message, handle)
35+
this.emit('message', message, handle),
3636
);
3737
}
3838
}

lib/internal/console/constructor.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ const consoleMethods = {
491491
this[kGroupIndent] = StringPrototypeSlice(
492492
this[kGroupIndent],
493493
0,
494-
this[kGroupIndent].length - this[kGroupIndentationWidth]
494+
this[kGroupIndent].length - this[kGroupIndentationWidth],
495495
);
496496
},
497497

@@ -654,7 +654,7 @@ function formatTime(ms) {
654654
if (hours !== 0 || minutes !== 0) {
655655
({ 0: seconds, 1: ms } = StringPrototypeSplit(
656656
NumberPrototypeToFixed(seconds, 3),
657-
'.'
657+
'.',
658658
));
659659
const res = hours !== 0 ? `${hours}:${pad(minutes)}` : minutes;
660660
return `${res}:${pad(seconds)}.${ms} (${hours !== 0 ? 'h:m' : ''}m:ss.mmm)`;

0 commit comments

Comments
 (0)