Skip to content

Commit 16c507b

Browse files
aduh95MylesBorins
authored andcommitted
lib: enforce use of trailing commas for functions
PR-URL: #46629 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
1 parent 07d8690 commit 16c507b

Some content is hidden

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

108 files changed

+385
-385
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
@@ -396,7 +396,7 @@ function installListeners(agent, s, options) {
396396
// TODO(ronag): Always destroy, even if not in free list.
397397
const sockets = agent.freeSockets;
398398
if (ArrayPrototypeSome(ObjectKeys(sockets), (name) =>
399-
ArrayPrototypeIncludes(sockets[name], s)
399+
ArrayPrototypeIncludes(sockets[name], s),
400400
)) {
401401
return s.destroy();
402402
}

lib/_http_server.js

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

601601
function connectionListener(socket) {
602602
defaultTriggerAsyncIdScope(
603-
getOrSetAsyncId(socket), connectionListenerInternal, this, socket
603+
getOrSetAsyncId(socket), connectionListenerInternal, this, socket,
604604
);
605605
}
606606

@@ -803,15 +803,15 @@ function onParserTimeout(server, socket) {
803803
const noop = () => {};
804804
const badRequestResponse = Buffer.from(
805805
`HTTP/1.1 400 ${STATUS_CODES[400]}\r\n` +
806-
'Connection: close\r\n\r\n', 'ascii'
806+
'Connection: close\r\n\r\n', 'ascii',
807807
);
808808
const requestTimeoutResponse = Buffer.from(
809809
`HTTP/1.1 408 ${STATUS_CODES[408]}\r\n` +
810-
'Connection: close\r\n\r\n', 'ascii'
810+
'Connection: close\r\n\r\n', 'ascii',
811811
);
812812
const requestHeaderFieldsTooLargeResponse = Buffer.from(
813813
`HTTP/1.1 431 ${STATUS_CODES[431]}\r\n` +
814-
'Connection: close\r\n\r\n', 'ascii'
814+
'Connection: close\r\n\r\n', 'ascii',
815815
);
816816
function socketOnError(e) {
817817
// 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

+6-6
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ Buffer.from = function from(value, encodingOrOffset, length) {
326326
throw new ERR_INVALID_ARG_TYPE(
327327
'first argument',
328328
['string', 'Buffer', 'ArrayBuffer', 'Array', 'Array-like Object'],
329-
value
329+
value,
330330
);
331331
};
332332

@@ -736,7 +736,7 @@ function byteLength(string, encoding) {
736736
}
737737

738738
throw new ERR_INVALID_ARG_TYPE(
739-
'string', ['string', 'Buffer', 'ArrayBuffer'], string
739+
'string', ['string', 'Buffer', 'ArrayBuffer'], string,
740740
);
741741
}
742742

@@ -957,7 +957,7 @@ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) {
957957
}
958958

959959
throw new ERR_INVALID_ARG_TYPE(
960-
'value', ['number', 'string', 'Buffer', 'Uint8Array'], val
960+
'value', ['number', 'string', 'Buffer', 'Uint8Array'], val,
961961
);
962962
}
963963

@@ -1213,7 +1213,7 @@ if (internalBinding('config').hasIntl) {
12131213
const code = icuErrName(result);
12141214
const err = genericNodeError(
12151215
`Unable to transcode Buffer [${code}]`,
1216-
{ code: code, errno: result }
1216+
{ code: code, errno: result },
12171217
);
12181218
throw err;
12191219
};
@@ -1365,10 +1365,10 @@ ObjectDefineProperties(module.exports, {
13651365
defineLazyProperties(
13661366
module.exports,
13671367
'internal/blob',
1368-
['Blob', 'resolveObjectURL']
1368+
['Blob', 'resolveObjectURL'],
13691369
);
13701370
defineLazyProperties(
13711371
module.exports,
13721372
'internal/file',
1373-
['File']
1373+
['File'],
13741374
);

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
@@ -317,7 +317,7 @@ function getRandomBytesAlias(key) {
317317
configurable: true,
318318
writable: true,
319319
value: value
320-
}
320+
},
321321
);
322322
return value;
323323
},
@@ -331,7 +331,7 @@ function getRandomBytesAlias(key) {
331331
configurable: true,
332332
writable: true,
333333
value
334-
}
334+
},
335335
);
336336
}
337337
};

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
@@ -3109,7 +3109,7 @@ module.exports = fs = {
31093109
defineLazyProperties(
31103110
fs,
31113111
'internal/fs/dir',
3112-
['Dir', 'opendir', 'opendirSync']
3112+
['Dir', 'opendir', 'opendirSync'],
31133113
);
31143114

31153115
ObjectDefineProperties(fs, {

lib/internal/assert/assertion_error.js

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

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
@@ -201,7 +201,7 @@ class BuiltinModule {
201201
* @type {Map<string, BuiltinModule>}
202202
*/
203203
static map = new SafeMap(
204-
ArrayPrototypeMap(builtinIds, (id) => [id, new BuiltinModule(id)])
204+
ArrayPrototypeMap(builtinIds, (id) => [id, new BuiltinModule(id)]),
205205
);
206206

207207
constructor(id) {

lib/internal/bootstrap/node.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,13 @@ defineOperation(globalThis, 'setImmediate', timers.setImmediate);
211211
defineLazyProperties(
212212
globalThis,
213213
'internal/structured_clone',
214-
['structuredClone']
214+
['structuredClone'],
215215
);
216216

217217
exposeLazyInterfaces(
218218
globalThis,
219219
'internal/worker/io',
220-
['BroadcastChannel']
220+
['BroadcastChannel'],
221221
);
222222
// Set the per-Environment callback that will be called
223223
// when the TrackingTraceStateObserver updates trace state.

lib/internal/child_process.js

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

948948
ArrayPrototypePush(
949949
target.channel[kPendingMessages],
950-
[event, message, handle]
950+
[event, message, handle],
951951
);
952952
}
953953

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
}

0 commit comments

Comments
 (0)