Skip to content

Commit b5ee2c8

Browse files
committed
tools: make comma-dangle ESLint rule more stringent …
We've been having a lot of nits lately asking people to add trailing commas, so it's probably time to incrementally make the comma-dangle rule more stringent.
1 parent c0e66e3 commit b5ee2c8

38 files changed

+69
-61
lines changed

.eslintrc.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,13 @@ module.exports = {
9494
ignorePattern: '.*',
9595
},
9696
}],
97-
'comma-dangle': ['error', 'only-multiline'],
97+
'comma-dangle': ['error', {
98+
arrays: 'always-multiline',
99+
exports: 'only-multiline',
100+
functions: 'only-multiline',
101+
imports: 'only-multiline',
102+
objects: 'only-multiline',
103+
}],
98104
'comma-spacing': 'error',
99105
'comma-style': 'error',
100106
'computed-property-spacing': 'error',

doc/api/child_process.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1225,7 +1225,7 @@ const subprocess = spawn(
12251225
'-c',
12261226
`node -e "setInterval(() => {
12271227
console.log(process.pid, 'is alive')
1228-
}, 500);"`
1228+
}, 500);"`,
12291229
], {
12301230
stdio: ['inherit', 'inherit', 'inherit']
12311231
}
@@ -1558,7 +1558,7 @@ const subprocess = child_process.spawn('ls', {
15581558
stdio: [
15591559
0, // Use parent's stdin for child.
15601560
'pipe', // Pipe child's stdout to parent.
1561-
fs.openSync('err.out', 'w') // Direct child's stderr to a file.
1561+
fs.openSync('err.out', 'w'), // Direct child's stderr to a file.
15621562
]
15631563
});
15641564

doc/api/dns.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ section if a custom port is used.
155155
'4.4.4.4',
156156
'2001:4860:4860::8888',
157157
'4.4.4.4:1053',
158-
'[2001:4860:4860::8888]:1053'
158+
'[2001:4860:4860::8888]:1053',
159159
]
160160
```
161161

@@ -645,7 +645,7 @@ dns.setServers([
645645
'4.4.4.4',
646646
'[2001:4860:4860::8888]',
647647
'4.4.4.4:1053',
648-
'[2001:4860:4860::8888]:1053'
648+
'[2001:4860:4860::8888]:1053',
649649
]);
650650
```
651651

@@ -755,7 +755,7 @@ section if a custom port is used.
755755
'4.4.4.4',
756756
'2001:4860:4860::8888',
757757
'4.4.4.4:1053',
758-
'[2001:4860:4860::8888]:1053'
758+
'[2001:4860:4860::8888]:1053',
759759
]
760760
```
761761

@@ -1148,7 +1148,7 @@ dnsPromises.setServers([
11481148
'4.4.4.4',
11491149
'[2001:4860:4860::8888]',
11501150
'4.4.4.4:1053',
1151-
'[2001:4860:4860::8888]:1053'
1151+
'[2001:4860:4860::8888]:1053',
11521152
]);
11531153
```
11541154

doc/api/os.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ The properties included on each object include:
115115
idle: 1070905480,
116116
irq: 20
117117
}
118-
}
118+
},
119119
]
120120
```
121121

doc/api/url.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ with [`JSON.stringify()`][].
566566
```js
567567
const myURLs = [
568568
new URL('https://www.example.com'),
569-
new URL('https://test.example.org')
569+
new URL('https://test.example.org'),
570570
];
571571
console.log(JSON.stringify(myURLs));
572572
// Prints ["https://www.example.com/","https://test.example.org/"]
@@ -703,7 +703,7 @@ let params;
703703
params = new URLSearchParams([
704704
['user', 'abc'],
705705
['query', 'first'],
706-
['query', 'second']
706+
['query', 'second'],
707707
]);
708708
console.log(params.toString());
709709
// Prints 'user=abc&query=first&query=second'
@@ -728,7 +728,7 @@ console.log(params.toString());
728728

729729
// Each key-value pair must have exactly two elements
730730
new URLSearchParams([
731-
['user', 'abc', 'error']
731+
['user', 'abc', 'error'],
732732
]);
733733
// Throws TypeError [ERR_INVALID_TUPLE]:
734734
// Each query pair must be an iterable [name, value] tuple

doc/api/webcrypto.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -187,15 +187,15 @@ const { subtle } = require('crypto').webcrypto;
187187
async function generateAndWrapHmacKey(format = 'jwk', hash = 'SHA-512') {
188188
const [
189189
key,
190-
wrappingKey
190+
wrappingKey,
191191
] = await Promise.all([
192192
subtle.generateKey({
193193
name: 'HMAC', hash
194194
}, true, ['sign', 'verify']),
195195
subtle.generateKey({
196196
name: 'AES-KW',
197197
length: 256
198-
}, true, ['wrapKey', 'unwrapKey'])
198+
}, true, ['wrapKey', 'unwrapKey']),
199199
]);
200200

201201
const wrappedKey = await subtle.wrapKey(format, key, wrappingKey, 'AES-KW');

