diff options
author | Rich Trott <rtrott@gmail.com> | 2022-02-03 09:35:32 +0300 |
---|---|---|
committer | Node.js GitHub Bot <github-bot@iojs.org> | 2022-02-05 15:58:32 +0300 |
commit | 5d559f4a748fa85f67f50b23916a9ef6cf9260a1 (patch) | |
tree | 1d156014abfe5d6da640ea3fe6ef38a0eb32f83f /test | |
parent | 73a75c2ee63ea65709f63b71ade3b81a02b519fc (diff) |
test: enable no-empty ESLint rule
PR-URL: https://github.com/nodejs/node/pull/41831
Refs: https://eslint.org/docs/rules/no-empty
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Diffstat (limited to 'test')
46 files changed, 206 insertions, 132 deletions
diff --git a/test/.eslintrc.yaml b/test/.eslintrc.yaml index 55e8ff6af8c..d9a0e3d3c5f 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 73d40ca7996..c1cf6c550b6 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 fec48ddcba7..28b5ab5209a 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 98e230e769f..f1c0d05e490 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 717b4dc01ea..5972c5e24e5 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 e19f8dc05b7..6127748368c 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 5653559e243..324c989a180 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 e139d93a971..fd7b8dcd4ce 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 72568a21c7c..49203684ed6 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 7e588c50957..38c49ad1a65 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 fd56f60cbe8..8c306694f5e 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 83c6642bdc4..c2e635007db 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 78e38c1e931..e38cefd20e4 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 bd2384941b2..57781b6972c 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 5eed67d28ff..5f10b19926b 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 487b5d44054..eac81b805b1 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 d8e1c94300d..8cc1afe39a9 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 31ab1aafd43..055e798d0e4 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 488e4b4ceaa..3e9f3512b80 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 60df2c1d73f..2425ceaff8a 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 f7931ec0dfa..0f71cccdf81 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 9fe9bdb2133..a19176df415 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 ffb7ea48dc3..4e9a3f5ab37 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 81c07d1263e..2a8e70f0f94 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 efa08323047..fba96a112f8 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 9ce7212729d..3b0c36892ea 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 0e170620b7f..23c51936e0c 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 014a304d3f0..d66f382af5c 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 bfac4f1fee8..8aa1c47b7fd 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 192f971b29d..81f350df0d6 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 45b27a155d0..87184662139 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 51f4521686e..fc82f44bc9d 100644 --- a/test/parallel/test-stream-readable-destroy.js +++ b/test/parallel/test-stream-readable-destroy.js @@ -316,8 +316,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 f616b460488..968bf5c63ae 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 9c11a9d9870..e6550445f14 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 4fcff30321f..64bbb4dd4fc 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 eb435550505..dd804ff2128 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 8b539bfc88d..4c715973e8b 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 42948ce896e..1b64e2bc99b 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 9ea62e44232..39febab73ee 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 aed2528bbee..e60a606ea32 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 c00a5e31921..f2208744447 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 6ddcb74c9da..22a7d762466 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 69a7fb44828..e5d4e4cd45d 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 909e58be565..808687f40ea 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 419b4171d22..be29dfe867f 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 c5d7e9b600e..c2dd8e0e95c 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); |