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

Lines changed: 7 additions & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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],

0 commit comments

Comments
 (0)