lib/assert.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ const meta = [
9595
'\\u000f', '\\u0010', '\\u0011', '\\u0012', '\\u0013',
9696
'\\u0014', '\\u0015', '\\u0016', '\\u0017', '\\u0018',
9797
'\\u0019', '\\u001a', '\\u001b', '\\u001c', '\\u001d',
98-
'\\u001e', '\\u001f'
98+
'\\u001e', '\\u001f',
9999
];
100100

101101
const escapeFn = (str) => meta[StringPrototypeCharCodeAt(str, 0)];
@@ -276,7 +276,7 @@ function parseCode(code, offset) {
276276
node.node.start,
277277
StringPrototypeReplace(StringPrototypeSlice(code,
278278
node.node.start, node.node.end),
279-
escapeSequencesRegExp, escapeFn)
279+
escapeSequencesRegExp, escapeFn),
280280
];
281281
}
282282

lib/internal/blob.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function getSource(source, encoding) {
8383
'SharedArrayBuffer',
8484
'Buffer',
8585
'TypedArray',
86-
'DataView'
86+
'DataView',
8787
],
8888
source);
8989
}

lib/internal/bootstrap/loaders.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ const internalBindingAllowlist = new SafeSet([
102102
'util',
103103
'uv',
104104
'v8',
105-
'zlib'
105+
'zlib',
106106
]);
107107

108108
// Set up process.binding() and process._linkedBinding().

lib/internal/bootstrap/pre_execution.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ function initializeDeprecations() {
263263
'isSetIterator',
264264
'isTypedArray',
265265
'isUint8Array',
266-
'isAnyArrayBuffer'
266+
'isAnyArrayBuffer',
267267
]) {
268268
utilBinding[name] = pendingDeprecation ?
269269
deprecate(types[name],

lib/internal/child_process/serialization.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const advanced = {
8484
sizeBuffer.writeUInt32BE(serializedMessage.length);
8585
return channel.writeBuffer(req, Buffer.concat([
8686
sizeBuffer,
87-
serializedMessage
87+
serializedMessage,
8888
]), handle);
8989
},
9090
};

lib/internal/console/constructor.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ const consoleMethods = {
532532
}
533533
}
534534
return final([
535-
iterKey, keyKey, valuesKey
535+
iterKey, keyKey, valuesKey,
536536
], [
537537
getIndexArray(length),
538538
keys,

lib/internal/crypto/hkdf.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ function prepareKey(key) {
9595
'ArrayBuffer',
9696
'TypedArray',
9797
'DataView',
98-
'Buffer'
98+
'Buffer',
9999
],
100100
key);
101101
}

lib/internal/crypto/keygen.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ function parseKeyEncoding(keyType, options = {}) {
149149
privateFormat,
150150
privateType,
151151
cipher,
152-
passphrase
152+
passphrase,
153153
];
154154
}
155155

