diff --git a/.eslintrc.js b/.eslintrc.js index 8e6a2f99aeb065..7c939124ee267e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -295,7 +295,6 @@ module.exports = { 'valid-typeof': ['error', { requireStringLiterals: true }], // ESLint recommended rules that we disable - 'no-empty': 'off', 'no-inner-declarations': 'off', // JSDoc recommended rules that we disable diff --git a/benchmark/es/foreach-bench.js b/benchmark/es/foreach-bench.js index 6992a1a5749438..86bd8dff4c0a2c 100644 --- a/benchmark/es/foreach-bench.js +++ b/benchmark/es/foreach-bench.js @@ -22,7 +22,7 @@ function useFor(n, items, count) { function useForOf(n, items) { bench.start(); for (let i = 0; i < n; i++) { - // eslint-disable-next-line no-unused-vars + // eslint-disable-next-line no-unused-vars, no-empty for (const item of items) {} } bench.end(n); diff --git a/benchmark/fs/bench-statSync-failure.js b/benchmark/fs/bench-statSync-failure.js index 82cb24c09f4af2..dd69259eacd07e 100644 --- a/benchmark/fs/bench-statSync-failure.js +++ b/benchmark/fs/bench-statSync-failure.js @@ -21,6 +21,7 @@ function main({ n, statSyncType }) { try { fs.statSync(arg); } catch { + // Continue regardless of error. } } } diff --git a/benchmark/fs/read-stream-throughput.js b/benchmark/fs/read-stream-throughput.js index 5984317ff91743..d4a0a798409a12 100644 --- a/benchmark/fs/read-stream-throughput.js +++ b/benchmark/fs/read-stream-throughput.js @@ -50,7 +50,11 @@ function main(conf) { buf.fill('x'); } - try { fs.unlinkSync(filename); } catch {} + try { + fs.unlinkSync(filename); + } catch { + // Continue regardless of error. + } const ws = fs.createWriteStream(filename); ws.on('close', runTest.bind(null, filesize, highWaterMark, encoding, n)); ws.on('drain', write); @@ -81,7 +85,11 @@ function runTest(filesize, highWaterMark, encoding, n) { }); rs.on('end', () => { - try { fs.unlinkSync(filename); } catch {} + try { + fs.unlinkSync(filename); + } catch { + // Continue regardless of error. + } // MB/sec bench.end(bytes / (1024 * 1024)); }); diff --git a/benchmark/fs/readfile-partitioned.js b/benchmark/fs/readfile-partitioned.js index 51700cfd649dfd..fac331ec38ba82 100644 --- a/benchmark/fs/readfile-partitioned.js +++ b/benchmark/fs/readfile-partitioned.js @@ -23,7 +23,11 @@ const bench = common.createBenchmark(main, { }); function main({ len, dur, concurrent }) { - try { fs.unlinkSync(filename); } catch {} + try { + fs.unlinkSync(filename); + } catch { + // Continue regardless of error. + } let data = Buffer.alloc(len, 'x'); fs.writeFileSync(filename, data); data = null; @@ -38,7 +42,11 @@ function main({ len, dur, concurrent }) { const totalOps = reads + zips; benchEnded = true; bench.end(totalOps); - try { fs.unlinkSync(filename); } catch {} + try { + fs.unlinkSync(filename); + } catch { + // Continue regardless of error. + } }, dur * 1000); function read() { diff --git a/benchmark/fs/readfile-promises.js b/benchmark/fs/readfile-promises.js index 28633c3f06427b..5cfa5b4cc02465 100644 --- a/benchmark/fs/readfile-promises.js +++ b/benchmark/fs/readfile-promises.js @@ -20,7 +20,11 @@ const bench = common.createBenchmark(main, { }); function main({ len, duration, concurrent }) { - try { fs.unlinkSync(filename); } catch { } + try { + fs.unlinkSync(filename); + } catch { + // Continue regardless of error. + } let data = Buffer.alloc(len, 'x'); fs.writeFileSync(filename, data); data = null; @@ -31,7 +35,11 @@ function main({ len, duration, concurrent }) { setTimeout(() => { benchEnded = true; bench.end(writes); - try { fs.unlinkSync(filename); } catch { } + try { + fs.unlinkSync(filename); + } catch { + // Continue regardless of error. + } process.exit(0); }, duration * 1000); diff --git a/benchmark/fs/readfile.js b/benchmark/fs/readfile.js index 3f996e02ede876..e27fe08f43ca86 100644 --- a/benchmark/fs/readfile.js +++ b/benchmark/fs/readfile.js @@ -20,7 +20,11 @@ const bench = common.createBenchmark(main, { }); function main({ len, duration, concurrent }) { - try { fs.unlinkSync(filename); } catch {} + try { + fs.unlinkSync(filename); + } catch { + // Continue regardless of error. + } let data = Buffer.alloc(len, 'x'); fs.writeFileSync(filename, data); data = null; @@ -31,7 +35,11 @@ function main({ len, duration, concurrent }) { setTimeout(() => { benchEnded = true; bench.end(reads); - try { fs.unlinkSync(filename); } catch {} + try { + fs.unlinkSync(filename); + } catch { + // Continue regardless of error. + } process.exit(0); }, duration * 1000); diff --git a/benchmark/fs/write-stream-throughput.js b/benchmark/fs/write-stream-throughput.js index 44a3bb23b041d1..88d3bce06d114e 100644 --- a/benchmark/fs/write-stream-throughput.js +++ b/benchmark/fs/write-stream-throughput.js @@ -36,7 +36,11 @@ function main({ dur, encodingType, size }) { throw new Error(`invalid encodingType: ${encodingType}`); } - try { fs.unlinkSync(filename); } catch {} + try { + fs.unlinkSync(filename); + } catch { + // Continue regardless of error. + } let started = false; let ended = false; @@ -48,7 +52,11 @@ function main({ dur, encodingType, size }) { f.on('finish', () => { ended = true; const written = fs.statSync(filename).size / 1024; - try { fs.unlinkSync(filename); } catch {} + try { + fs.unlinkSync(filename); + } catch { + // Continue regardless of error. + } bench.end(written / 1024); }); diff --git a/benchmark/fs/writefile-promises.js b/benchmark/fs/writefile-promises.js index 2ba25184ff3132..8b3cd528bac5c9 100644 --- a/benchmark/fs/writefile-promises.js +++ b/benchmark/fs/writefile-promises.js @@ -46,7 +46,11 @@ function main({ encodingType, duration, concurrent, size }) { benchEnded = true; bench.end(writes); for (let i = 0; i < filesWritten; i++) { - try { fs.unlinkSync(`${filename}-${i}`); } catch { } + try { + fs.unlinkSync(`${filename}-${i}`); + } catch { + // Continue regardless of error. + } } process.exit(0); }, duration * 1000); diff --git a/benchmark/misc/punycode.js b/benchmark/misc/punycode.js index 9c674b5deefb8c..d0ee938ebd39a3 100644 --- a/benchmark/misc/punycode.js +++ b/benchmark/misc/punycode.js @@ -4,7 +4,9 @@ const common = require('../common.js'); let icu; try { icu = common.binding('icu'); -} catch {} +} catch { + // Continue regardless of error. +} const punycode = require('punycode'); const bench = common.createBenchmark(main, { diff --git a/benchmark/net/net-c2s-cork.js b/benchmark/net/net-c2s-cork.js index 1493cae68d0069..9a1129218531f1 100644 --- a/benchmark/net/net-c2s-cork.js +++ b/benchmark/net/net-c2s-cork.js @@ -55,7 +55,7 @@ function main({ dur, len, type }) { function send() { socket.cork(); - while (socket.write(chunk, encoding)) {} + while (socket.write(chunk, encoding)); socket.uncork(); } }); diff --git a/doc/api/console.md b/doc/api/console.md index 5c8b4ecc64d9b4..bd890e20a79a59 100644 --- a/doc/api/console.md +++ b/doc/api/console.md @@ -469,10 +469,10 @@ Stops a timer that was previously started by calling [`console.time()`][] and prints the result to `stdout`: ```js -console.time('100-elements'); -for (let i = 0; i < 100; i++) {} -console.timeEnd('100-elements'); -// prints 100-elements: 225.438ms +console.time('bunch-of-stuff'); +// Do a bunch of stuff. +console.timeEnd('bunch-of-stuff'); +// Prints: bunch-of-stuff: 225.438ms ``` ### `console.timeLog([label][, ...data])` diff --git a/doc/api/worker_threads.md b/doc/api/worker_threads.md index e2b165ce0e8b1f..362cad18023c7f 100644 --- a/doc/api/worker_threads.md +++ b/doc/api/worker_threads.md @@ -1255,7 +1255,9 @@ import { if (isMainThread) { new Worker(new URL(import.meta.url)); - for (let n = 0; n < 1e10; n++) {} + for (let n = 0; n < 1e10; n++) { + // Looping to simulate work. + } } else { // This output will be blocked by the for loop in the main thread. console.log('foo'); @@ -1272,7 +1274,9 @@ const { if (isMainThread) { new Worker(__filename); - for (let n = 0; n < 1e10; n++) {} + for (let n = 0; n < 1e10; n++) { + // Looping to simulate work. + } } else { // This output will be blocked by the for loop in the main thread. console.log('foo'); diff --git a/lib/events.js b/lib/events.js index 3b992f39bf7990..e140c1a5f3d6bd 100644 --- a/lib/events.js +++ b/lib/events.js @@ -445,7 +445,9 @@ function enhanceStackTrace(err, own) { const { name } = this.constructor; if (name !== 'EventEmitter') ctorInfo = ` on ${name} instance`; - } catch {} + } catch { + // Continue regardless of error. + } const sep = `\nEmitted 'error' event${ctorInfo} at:\n`; const errStack = ArrayPrototypeSlice( @@ -493,7 +495,9 @@ EventEmitter.prototype.emit = function emit(type, ...args) { value: FunctionPrototypeBind(enhanceStackTrace, this, er, capture), configurable: true }); - } catch {} + } catch { + // Continue regardless of error. + } // Note: The comments on the `throw` lines are intentional, they show // up in Node's output if this results in an unhandled exception. diff --git a/lib/fs.js b/lib/fs.js index c1cc7aecaa49e4..65c828ea110d2d 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -1600,7 +1600,9 @@ function symlink(target, path, type_, callback_) { // errors consistent between platforms if invalid path is // provided. absoluteTarget = pathModule.resolve(path, '..', target); - } catch { } + } catch { + // Continue regardless of error. + } if (absoluteTarget !== undefined) { stat(absoluteTarget, (err, stat) => { const resolvedType = !err && stat.isDirectory() ? 'dir' : 'file'; diff --git a/lib/internal/bootstrap/pre_execution.js b/lib/internal/bootstrap/pre_execution.js index 71b0afd4e67c99..f21ba048b48638 100644 --- a/lib/internal/bootstrap/pre_execution.js +++ b/lib/internal/bootstrap/pre_execution.js @@ -97,7 +97,9 @@ function patchProcessObject(expandArgv1) { const path = require('path'); try { process.argv[1] = path.resolve(process.argv[1]); - } catch {} + } catch { + // Continue regardless of error. + } } // TODO(joyeecheung): most of these should be deprecated and removed, diff --git a/lib/internal/error_serdes.js b/lib/internal/error_serdes.js index 6a2081b8e2d4ff..c364820f60b1aa 100644 --- a/lib/internal/error_serdes.js +++ b/lib/internal/error_serdes.js @@ -48,7 +48,9 @@ function TryGetAllProperties(object, target = object) { if (getter && key !== '__proto__') { try { descriptor.value = FunctionPrototypeCall(getter, target); - } catch {} + } catch { + // Continue regardless of error. + } } if ('value' in descriptor && typeof descriptor.value !== 'function') { delete descriptor.get; @@ -107,11 +109,15 @@ function serializeError(error) { } } } - } catch {} + } catch { + // Continue regardless of error. + } try { const serialized = serialize(error); return Buffer.concat([Buffer.from([kSerializedObject]), serialized]); - } catch {} + } catch { + // Continue regardless of error. + } return Buffer.concat([Buffer.from([kInspectedError]), Buffer.from(inspect(error), 'utf8')]); } diff --git a/lib/internal/main/worker_thread.js b/lib/internal/main/worker_thread.js index 71a07a63a3636a..65827ecd593ffb 100644 --- a/lib/internal/main/worker_thread.js +++ b/lib/internal/main/worker_thread.js @@ -224,14 +224,18 @@ function workerOnGlobalUncaughtException(error, fromPromise) { if (!handlerThrew) { process.emit('exit', process.exitCode); } - } catch {} + } catch { + // Continue regardless of error. + } } let serialized; try { const { serializeError } = require('internal/error_serdes'); serialized = serializeError(error); - } catch {} + } catch { + // Continue regardless of error. + } debug(`[${threadId}] uncaught exception serialized = ${!!serialized}`); if (serialized) port.postMessage({ diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index 5c2de2d9c57ffd..cfe2982bf22c24 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -1134,7 +1134,9 @@ Module._extensions['.js'] = function(module, filename) { let parentSource; try { parentSource = fs.readFileSync(parentPath, 'utf8'); - } catch {} + } catch { + // Continue regardless of error. + } if (parentSource) { const errLine = StringPrototypeSplit( StringPrototypeSlice(err.stack, StringPrototypeIndexOf( diff --git a/lib/internal/modules/esm/module_job.js b/lib/internal/modules/esm/module_job.js index 018d598796f153..fd1c6166330e76 100644 --- a/lib/internal/modules/esm/module_job.js +++ b/lib/internal/modules/esm/module_job.js @@ -154,7 +154,9 @@ class ModuleJob { // care about CommonJS for the purposes of this error message. ({ format } = await this.loader.load(childFileURL)); - } catch {} + } catch { + // Continue regardless of error. + } if (format === 'commonjs') { const importStatement = splitStack[1]; diff --git a/lib/internal/modules/esm/resolve.js b/lib/internal/modules/esm/resolve.js index 688c0410a3e063..a4be89cc949b76 100644 --- a/lib/internal/modules/esm/resolve.js +++ b/lib/internal/modules/esm/resolve.js @@ -498,7 +498,9 @@ function resolvePackageTargetString( try { new URL(target); isURL = true; - } catch {} + } catch { + // Continue regardless of error. + } if (!isURL) { const exportTarget = pattern ? RegExpPrototypeSymbolReplace(patternRegEx, target, () => subpath) : diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js index 297ac95e662670..da95703faad9fd 100644 --- a/lib/internal/modules/esm/translators.js +++ b/lib/internal/modules/esm/translators.js @@ -180,7 +180,9 @@ translators.set('commonjs', async function commonjsStrategy(url, source, let value; try { value = exports[exportName]; - } catch {} + } catch { + // Continue regardless of error. + } this.setExport(exportName, value); } this.setExport('default', exports); @@ -205,7 +207,9 @@ function cjsPreparseModuleExports(filename) { let source; try { source = readFileSync(filename, 'utf8'); - } catch {} + } catch { + // Continue regardless of error. + } let exports, reexports; try { diff --git a/lib/internal/policy/manifest.js b/lib/internal/policy/manifest.js index 61ee55d3a45637..1be12eb4635d36 100644 --- a/lib/internal/policy/manifest.js +++ b/lib/internal/policy/manifest.js @@ -430,12 +430,11 @@ class Manifest { if (objectButNotArray(obj) && 'onerror' in obj) { const behavior = obj.onerror; - if (behavior === 'throw') { - } else if (behavior === 'exit') { + if (behavior === 'exit') { reaction = REACTION_EXIT; } else if (behavior === 'log') { reaction = REACTION_LOG; - } else { + } else if (behavior !== 'throw') { throw new ERR_MANIFEST_UNKNOWN_ONERROR(behavior); } } @@ -579,8 +578,7 @@ class Manifest { const entry = this.#scopeIntegrities.get(scope); if (entry === true) { return true; - } else if (entry === kCascade) { - } else { + } else if (entry !== kCascade) { break; } } @@ -639,7 +637,9 @@ function canonicalizeSpecifier(specifier, base) { return resolve(specifier, base).href; } return resolve(specifier).href; - } catch {} + } catch { + // Continue regardless of error. + } return specifier; } diff --git a/lib/internal/process/execution.js b/lib/internal/process/execution.js index 1311349951c5b9..4a8e51f694f7e6 100644 --- a/lib/internal/process/execution.js +++ b/lib/internal/process/execution.js @@ -155,7 +155,9 @@ function createOnGlobalUncaughtException() { null, er ?? {}); } - } catch {} // Ignore the exception. Diagnostic reporting is unavailable. + } catch { + // Ignore the exception. Diagnostic reporting is unavailable. + } } const type = fromPromise ? 'unhandledRejection' : 'uncaughtException'; diff --git a/lib/internal/process/warning.js b/lib/internal/process/warning.js index 90c6076dc54965..9778990630dcaa 100644 --- a/lib/internal/process/warning.js +++ b/lib/internal/process/warning.js @@ -61,7 +61,9 @@ function writeToFile(message) { process.on('exit', () => { try { fs.closeSync(fd); - } catch {} + } catch { + // Continue regardless of error. + } }); } fs.appendFile(fd, `${message}\n`, (err) => { diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index ca3227dea43c99..d78a4e97d218a6 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -268,7 +268,9 @@ function getUserOptions(ctx, isCrossContext) { let stylized; try { stylized = `${ctx.stylize(value, flavour)}`; - } catch {} + } catch { + // Continue regardless of error. + } if (typeof stylized !== 'string') return value; // `stylized` is a string as it should be, which is safe to pass along. diff --git a/lib/internal/webstreams/readablestream.js b/lib/internal/webstreams/readablestream.js index bb1bbf947b4e0b..76200cbc1e876c 100644 --- a/lib/internal/webstreams/readablestream.js +++ b/lib/internal/webstreams/readablestream.js @@ -1358,7 +1358,7 @@ function readableStreamPipeTo( async function run() { // Run until step resolves as true - while (!await step()) {} + while (!await step()); } if (signal !== undefined) { diff --git a/lib/repl.js b/lib/repl.js index c576f5b7f3094d..8e31ec43add7cc 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -445,6 +445,7 @@ function REPLServer(prompt, // to the parent of `process.cwd()`. parentURL = pathToFileURL(path.join(process.cwd(), 'repl')).href; } catch { + // Continue regardless of error. } // Remove all "await"s and attempt running the script @@ -485,6 +486,7 @@ function REPLServer(prompt, // to the parent of `process.cwd()`. parentURL = pathToFileURL(path.join(process.cwd(), 'repl')).href; } catch { + // Continue regardless of error. } while (true) { try { @@ -1236,7 +1238,9 @@ REPLServer.prototype.complete = function() { function gracefulReaddir(...args) { try { return ReflectApply(fs.readdirSync, null, args); - } catch {} + } catch { + // Continue regardless of error. + } } function completeFSFunctions(line) { diff --git a/test/.eslintrc.yaml b/test/.eslintrc.yaml index 55e8ff6af8c390..67a2b9667bb583 100644 --- a/test/.eslintrc.yaml +++ b/test/.eslintrc.yaml @@ -5,10 +5,10 @@ env: es6: true rules: + multiline-comment-style: ["error", "separate-lines"] 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 9c98ce6252c0e3..0a47cb1d58981a 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 dbd3b06d290d31..5ca163f41e7307 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-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 0864e287d72ced..5c237f2cb7f0de 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 a497317565fb4c..3bbb4dbd69abd9 100644 --- a/test/parallel/test-stream-readable-async-iterators.js +++ b/test/parallel/test-stream-readable-async-iterators.js @@ -242,8 +242,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; } @@ -449,12 +449,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) { } } { @@ -594,7 +592,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); } @@ -627,8 +625,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); } } @@ -737,7 +734,7 @@ async function tests() { const readable = createErrorReadable(); try { // eslint-disable-next-line no-unused-vars - for await (const chunk of readable) { } + for await (const chunk of readable); assert.fail('should have thrown'); } catch (err) { assert.strictEqual(err.message, 'inner'); @@ -752,7 +749,7 @@ async function tests() { const opts = { destroyOnError: true, destroyOnReturn: false }; try { // eslint-disable-next-line no-unused-vars - for await (const chunk of readable.iterator(opts)) { } + for await (const chunk of readable.iterator(opts)); assert.fail('should have thrown'); } catch (err) { assert.strictEqual(err.message, 'inner'); @@ -767,7 +764,7 @@ async function tests() { const opts = { destroyOnError: false, destroyOnReturn: true }; try { // eslint-disable-next-line no-unused-vars - for await (const chunk of readable.iterator(opts)) { } + for await (const chunk of readable.iterator(opts)); assert.fail('should have thrown'); } catch (err) { assert.strictEqual(err.message, 'inner'); @@ -827,8 +824,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 9ba3f9cd3653d6..33371d61d5799c 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-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);