From c694dae41cd9b6234bfd4b82d39e4043161760ae Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 2 Feb 2022 22:35:32 -0800 Subject: [PATCH] test: enable no-empty ESLint rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/41831 Refs: https://eslint.org/docs/rules/no-empty Reviewed-By: Colin Ihrig Reviewed-By: Tobias Nießen Reviewed-By: Antoine du Hamel --- test/.eslintrc.yaml | 3 +- test/addons/uv-handle-leak/test.js | 4 +- test/common/inspector-helper.js | 3 +- test/common/report.js | 4 +- .../test-dgram-broadcast-multi-process.js | 4 +- .../test-dgram-multicast-multi-process.js | 4 +- .../test-dgram-multicast-ssm-multi-process.js | 4 +- ...est-dgram-multicast-ssmv6-multi-process.js | 4 +- test/message/vm_dont_display_runtime_error.js | 4 +- test/message/vm_dont_display_syntax_error.js | 4 +- test/node-api/test_fatal/test_threads.js | 5 +- .../test_fatal/test_threads_report.js | 2 +- ...oks-run-in-async-scope-caught-exception.js | 4 +- .../test-cluster-kill-infinite-loop.js | 2 +- ...domain-with-abort-on-uncaught-exception.js | 1 + test/parallel/test-file-write-stream2.js | 4 +- test/parallel/test-fs-access.js | 1 + test/parallel/test-fs-promises-watch.js | 40 ++++++++----- test/parallel/test-fs-realpath.js | 56 ++++++++++++++----- test/parallel/test-global.js | 4 +- test/parallel/test-http-outgoing-finish.js | 2 +- ...http-outgoing-message-capture-rejection.js | 4 +- .../test-http2-server-socket-destroy.js | 4 +- .../test-listen-fd-detached-inherit.js | 4 +- test/parallel/test-listen-fd-detached.js | 4 +- .../test-performance-eventlooputil.js | 2 +- test/parallel/test-process-uid-gid.js | 16 ++++-- test/parallel/test-stdout-to-file.js | 4 +- .../parallel/test-stream-pipeline-uncaught.js | 2 +- test/parallel/test-stream-pipeline.js | 4 +- .../test-stream-readable-async-iterators.js | 23 ++++---- test/parallel/test-stream-readable-destroy.js | 4 +- ...est-stream-readable-reading-readingMore.js | 2 +- .../test-timers-interval-promisified.js | 4 +- ...st-vm-parse-abort-on-uncaught-exception.js | 8 ++- .../test-whatwg-readablebytestream.js | 4 -- test/pseudo-tty/test-trace-sigint.js | 2 +- test/pummel/test-policy-integrity-dep.js | 13 ++--- .../test-policy-integrity-parent-commonjs.js | 13 ++--- .../test-policy-integrity-parent-module.js | 13 ++--- ...policy-integrity-parent-no-package-json.js | 10 ++-- .../test-policy-integrity-worker-commonjs.js | 13 ++--- .../test-policy-integrity-worker-module.js | 13 ++--- ...policy-integrity-worker-no-package-json.js | 10 ++-- test/pummel/test-vm-memleak.js | 1 + test/sequential/test-net-response-size.js | 2 +- 46 files changed, 206 insertions(+), 132 deletions(-) diff --git a/test/.eslintrc.yaml b/test/.eslintrc.yaml index 55e8ff6af8c390..d9a0e3d3c5f587 100644 --- a/test/.eslintrc.yaml +++ b/test/.eslintrc.yaml @@ -5,10 +5,11 @@ env: es6: true rules: + multiline-comment-style: ["error", "separate-lines"] + no-empty: error no-var: error prefer-const: error symbol-description: off - multiline-comment-style: ["error", "separate-lines"] no-restricted-syntax: # Config copied from .eslintrc.js diff --git a/test/addons/uv-handle-leak/test.js b/test/addons/uv-handle-leak/test.js index 73d40ca7996274..c1cf6c550b6975 100644 --- a/test/addons/uv-handle-leak/test.js +++ b/test/addons/uv-handle-leak/test.js @@ -16,7 +16,9 @@ try { const { isMainThread } = require('worker_threads'); if (!isMainThread) common.skip('Cannot run test in environment with clean-exit policy'); -} catch {} +} catch { + // Continue regardless of error. +} binding.leakHandle(); binding.leakHandle(0); diff --git a/test/common/inspector-helper.js b/test/common/inspector-helper.js index fec48ddcba7b9c..28b5ab5209a298 100644 --- a/test/common/inspector-helper.js +++ b/test/common/inspector-helper.js @@ -365,8 +365,7 @@ class NodeInstance extends EventEmitter { ['--expose-internals'], `${scriptContents}\nprocess._rawDebug('started');`, undefined); const msg = 'Timed out waiting for process to start'; - while (await fires(instance.nextStderrString(), msg, TIMEOUT) !== - 'started') {} + while (await fires(instance.nextStderrString(), msg, TIMEOUT) !== 'started'); process._debugProcess(instance._process.pid); return instance; } diff --git a/test/common/report.js b/test/common/report.js index 98e230e769fca9..f1c0d05e490393 100644 --- a/test/common/report.js +++ b/test/common/report.js @@ -46,7 +46,9 @@ function validateContent(report, fields = []) { } catch (err) { try { err.stack += util.format('\n------\nFailing Report:\n%O', report); - } catch {} + } catch { + // Continue regardless of error. + } throw err; } } diff --git a/test/internet/test-dgram-broadcast-multi-process.js b/test/internet/test-dgram-broadcast-multi-process.js index 717b4dc01ea027..5972c5e24e537c 100644 --- a/test/internet/test-dgram-broadcast-multi-process.js +++ b/test/internet/test-dgram-broadcast-multi-process.js @@ -184,7 +184,9 @@ if (process.argv[2] !== 'child') { const buf = messages[i++]; if (!buf) { - try { sendSocket.close(); } catch {} + try { sendSocket.close(); } catch { + // Continue regardless of error. + } return; } diff --git a/test/internet/test-dgram-multicast-multi-process.js b/test/internet/test-dgram-multicast-multi-process.js index e19f8dc05b747a..6127748368c097 100644 --- a/test/internet/test-dgram-multicast-multi-process.js +++ b/test/internet/test-dgram-multicast-multi-process.js @@ -170,7 +170,9 @@ if (process.argv[2] !== 'child') { const buf = messages[i++]; if (!buf) { - try { sendSocket.close(); } catch {} + try { sendSocket.close(); } catch { + // Continue regardless of error. + } return; } diff --git a/test/internet/test-dgram-multicast-ssm-multi-process.js b/test/internet/test-dgram-multicast-ssm-multi-process.js index 5653559e243c7a..324c989a180fa0 100644 --- a/test/internet/test-dgram-multicast-ssm-multi-process.js +++ b/test/internet/test-dgram-multicast-ssm-multi-process.js @@ -164,7 +164,9 @@ if (process.argv[2] !== 'child') { const buf = messages[i++]; if (!buf) { - try { sendSocket.close(); } catch {} + try { sendSocket.close(); } catch { + // Continue regardless of error. + } return; } diff --git a/test/internet/test-dgram-multicast-ssmv6-multi-process.js b/test/internet/test-dgram-multicast-ssmv6-multi-process.js index e139d93a971a28..fd7b8dcd4ce011 100644 --- a/test/internet/test-dgram-multicast-ssmv6-multi-process.js +++ b/test/internet/test-dgram-multicast-ssmv6-multi-process.js @@ -164,7 +164,9 @@ if (process.argv[2] !== 'child') { const buf = messages[i++]; if (!buf) { - try { sendSocket.close(); } catch {} + try { sendSocket.close(); } catch { + // Continue regardless of error. + } return; } diff --git a/test/message/vm_dont_display_runtime_error.js b/test/message/vm_dont_display_runtime_error.js index 72568a21c7c339..49203684ed6609 100644 --- a/test/message/vm_dont_display_runtime_error.js +++ b/test/message/vm_dont_display_runtime_error.js @@ -30,7 +30,9 @@ try { filename: 'test.vm', displayErrors: false }); -} catch {} +} catch { + // Continue regardless of error. +} console.error('middle'); diff --git a/test/message/vm_dont_display_syntax_error.js b/test/message/vm_dont_display_syntax_error.js index 7e588c5095741a..38c49ad1a65315 100644 --- a/test/message/vm_dont_display_syntax_error.js +++ b/test/message/vm_dont_display_syntax_error.js @@ -30,7 +30,9 @@ try { filename: 'test.vm', displayErrors: false }); -} catch {} +} catch { + // Continue regardless of error. +} console.error('middle'); diff --git a/test/node-api/test_fatal/test_threads.js b/test/node-api/test_fatal/test_threads.js index fd56f60cbe832f..8c306694f5e259 100644 --- a/test/node-api/test_fatal/test_threads.js +++ b/test/node-api/test_fatal/test_threads.js @@ -8,8 +8,9 @@ const test_fatal = require(`./build/${common.buildType}/test_fatal`); // that crashes the process. if (process.argv[2] === 'child') { test_fatal.TestThread(); - // Busy loop to allow the work thread to abort. - while (true) {} + while (true) { + // Busy loop to allow the work thread to abort. + } } const p = child_process.spawnSync( diff --git a/test/node-api/test_fatal/test_threads_report.js b/test/node-api/test_fatal/test_threads_report.js index 83c6642bdc41eb..c2e635007db750 100644 --- a/test/node-api/test_fatal/test_threads_report.js +++ b/test/node-api/test_fatal/test_threads_report.js @@ -16,7 +16,7 @@ if (common.buildType === 'Debug') if (process.argv[2] === 'child') { test_fatal.TestThread(); // Busy loop to allow the work thread to abort. - while (true) {} + while (true); } tmpdir.refresh(); diff --git a/test/parallel/test-async-hooks-run-in-async-scope-caught-exception.js b/test/parallel/test-async-hooks-run-in-async-scope-caught-exception.js index 78e38c1e9312d7..e38cefd20e4fec 100644 --- a/test/parallel/test-async-hooks-run-in-async-scope-caught-exception.js +++ b/test/parallel/test-async-hooks-run-in-async-scope-caught-exception.js @@ -5,5 +5,7 @@ const { AsyncResource } = require('async_hooks'); try { new AsyncResource('foo').runInAsyncScope(() => { throw new Error('bar'); }); -} catch {} +} catch { + // Continue regardless of error. +} // Should abort (fail the case) if async id is not matching. diff --git a/test/parallel/test-cluster-kill-infinite-loop.js b/test/parallel/test-cluster-kill-infinite-loop.js index bd2384941b2122..57781b6972cadb 100644 --- a/test/parallel/test-cluster-kill-infinite-loop.js +++ b/test/parallel/test-cluster-kill-infinite-loop.js @@ -17,5 +17,5 @@ if (cluster.isPrimary) { assert.strictEqual(signal, 'SIGTERM'); })); } else { - while (true) {} + while (true); } diff --git a/test/parallel/test-domain-with-abort-on-uncaught-exception.js b/test/parallel/test-domain-with-abort-on-uncaught-exception.js index 5eed67d28ffa58..5f10b19926b955 100644 --- a/test/parallel/test-domain-with-abort-on-uncaught-exception.js +++ b/test/parallel/test-domain-with-abort-on-uncaught-exception.js @@ -49,6 +49,7 @@ if (process.argv[2] === 'child') { try { throw new Error(domainErrHandlerExMessage); } catch { + // Continue regardless of error. } } else { throw new Error(domainErrHandlerExMessage); diff --git a/test/parallel/test-file-write-stream2.js b/test/parallel/test-file-write-stream2.js index 487b5d44054373..eac81b805b108a 100644 --- a/test/parallel/test-file-write-stream2.js +++ b/test/parallel/test-file-write-stream2.js @@ -56,7 +56,9 @@ process.on('exit', function() { function removeTestFile() { try { fs.unlinkSync(filepath); - } catch {} + } catch { + // Continue regardless of error. + } } diff --git a/test/parallel/test-fs-access.js b/test/parallel/test-fs-access.js index d8e1c94300d2ed..8cc1afe39a9dd7 100644 --- a/test/parallel/test-fs-access.js +++ b/test/parallel/test-fs-access.js @@ -60,6 +60,7 @@ if (!common.isWindows && process.getuid() === 0) { process.setuid('nobody'); hasWriteAccessForReadonlyFile = false; } catch { + // Continue regardless of error. } } diff --git a/test/parallel/test-fs-promises-watch.js b/test/parallel/test-fs-promises-watch.js index 31ab1aafd43e63..055e798d0e49e4 100644 --- a/test/parallel/test-fs-promises-watch.js +++ b/test/parallel/test-fs-promises-watch.js @@ -75,33 +75,45 @@ for (const testCase of kCases) { } assert.rejects( - // eslint-disable-next-line no-unused-vars - async () => { for await (const _ of watch(1)) {} }, + async () => { + // eslint-disable-next-line no-unused-vars, no-empty + for await (const _ of watch(1)) { } + }, { code: 'ERR_INVALID_ARG_TYPE' }); assert.rejects( - // eslint-disable-next-line no-unused-vars - async () => { for await (const _ of watch(__filename, 1)) {} }, + async () => { + // eslint-disable-next-line no-unused-vars, no-empty + for await (const _ of watch(__filename, 1)) { } + }, { code: 'ERR_INVALID_ARG_TYPE' }); assert.rejects( - // eslint-disable-next-line no-unused-vars - async () => { for await (const _ of watch('', { persistent: 1 })) {} }, + async () => { + // eslint-disable-next-line no-unused-vars, no-empty + for await (const _ of watch('', { persistent: 1 })) { } + }, { code: 'ERR_INVALID_ARG_TYPE' }); assert.rejects( - // eslint-disable-next-line no-unused-vars - async () => { for await (const _ of watch('', { recursive: 1 })) {} }, + async () => { + // eslint-disable-next-line no-unused-vars, no-empty + for await (const _ of watch('', { recursive: 1 })) { } + }, { code: 'ERR_INVALID_ARG_TYPE' }); assert.rejects( - // eslint-disable-next-line no-unused-vars - async () => { for await (const _ of watch('', { encoding: 1 })) {} }, + async () => { + // eslint-disable-next-line no-unused-vars, no-empty + for await (const _ of watch('', { encoding: 1 })) { } + }, { code: 'ERR_INVALID_ARG_VALUE' }); assert.rejects( - // eslint-disable-next-line no-unused-vars - async () => { for await (const _ of watch('', { signal: 1 })) {} }, + async () => { + // eslint-disable-next-line no-unused-vars, no-empty + for await (const _ of watch('', { signal: 1 })) { } + }, { code: 'ERR_INVALID_ARG_TYPE' }); (async () => { @@ -109,8 +121,8 @@ assert.rejects( const { signal } = ac; setImmediate(() => ac.abort()); try { - // eslint-disable-next-line no-unused-vars - for await (const _ of watch(__filename, { signal })) {} + // eslint-disable-next-line no-unused-vars, no-empty + for await (const _ of watch(__filename, { signal })) { } } catch (err) { assert.strictEqual(err.name, 'AbortError'); } diff --git a/test/parallel/test-fs-realpath.js b/test/parallel/test-fs-realpath.js index 488e4b4ceaada3..3e9f3512b802fc 100644 --- a/test/parallel/test-fs-realpath.js +++ b/test/parallel/test-fs-realpath.js @@ -108,7 +108,9 @@ function test_simple_relative_symlink(realpath, realpathSync, callback) { [ [entry, `../${path.basename(tmpDir)}/cycles/root.js`], ].forEach(function(t) { - try { fs.unlinkSync(t[0]); } catch {} + try { fs.unlinkSync(t[0]); } catch { + // Continue regardless of error. + } console.log('fs.symlinkSync(%j, %j, %j)', t[1], t[0], 'file'); fs.symlinkSync(t[1], t[0], 'file'); unlink.push(t[0]); @@ -134,7 +136,9 @@ function test_simple_absolute_symlink(realpath, realpathSync, callback) { [ [entry, expected], ].forEach(function(t) { - try { fs.unlinkSync(t[0]); } catch {} + try { fs.unlinkSync(t[0]); } catch { + // Continue regardless of error. + } console.error('fs.symlinkSync(%j, %j, %j)', t[1], t[0], type); fs.symlinkSync(t[1], t[0], type); unlink.push(t[0]); @@ -159,13 +163,17 @@ function test_deep_relative_file_symlink(realpath, realpathSync, callback) { expected); const linkPath1 = path.join(targetsAbsDir, 'nested-index', 'one', 'symlink1.js'); - try { fs.unlinkSync(linkPath1); } catch {} + try { fs.unlinkSync(linkPath1); } catch { + // Continue regardless of error. + } fs.symlinkSync(linkData1, linkPath1, 'file'); const linkData2 = '../one/symlink1.js'; const entry = path.join(targetsAbsDir, 'nested-index', 'two', 'symlink1-b.js'); - try { fs.unlinkSync(entry); } catch {} + try { fs.unlinkSync(entry); } catch { + // Continue regardless of error. + } fs.symlinkSync(linkData2, entry, 'file'); unlink.push(linkPath1); unlink.push(entry); @@ -186,13 +194,17 @@ function test_deep_relative_dir_symlink(realpath, realpathSync, callback) { const path1b = path.join(targetsAbsDir, 'nested-index', 'one'); const linkPath1b = path.join(path1b, 'symlink1-dir'); const linkData1b = path.relative(path1b, expected); - try { fs.unlinkSync(linkPath1b); } catch {} + try { fs.unlinkSync(linkPath1b); } catch { + // Continue regardless of error. + } fs.symlinkSync(linkData1b, linkPath1b, 'dir'); const linkData2b = '../one/symlink1-dir'; const entry = path.join(targetsAbsDir, 'nested-index', 'two', 'symlink12-dir'); - try { fs.unlinkSync(entry); } catch {} + try { fs.unlinkSync(entry); } catch { + // Continue regardless of error. + } fs.symlinkSync(linkData2b, entry, 'dir'); unlink.push(linkPath1b); unlink.push(entry); @@ -216,7 +228,9 @@ function test_cyclic_link_protection(realpath, realpathSync, callback) { [path.join(tmpDir, '/cycles/realpath-3b'), '../cycles/realpath-3c'], [path.join(tmpDir, '/cycles/realpath-3c'), '../cycles/realpath-3a'], ].forEach(function(t) { - try { fs.unlinkSync(t[0]); } catch {} + try { fs.unlinkSync(t[0]); } catch { + // Continue regardless of error. + } fs.symlinkSync(t[1], t[0], 'dir'); unlink.push(t[0]); }); @@ -243,7 +257,9 @@ function test_cyclic_link_overprotection(realpath, realpathSync, callback) { const link = `${folder}/cycles`; let testPath = cycles; testPath += '/folder/cycles'.repeat(10); - try { fs.unlinkSync(link); } catch {} + try { fs.unlinkSync(link); } catch { + // Continue regardless of error. + } fs.symlinkSync(cycles, link, 'dir'); unlink.push(link); assertEqualPath(realpathSync(testPath), path.resolve(expected)); @@ -271,7 +287,9 @@ function test_relative_input_cwd(realpath, realpathSync, callback) { ].forEach(function(t) { const fn = t[0]; console.error('fn=%j', fn); - try { fs.unlinkSync(fn); } catch {} + try { fs.unlinkSync(fn); } catch { + // Continue regardless of error. + } const b = path.basename(t[1]); const type = (b === 'root.js' ? 'file' : 'dir'); console.log('fs.symlinkSync(%j, %j, %j)', t[1], fn, type); @@ -309,8 +327,12 @@ function test_deep_symlink_mix(realpath, realpathSync, callback) { // $tmpDir/targets/cycles/root.js (hard) const entry = tmp('node-test-realpath-f1'); - try { fs.unlinkSync(tmp('node-test-realpath-d2/foo')); } catch {} - try { fs.rmdirSync(tmp('node-test-realpath-d2')); } catch {} + try { fs.unlinkSync(tmp('node-test-realpath-d2/foo')); } catch { + // Continue regardless of error. + } + try { fs.rmdirSync(tmp('node-test-realpath-d2')); } catch { + // Continue regardless of error. + } fs.mkdirSync(tmp('node-test-realpath-d2'), 0o700); try { [ @@ -325,7 +347,9 @@ function test_deep_symlink_mix(realpath, realpathSync, callback) { [`${targetsAbsDir}/nested-index/two/realpath-c`, `${tmpDir}/cycles/root.js`], ].forEach(function(t) { - try { fs.unlinkSync(t[0]); } catch {} + try { fs.unlinkSync(t[0]); } catch { + // Continue regardless of error. + } fs.symlinkSync(t[1], t[0]); unlink.push(t[0]); }); @@ -479,14 +503,18 @@ function test_abs_with_kids(realpath, realpathSync, cb) { ['/a/b/c/x.txt', '/a/link', ].forEach(function(file) { - try { fs.unlinkSync(root + file); } catch {} + try { fs.unlinkSync(root + file); } catch { + // Continue regardless of error. + } }); ['/a/b/c', '/a/b', '/a', '', ].forEach(function(folder) { - try { fs.rmdirSync(root + folder); } catch {} + try { fs.rmdirSync(root + folder); } catch { + // Continue regardless of error. + } }); } diff --git a/test/parallel/test-global.js b/test/parallel/test-global.js index 60df2c1d73f463..2425ceaff8a650 100644 --- a/test/parallel/test-global.js +++ b/test/parallel/test-global.js @@ -36,7 +36,9 @@ builtinModules.forEach((moduleName) => { // This could throw for e.g., crypto if the binary is not compiled // accordingly. require(moduleName); - } catch {} + } catch { + // Continue regardless of error. + } } }); diff --git a/test/parallel/test-http-outgoing-finish.js b/test/parallel/test-http-outgoing-finish.js index f7931ec0dfa7e2..0f71cccdf810af 100644 --- a/test/parallel/test-http-outgoing-finish.js +++ b/test/parallel/test-http-outgoing-finish.js @@ -49,7 +49,7 @@ function write(out) { let endCb = false; // First, write until it gets some backpressure - while (out.write(buf, common.mustSucceed())) {} + while (out.write(buf, common.mustSucceed())); // Now end, and make sure that we don't get the 'finish' event // before the tick where the cb gets called. We give it until diff --git a/test/parallel/test-http-outgoing-message-capture-rejection.js b/test/parallel/test-http-outgoing-message-capture-rejection.js index 9fe9bdb21331d8..a19176df415263 100644 --- a/test/parallel/test-http-outgoing-message-capture-rejection.js +++ b/test/parallel/test-http-outgoing-message-capture-rejection.js @@ -19,7 +19,7 @@ events.captureRejections = true; })); // Write until there is space in the buffer - while (res.write('hello')) {} + while (res.write('hello')); })); server.listen(0, common.mustCall(() => { @@ -87,6 +87,6 @@ events.captureRejections = true; })); // Write until there is space in the buffer - while (req.write('hello')) {} + while (req.write('hello')); })); } diff --git a/test/parallel/test-http2-server-socket-destroy.js b/test/parallel/test-http2-server-socket-destroy.js index ffb7ea48dc3343..4e9a3f5ab375c0 100644 --- a/test/parallel/test-http2-server-socket-destroy.js +++ b/test/parallel/test-http2-server-socket-destroy.js @@ -62,5 +62,7 @@ server.on('listening', common.mustCall(async () => { try { await once(req, 'end'); - } catch {} + } catch { + // Continue regardless of error. + } })); diff --git a/test/parallel/test-listen-fd-detached-inherit.js b/test/parallel/test-listen-fd-detached-inherit.js index 81c07d1263e964..2a8e70f0f94230 100644 --- a/test/parallel/test-listen-fd-detached-inherit.js +++ b/test/parallel/test-listen-fd-detached-inherit.js @@ -69,7 +69,9 @@ function test() { process.kill(child.pid, 'SIGKILL'); try { parent.kill(); - } catch {} + } catch { + // Continue regardless of error. + } assert.strictEqual(s, 'hello from child\n'); assert.strictEqual(res.statusCode, 200); diff --git a/test/parallel/test-listen-fd-detached.js b/test/parallel/test-listen-fd-detached.js index efa08323047358..fba96a112f89b0 100644 --- a/test/parallel/test-listen-fd-detached.js +++ b/test/parallel/test-listen-fd-detached.js @@ -69,7 +69,9 @@ function test() { process.kill(child.pid, 'SIGKILL'); try { parent.kill(); - } catch {} + } catch { + // Continue regardless of error. + } assert.strictEqual(s, 'hello from child\n'); assert.strictEqual(res.statusCode, 200); diff --git a/test/parallel/test-performance-eventlooputil.js b/test/parallel/test-performance-eventlooputil.js index 9ce7212729d574..3b0c36892ea486 100644 --- a/test/parallel/test-performance-eventlooputil.js +++ b/test/parallel/test-performance-eventlooputil.js @@ -37,7 +37,7 @@ setTimeout(mustCall(function r() { return setTimeout(mustCall(r), 5); const t = Date.now(); - while (Date.now() - t < SPIN_DUR) { } + while (Date.now() - t < SPIN_DUR); const elu2 = eventLoopUtilization(elu1); const elu3 = eventLoopUtilization(); diff --git a/test/parallel/test-process-uid-gid.js b/test/parallel/test-process-uid-gid.js index 0e170620b7f237..23c51936e0c893 100644 --- a/test/parallel/test-process-uid-gid.js +++ b/test/parallel/test-process-uid-gid.js @@ -53,10 +53,18 @@ assert.throws(() => { // Passing -0 shouldn't crash the process // Refs: https://github.com/nodejs/node/issues/32750 -try { process.setuid(-0); } catch {} -try { process.seteuid(-0); } catch {} -try { process.setgid(-0); } catch {} -try { process.setegid(-0); } catch {} +try { process.setuid(-0); } catch { + // Continue regardless of error. +} +try { process.seteuid(-0); } catch { + // Continue regardless of error. +} +try { process.setgid(-0); } catch { + // Continue regardless of error. +} +try { process.setegid(-0); } catch { + // Continue regardless of error. +} // If we're not running as super user... if (process.getuid() !== 0) { diff --git a/test/parallel/test-stdout-to-file.js b/test/parallel/test-stdout-to-file.js index 014a304d3f0263..d66f382af5c1f8 100644 --- a/test/parallel/test-stdout-to-file.js +++ b/test/parallel/test-stdout-to-file.js @@ -19,7 +19,9 @@ function test(size, useBuffer, cb) { try { fs.unlinkSync(tmpFile); - } catch {} + } catch { + // Continue regardless of error. + } console.log(`${size} chars to ${tmpFile}...`); diff --git a/test/parallel/test-stream-pipeline-uncaught.js b/test/parallel/test-stream-pipeline-uncaught.js index bfac4f1fee8d0b..8aa1c47b7fd3b1 100644 --- a/test/parallel/test-stream-pipeline-uncaught.js +++ b/test/parallel/test-stream-pipeline-uncaught.js @@ -16,7 +16,7 @@ process.on('uncaughtException', common.mustCall((err) => { const s = new PassThrough(); s.end('data'); pipeline(s, async function(source) { - for await (const chunk of source) {} // eslint-disable-line no-unused-vars + for await (const chunk of source) { } // eslint-disable-line no-unused-vars, no-empty }, common.mustSucceed(() => { throw new Error('error'); })); diff --git a/test/parallel/test-stream-pipeline.js b/test/parallel/test-stream-pipeline.js index 192f971b29daca..81f350df0d68fd 100644 --- a/test/parallel/test-stream-pipeline.js +++ b/test/parallel/test-stream-pipeline.js @@ -700,7 +700,7 @@ const tsp = require('timers/promises'); await Promise.resolve(); yield 'hello'; }, async function*(source) { // eslint-disable-line require-yield - for await (const chunk of source) {} // eslint-disable-line no-unused-vars + for await (const chunk of source) { } // eslint-disable-line no-unused-vars, no-empty }, common.mustCall((err) => { assert.strictEqual(err, undefined); })); @@ -716,7 +716,7 @@ const tsp = require('timers/promises'); await Promise.resolve(); throw new Error('kaboom'); }, async function*(source) { // eslint-disable-line require-yield - for await (const chunk of source) {} // eslint-disable-line no-unused-vars + for await (const chunk of source) { } // eslint-disable-line no-unused-vars, no-empty }, common.mustCall((err) => { assert.strictEqual(err.message, 'kaboom'); })); diff --git a/test/parallel/test-stream-readable-async-iterators.js b/test/parallel/test-stream-readable-async-iterators.js index 45b27a155d0efd..87184662139ae5 100644 --- a/test/parallel/test-stream-readable-async-iterators.js +++ b/test/parallel/test-stream-readable-async-iterators.js @@ -243,8 +243,8 @@ async function tests() { let err; try { - // eslint-disable-next-line no-unused-vars - for await (const k of readable) {} + // eslint-disable-next-line no-unused-vars, no-empty + for await (const k of readable) { } } catch (e) { err = e; } @@ -461,12 +461,10 @@ async function tests() { this.push(null); } }); - // eslint-disable-next-line no-unused-vars - for await (const a of r) { - } - // eslint-disable-next-line no-unused-vars - for await (const b of r) { - } + // eslint-disable-next-line no-unused-vars, no-empty + for await (const a of r) { } + // eslint-disable-next-line no-unused-vars, no-empty + for await (const b of r) { } } { @@ -616,7 +614,7 @@ async function tests() { } }); - for await (const chunk of r) {} // eslint-disable-line no-unused-vars + for await (const chunk of r) { } // eslint-disable-line no-unused-vars, no-empty assert.strictEqual(r.destroyed, false); } @@ -649,8 +647,7 @@ async function tests() { assert.strictEqual(r.destroyed, false); }); - for await (const chunk of r) {} // eslint-disable-line no-unused-vars - + for await (const chunk of r) { } // eslint-disable-line no-unused-vars, no-empty assert.strictEqual(r.destroyed, true); } } @@ -812,8 +809,8 @@ async function tests() { let _err; try { - // eslint-disable-next-line no-unused-vars - for await (const chunk of res) {} + // eslint-disable-next-line no-unused-vars, no-empty + for await (const chunk of res) { } } catch (err) { _err = err; } diff --git a/test/parallel/test-stream-readable-destroy.js b/test/parallel/test-stream-readable-destroy.js index ffea6cb9c869f3..fa95b333a43761 100644 --- a/test/parallel/test-stream-readable-destroy.js +++ b/test/parallel/test-stream-readable-destroy.js @@ -314,8 +314,8 @@ const assert = require('assert'); assert.strictEqual(e.name, 'AbortError'); })); assert.rejects((async () => { - /* eslint-disable-next-line no-unused-vars */ - for await (const chunk of read) {} + // eslint-disable-next-line no-unused-vars, no-empty + for await (const chunk of read) { } })(), /AbortError/); setTimeout(() => controller.abort(), 0); } diff --git a/test/parallel/test-stream-readable-reading-readingMore.js b/test/parallel/test-stream-readable-reading-readingMore.js index f616b460488e75..968bf5c63ae0d3 100644 --- a/test/parallel/test-stream-readable-reading-readingMore.js +++ b/test/parallel/test-stream-readable-reading-readingMore.js @@ -41,7 +41,7 @@ const Readable = require('stream').Readable; assert.strictEqual(state.ended, !state.reading); // Consume all the data - while (readable.read() !== null) {} + while (readable.read() !== null); if (expectedReadingMore.length === 0) // Reached end of stream process.nextTick(common.mustCall(onStreamEnd, 1)); diff --git a/test/parallel/test-timers-interval-promisified.js b/test/parallel/test-timers-interval-promisified.js index 9c11a9d9870fa7..e6550445f142eb 100644 --- a/test/parallel/test-timers-interval-promisified.js +++ b/test/parallel/test-timers-interval-promisified.js @@ -251,8 +251,8 @@ process.on('multipleResolves', common.mustNotCall()); const signal = AbortSignal.abort('boom'); try { const iterable = timerPromises.setInterval(2, undefined, { signal }); - // eslint-disable-next-line no-unused-vars - for await (const _ of iterable) {} + // eslint-disable-next-line no-unused-vars, no-empty + for await (const _ of iterable) { } assert.fail('should have failed'); } catch (err) { assert.strictEqual(err.cause, 'boom'); diff --git a/test/parallel/test-vm-parse-abort-on-uncaught-exception.js b/test/parallel/test-vm-parse-abort-on-uncaught-exception.js index 4fcff30321f671..64bbb4dd4fcb98 100644 --- a/test/parallel/test-vm-parse-abort-on-uncaught-exception.js +++ b/test/parallel/test-vm-parse-abort-on-uncaught-exception.js @@ -7,8 +7,12 @@ const vm = require('vm'); try { new vm.Script({ toString() { throw new Error('foo'); } }, {}); -} catch {} +} catch { + // Continue regardless of error. +} try { new vm.Script('[', {}); -} catch {} +} catch { + // Continue regardless of error. +} diff --git a/test/parallel/test-whatwg-readablebytestream.js b/test/parallel/test-whatwg-readablebytestream.js index eb4355505053ef..dd804ff212822d 100644 --- a/test/parallel/test-whatwg-readablebytestream.js +++ b/test/parallel/test-whatwg-readablebytestream.js @@ -232,7 +232,3 @@ class Source { code: 'ERR_INVALID_STATE', }); } - -{ - -} diff --git a/test/pseudo-tty/test-trace-sigint.js b/test/pseudo-tty/test-trace-sigint.js index 8b539bfc88d7b8..4c715973e8bf93 100644 --- a/test/pseudo-tty/test-trace-sigint.js +++ b/test/pseudo-tty/test-trace-sigint.js @@ -26,5 +26,5 @@ function main() { // Deactivate colors even if the tty does support colors. process.env.NODE_DISABLE_COLORS = '1'; process.kill(process.pid, 'SIGINT'); - while (true) {} + while (true); } diff --git a/test/pummel/test-policy-integrity-dep.js b/test/pummel/test-policy-integrity-dep.js index 42948ce896e151..1b64e2bc99b1ea 100644 --- a/test/pummel/test-policy-integrity-dep.js +++ b/test/pummel/test-policy-integrity-dep.js @@ -196,7 +196,9 @@ function drainQueue() { const enoentFilepath = path.join(tmpdir.path, 'enoent'); try { fs.unlinkSync(enoentFilepath); - } catch { } + } catch { + // Continue regardless of error. + } const { status } = spawnSync( process.execPath, ['--experimental-policy', enoentFilepath, '-e', ''], @@ -282,8 +284,7 @@ for (const permutation of permutations({ } else if (permutation.depIntegrity === 'missing') { resources[depPath].integrities = null; shouldSucceed = false; - } else if (permutation.depIntegrity === 'match') { - } else { + } else if (permutation.depIntegrity !== 'match') { throw new Error('unreachable'); } if (parentFormat !== 'commonjs') { @@ -301,8 +302,7 @@ for (const permutation of permutations({ } else if (permutation.parentIntegrity === 'missing') { resources[parentPath].integrities = null; shouldSucceed = false; - } else if (permutation.parentIntegrity === 'match') { - } else { + } else if (permutation.parentIntegrity !== 'match') { throw new Error('unreachable'); } } @@ -324,8 +324,7 @@ for (const permutation of permutations({ } else if (permutation.packageIntegrity === 'missing') { packageIntegrities = []; shouldSucceed = false; - } else if (permutation.packageIntegrity === 'match') { - } else { + } else if (permutation.packageIntegrity !== 'match') { throw new Error('unreachable'); } resources['./package.json'] = { diff --git a/test/pummel/test-policy-integrity-parent-commonjs.js b/test/pummel/test-policy-integrity-parent-commonjs.js index 9ea62e4423219c..39febab73ee419 100644 --- a/test/pummel/test-policy-integrity-parent-commonjs.js +++ b/test/pummel/test-policy-integrity-parent-commonjs.js @@ -197,7 +197,9 @@ function drainQueue() { const enoentFilepath = path.join(tmpdir.path, 'enoent'); try { fs.unlinkSync(enoentFilepath); - } catch { } + } catch { + // Continue regardless of error. + } const { status } = spawnSync( process.execPath, ['--experimental-policy', enoentFilepath, '-e', ''], @@ -273,8 +275,7 @@ for (const permutation of permutations({ } else if (permutation.depIntegrity === 'missing') { resources[depPath].integrities = null; shouldSucceed = false; - } else if (permutation.depIntegrity === 'match') { - } else { + } else if (permutation.depIntegrity !== 'match') { throw new Error('unreachable'); } if (parentFormat !== 'commonjs') { @@ -291,8 +292,7 @@ for (const permutation of permutations({ } else if (permutation.parentIntegrity === 'missing') { resources[parentPath].integrities = null; shouldSucceed = false; - } else if (permutation.parentIntegrity === 'match') { - } else { + } else if (permutation.parentIntegrity !== 'match') { throw new Error('unreachable'); } @@ -312,8 +312,7 @@ for (const permutation of permutations({ } else if (permutation.packageIntegrity === 'missing') { packageIntegrities = []; shouldSucceed = false; - } else if (permutation.packageIntegrity === 'match') { - } else { + } else if (permutation.packageIntegrity !== 'match') { throw new Error('unreachable'); } resources['./package.json'] = { diff --git a/test/pummel/test-policy-integrity-parent-module.js b/test/pummel/test-policy-integrity-parent-module.js index aed2528bbeeb5c..e60a606ea32bbe 100644 --- a/test/pummel/test-policy-integrity-parent-module.js +++ b/test/pummel/test-policy-integrity-parent-module.js @@ -197,7 +197,9 @@ function drainQueue() { const enoentFilepath = path.join(tmpdir.path, 'enoent'); try { fs.unlinkSync(enoentFilepath); - } catch { } + } catch { + // Continue regardless of error. + } const { status } = spawnSync( process.execPath, ['--experimental-policy', enoentFilepath, '-e', ''], @@ -273,8 +275,7 @@ for (const permutation of permutations({ } else if (permutation.depIntegrity === 'missing') { resources[depPath].integrities = null; shouldSucceed = false; - } else if (permutation.depIntegrity === 'match') { - } else { + } else if (permutation.depIntegrity !== 'match') { throw new Error('unreachable'); } if (parentFormat !== 'commonjs') { @@ -291,8 +292,7 @@ for (const permutation of permutations({ } else if (permutation.parentIntegrity === 'missing') { resources[parentPath].integrities = null; shouldSucceed = false; - } else if (permutation.parentIntegrity === 'match') { - } else { + } else if (permutation.parentIntegrity !== 'match') { throw new Error('unreachable'); } @@ -312,8 +312,7 @@ for (const permutation of permutations({ } else if (permutation.packageIntegrity === 'missing') { packageIntegrities = []; shouldSucceed = false; - } else if (permutation.packageIntegrity === 'match') { - } else { + } else if (permutation.packageIntegrity !== 'match') { throw new Error('unreachable'); } resources['./package.json'] = { diff --git a/test/pummel/test-policy-integrity-parent-no-package-json.js b/test/pummel/test-policy-integrity-parent-no-package-json.js index c00a5e31921efc..f2208744447827 100644 --- a/test/pummel/test-policy-integrity-parent-no-package-json.js +++ b/test/pummel/test-policy-integrity-parent-no-package-json.js @@ -197,7 +197,9 @@ function drainQueue() { const enoentFilepath = path.join(tmpdir.path, 'enoent'); try { fs.unlinkSync(enoentFilepath); - } catch { } + } catch { + // Continue regardless of error. + } const { status } = spawnSync( process.execPath, ['--experimental-policy', enoentFilepath, '-e', ''], @@ -269,8 +271,7 @@ for (const permutation of permutations({ } else if (permutation.depIntegrity === 'missing') { resources[depPath].integrities = null; shouldSucceed = false; - } else if (permutation.depIntegrity === 'match') { - } else { + } else if (permutation.depIntegrity !== 'match') { throw new Error('unreachable'); } if (parentFormat !== 'commonjs') { @@ -287,8 +288,7 @@ for (const permutation of permutations({ } else if (permutation.parentIntegrity === 'missing') { resources[parentPath].integrities = null; shouldSucceed = false; - } else if (permutation.parentIntegrity === 'match') { - } else { + } else if (permutation.parentIntegrity !== 'match') { throw new Error('unreachable'); } diff --git a/test/pummel/test-policy-integrity-worker-commonjs.js b/test/pummel/test-policy-integrity-worker-commonjs.js index 6ddcb74c9dae40..22a7d762466046 100644 --- a/test/pummel/test-policy-integrity-worker-commonjs.js +++ b/test/pummel/test-policy-integrity-worker-commonjs.js @@ -214,7 +214,9 @@ function drainQueue() { const enoentFilepath = path.join(tmpdir.path, 'enoent'); try { fs.unlinkSync(enoentFilepath); - } catch { } + } catch { + // Continue regardless of error. + } const { status } = spawnSync( process.execPath, ['--experimental-policy', enoentFilepath, '-e', ''], @@ -290,8 +292,7 @@ for (const permutation of permutations({ } else if (permutation.depIntegrity === 'missing') { resources[depPath].integrities = null; shouldSucceed = false; - } else if (permutation.depIntegrity === 'match') { - } else { + } else if (permutation.depIntegrity !== 'match') { throw new Error('unreachable'); } if (parentFormat !== 'commonjs') { @@ -308,8 +309,7 @@ for (const permutation of permutations({ } else if (permutation.parentIntegrity === 'missing') { resources[parentPath].integrities = null; shouldSucceed = false; - } else if (permutation.parentIntegrity === 'match') { - } else { + } else if (permutation.parentIntegrity !== 'match') { throw new Error('unreachable'); } @@ -335,8 +335,7 @@ for (const permutation of permutations({ } else if (permutation.packageIntegrity === 'missing') { packageIntegrities = []; shouldSucceed = false; - } else if (permutation.packageIntegrity === 'match') { - } else { + } else if (permutation.packageIntegrity !== 'match') { throw new Error('unreachable'); } resources['./package.json'] = { diff --git a/test/pummel/test-policy-integrity-worker-module.js b/test/pummel/test-policy-integrity-worker-module.js index 69a7fb448283c3..e5d4e4cd45d300 100644 --- a/test/pummel/test-policy-integrity-worker-module.js +++ b/test/pummel/test-policy-integrity-worker-module.js @@ -214,7 +214,9 @@ function drainQueue() { const enoentFilepath = path.join(tmpdir.path, 'enoent'); try { fs.unlinkSync(enoentFilepath); - } catch { } + } catch { + // Continue regardless of error. + } const { status } = spawnSync( process.execPath, ['--experimental-policy', enoentFilepath, '-e', ''], @@ -290,8 +292,7 @@ for (const permutation of permutations({ } else if (permutation.depIntegrity === 'missing') { resources[depPath].integrities = null; shouldSucceed = false; - } else if (permutation.depIntegrity === 'match') { - } else { + } else if (permutation.depIntegrity !== 'match') { throw new Error('unreachable'); } if (parentFormat !== 'commonjs') { @@ -308,8 +309,7 @@ for (const permutation of permutations({ } else if (permutation.parentIntegrity === 'missing') { resources[parentPath].integrities = null; shouldSucceed = false; - } else if (permutation.parentIntegrity === 'match') { - } else { + } else if (permutation.parentIntegrity !== 'match') { throw new Error('unreachable'); } @@ -334,8 +334,7 @@ for (const permutation of permutations({ } else if (permutation.packageIntegrity === 'missing') { packageIntegrities = []; shouldSucceed = false; - } else if (permutation.packageIntegrity === 'match') { - } else { + } else if (permutation.packageIntegrity !== 'match') { throw new Error('unreachable'); } resources['./package.json'] = { diff --git a/test/pummel/test-policy-integrity-worker-no-package-json.js b/test/pummel/test-policy-integrity-worker-no-package-json.js index 909e58be5650d6..808687f40ea219 100644 --- a/test/pummel/test-policy-integrity-worker-no-package-json.js +++ b/test/pummel/test-policy-integrity-worker-no-package-json.js @@ -214,7 +214,9 @@ function drainQueue() { const enoentFilepath = path.join(tmpdir.path, 'enoent'); try { fs.unlinkSync(enoentFilepath); - } catch { } + } catch { + // Continue regardless of error. + } const { status } = spawnSync( process.execPath, ['--experimental-policy', enoentFilepath, '-e', ''], @@ -286,8 +288,7 @@ for (const permutation of permutations({ } else if (permutation.depIntegrity === 'missing') { resources[depPath].integrities = null; shouldSucceed = false; - } else if (permutation.depIntegrity === 'match') { - } else { + } else if (permutation.depIntegrity !== 'match') { throw new Error('unreachable'); } if (parentFormat !== 'commonjs') { @@ -304,8 +305,7 @@ for (const permutation of permutations({ } else if (permutation.parentIntegrity === 'missing') { resources[parentPath].integrities = null; shouldSucceed = false; - } else if (permutation.parentIntegrity === 'match') { - } else { + } else if (permutation.parentIntegrity !== 'match') { throw new Error('unreachable'); } diff --git a/test/pummel/test-vm-memleak.js b/test/pummel/test-vm-memleak.js index 419b4171d226e9..be29dfe867f293 100644 --- a/test/pummel/test-vm-memleak.js +++ b/test/pummel/test-vm-memleak.js @@ -39,6 +39,7 @@ const interval = setInterval(function() { try { vm.runInNewContext('throw 1;'); } catch { + // Continue regardless of error. } global.gc(); diff --git a/test/sequential/test-net-response-size.js b/test/sequential/test-net-response-size.js index c5d7e9b600e05d..c2dd8e0e95c1d7 100644 --- a/test/sequential/test-net-response-size.js +++ b/test/sequential/test-net-response-size.js @@ -65,7 +65,7 @@ if (process.argv[2] === 'server') { // Block the event loop for 1 second const start = (new Date()).getTime(); - while ((new Date()).getTime() < start + 1000) {} + while ((new Date()).getTime() < start + 1000); client.write(alittle);