lib/internal/crypto/keys.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const [
8989
KeyObject,
9090
SecretKeyObject,
9191
PublicKeyObject,
92-
PrivateKeyObject
92+
PrivateKeyObject,
9393
] = createNativeKeyObjectClass((NativeKeyObject) => {
9494
// Publicly visible KeyObject class.
9595
class KeyObject extends NativeKeyObject {

lib/internal/crypto/random.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ function getRandomValues(data) {
296296

297297
const kHexDigits = [
298298
48, 49, 50, 51, 52, 53, 54, 55,
299-
56, 57, 97, 98, 99, 100, 101, 102
299+
56, 57, 97, 98, 99, 100, 101, 102,
300300
];
301301

302302
const kBatchSize = 128;

lib/internal/crypto/util.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ const getArrayBufferOrView = hideStackFrames((buffer, name, encoding) => {
133133
'ArrayBuffer',
134134
'Buffer',
135135
'TypedArray',
136-
'DataView'
136+
'DataView',
137137
],
138138
buffer
139139
);
@@ -200,7 +200,7 @@ const kHashTypes = [
200200
'SHA-1',
201201
'SHA-256',
202202
'SHA-384',
203-
'SHA-512'
203+
'SHA-512',
204204
];
205205

206206
function validateMaxBufferLength(data, name) {
@@ -278,7 +278,7 @@ const validateByteSource = hideStackFrames((val, name) => {
278278
'ArrayBuffer',
279279
'TypedArray',
280280
'DataView',
281-
'Buffer'
281+
'Buffer',
282282
],
283283
val);
284284
});

lib/internal/encoding.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ const encodings = new SafeMap([
285285
['windows-949', 'euc-kr'],
286286
['utf-16be', 'utf-16be'],
287287
['utf-16le', 'utf-16le'],
288-
['utf-16', 'utf-16le']
288+
['utf-16', 'utf-16le'],
289289
]);
290290

291291
// Unfortunately, String.prototype.trim also removes non-ascii whitespace,

lib/internal/errors.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const kTypes = [
7070
'Object',
7171
'boolean',
7272
'bigint',
73-
'symbol'
73+
'symbol',
7474
];
7575

7676
const MainContextError = Error;

lib/internal/freeze_intrinsics.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ module.exports = function() {
199199
WebAssembly.CompileError.prototype,
200200
WebAssembly.LinkError.prototype,
201201
WebAssembly.RuntimeError.prototype,
202-
SharedArrayBuffer.prototype
202+
SharedArrayBuffer.prototype,
203203
];
204204
const intrinsics = [
205205
// Anonymous Intrinsics
@@ -313,7 +313,7 @@ module.exports = function() {
313313
BigInt,
314314
Atomics,
315315
WebAssembly,
316-
SharedArrayBuffer
316+
SharedArrayBuffer,
317317
];
318318

319319
if (typeof Intl !== 'undefined') {

lib/internal/http2/util.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ const kValidPseudoHeaders = new SafeSet([
108108
HTTP2_HEADER_AUTHORITY,
109109
HTTP2_HEADER_SCHEME,
110110
HTTP2_HEADER_PATH,
111-
HTTP2_HEADER_PROTOCOL
111+
HTTP2_HEADER_PROTOCOL,
112112
]);
113113

114114
// This set contains headers that are permitted to have only a single
@@ -153,7 +153,7 @@ const kSingleValueHeaders = new SafeSet([
153153
HTTP2_HEADER_TK,
154154
HTTP2_HEADER_UPGRADE_INSECURE_REQUESTS,
155155
HTTP2_HEADER_USER_AGENT,
156-
HTTP2_HEADER_X_CONTENT_TYPE_OPTIONS
156+
HTTP2_HEADER_X_CONTENT_TYPE_OPTIONS,
157157
]);
158158

159159
// The HTTP methods in this set are specifically defined as assigning no
@@ -163,7 +163,7 @@ const kSingleValueHeaders = new SafeSet([
163163
const kNoPayloadMethods = new SafeSet([
164164
HTTP2_METHOD_DELETE,
165165
HTTP2_METHOD_GET,
166-
HTTP2_METHOD_HEAD
166+
HTTP2_METHOD_HEAD,
167167
]);
168168

169169
// The following ArrayBuffer instances are used to share memory more efficiently

lib/internal/main/print_help.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,13 @@ const envVars = new SafeMap(ArrayPrototypeConcat([
5555
['NODE_V8_COVERAGE', { helpText: 'directory to output v8 coverage JSON ' +
5656
'to' }],
5757
['UV_THREADPOOL_SIZE', { helpText: 'sets the number of threads used in ' +
58-
'libuv\'s threadpool' }]
58+
'libuv\'s threadpool' }],
5959
], hasIntl ? [
6060
['NODE_ICU_DATA', { helpText: 'data path for ICU (Intl object) data' +
61-
hasSmallICU ? '' : ' (will extend linked-in data)' }]
61+
hasSmallICU ? '' : ' (will extend linked-in data)' }],
6262
] : []), (hasNodeOptions ? [
6363
['NODE_OPTIONS', { helpText: 'set CLI options in the environment via a ' +
64-
'space-separated list' }]
64+
'space-separated list' }],
6565
] : []), hasCrypto ? [
6666
['OPENSSL_CONF', { helpText: 'load OpenSSL configuration from file' }],
6767
['SSL_CERT_DIR', { helpText: 'sets OpenSSL\'s directory of trusted ' +
@@ -108,7 +108,7 @@ function format(
108108
let maxFirstColumnUsed = 0;
109109

110110
for (const [
111-
name, { helpText, type, value }
111+
name, { helpText, type, value },
112112
] of ArrayPrototypeSort([...options.entries()])) {
113113
if (!helpText) continue;
114114

lib/internal/modules/cjs/loader.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ let wrap = function(script) {
195195

196196
const wrapper = [
197197
'(function (exports, require, module, __filename, __dirname) { ',
198-
'\n});'
198+
'\n});',
199199
];
200200

201201
let wrapperProxy = new Proxy(wrapper, {

lib/internal/per_context/primordials.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ function copyPrototype(src, dest, prefix) {
141141
[
142142
'JSON',
143143
'Math',
144-
'Reflect'
144+
'Reflect',
145145
].forEach((name) => {
146146
copyPropsRenamed(global[name], primordials, name);
147147
});

lib/internal/process/per_thread.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ function getFastAPIs(binding) {
7272

7373
return [
7474
hrValues[0] * 0x100000000 + hrValues[1],
75-
hrValues[2]
75+
hrValues[2],
7676
];
7777
}
7878

lib/internal/querystring.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const isHexTable = new Int8Array([
3333
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3434
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
3535
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
36-
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // ... 256
36+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // ... 256
3737
]);
3838

3939
function encodeStr(str, noEscapeTable, hexTable) {

lib/internal/streams/pipeline.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ function pipeline(...streams) {
241241
pt.end(val);
242242
}, (err) => {
243243
pt.destroy(err);
244-
}
244+
},
245245
]);
246246
} else if (isIterable(ret, true)) {
247247
finishCount++;

lib/internal/tty.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const TERM_ENVS_REG_EXP = [
7777
/^rxvt/,
7878
/^screen/,
7979
/^xterm/,
80-
/^vt100/
80+
/^vt100/,
8181
];
8282

8383
let warned = false;

0 commit comments

Comments
 (0)