diff --git a/test/.eslintrc.yaml b/test/.eslintrc.yaml index e727eb1ba5a2d6..497db45fcd550d 100644 --- a/test/.eslintrc.yaml +++ b/test/.eslintrc.yaml @@ -47,7 +47,7 @@ rules: message: Use Number.isNaN() instead of the global isNaN() function. - selector: VariableDeclarator > CallExpression:matches([callee.name='debuglog'], [callee.property.name='debuglog']):not([arguments.0.value='test']) message: Use 'test' as debuglog value in tests. - - selector: CallExpression:matches([callee.object.name="common"][callee.property.name=/^mustCall/],[callee.name="mustCall"],[callee.name="mustCallAtLeast"])>:first-child[type=/FunctionExpression$/][body.body.length=0] + - selector: CallExpression:matches([callee.object.name="common"][callee.property.name=/^must(Not)?Call/],[callee.name="mustCall"],[callee.name="mustCallAtLeast"],[callee.name="mustNotCall"])>:first-child[type=/FunctionExpression$/][body.body.length=0] message: Do not use an empty function, omit the parameter altogether. # Custom rules in tools/eslint-rules diff --git a/test/parallel/test-child-process-execfile.js b/test/parallel/test-child-process-execfile.js index f51c1729c9ac79..e6e04ff61f93b8 100644 --- a/test/parallel/test-child-process-execfile.js +++ b/test/parallel/test-child-process-execfile.js @@ -84,7 +84,7 @@ const execOpts = { encoding: 'utf8', shell: true }; // Verify that if something different than Abortcontroller.signal // is passed, ERR_INVALID_ARG_TYPE is thrown assert.throws(() => { - const callback = common.mustNotCall(() => {}); + const callback = common.mustNotCall(); execFile(process.execPath, [echoFixture, 0], { signal: 'hello' }, callback); }, { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' }); diff --git a/test/parallel/test-fs-promises-readfile.js b/test/parallel/test-fs-promises-readfile.js index fd1bfabf88dd9f..8043223e591a2d 100644 --- a/test/parallel/test-fs-promises-readfile.js +++ b/test/parallel/test-fs-promises-readfile.js @@ -64,7 +64,7 @@ async function validateWrongSignalParam() { // is passed, ERR_INVALID_ARG_TYPE is thrown await assert.rejects(async () => { - const callback = common.mustNotCall(() => {}); + const callback = common.mustNotCall(); await readFile(fn, { signal: 'hello' }, callback); }, { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' }); diff --git a/test/parallel/test-fs-readfile.js b/test/parallel/test-fs-readfile.js index 1a7ddf45bebf64..999c22165278af 100644 --- a/test/parallel/test-fs-readfile.js +++ b/test/parallel/test-fs-readfile.js @@ -95,7 +95,7 @@ for (const e of fileInfo) { // Verify that if something different than Abortcontroller.signal // is passed, ERR_INVALID_ARG_TYPE is thrown assert.throws(() => { - const callback = common.mustNotCall(() => {}); + const callback = common.mustNotCall(); fs.readFile(fileInfo[0].name, { signal: 'hello' }, callback); }, { code: 'ERR_INVALID_ARG_TYPE', name: 'TypeError' }); } diff --git a/test/parallel/test-http2-client-http1-server.js b/test/parallel/test-http2-client-http1-server.js index e6680ee14bdf50..4a7c7c0a7d59cd 100644 --- a/test/parallel/test-http2-client-http1-server.js +++ b/test/parallel/test-http2-client-http1-server.js @@ -11,7 +11,7 @@ const http2 = require('http2'); const { NghttpError } = require('internal/http2/util'); // Creating an http1 server here... -const server = http.createServer(common.mustNotCall(() => {})) +const server = http.createServer(common.mustNotCall()) .on('clientError', common.mustCall((error, socket) => { assert.strictEqual(error.code, 'HPE_PAUSED_H2_UPGRADE'); assert.strictEqual(error.bytesParsed, 24); diff --git a/test/parallel/test-https-agent-session-injection.js b/test/parallel/test-https-agent-session-injection.js index cb9358b1b17009..986953a59fe6d6 100644 --- a/test/parallel/test-https-agent-session-injection.js +++ b/test/parallel/test-https-agent-session-injection.js @@ -32,7 +32,7 @@ const server = https.createServer(options, function(req, res) { path: '/', ca, servername: 'nodejs.org', - }, common.mustNotCall(() => {})); + }, common.mustNotCall()); req.on('error', common.mustCall((err) => { assert.strictEqual( @@ -45,7 +45,7 @@ const server = https.createServer(options, function(req, res) { path: '/', ca, servername: 'nodejs.org', - }, common.mustNotCall(() => {})); + }, common.mustNotCall()); second.on('error', common.mustCall((err) => { server.close(); diff --git a/test/parallel/test-readline-interface.js b/test/parallel/test-readline-interface.js index b5a3b0499fcdbd..c624185696e111 100644 --- a/test/parallel/test-readline-interface.js +++ b/test/parallel/test-readline-interface.js @@ -1054,8 +1054,7 @@ for (let i = 0; i < 12; i++) { rli.question('foo?', common.mustCall((answer) => { assert.strictEqual(answer, 'baz'); })); - rli.question('bar?', common.mustNotCall(() => { - })); + rli.question('bar?', common.mustNotCall()); rli.write('baz\n'); rli.close(); } diff --git a/test/parallel/test-stream-filter.js b/test/parallel/test-stream-filter.js index e434eb8c84ef9b..173e4f47e24353 100644 --- a/test/parallel/test-stream-filter.js +++ b/test/parallel/test-stream-filter.js @@ -169,7 +169,7 @@ const { setTimeout } = require('timers/promises'); { const stream = Readable.from([1, 2, 3, 4, 5]); Object.defineProperty(stream, 'map', { - value: common.mustNotCall(() => {}), + value: common.mustNotCall(), }); // Check that map isn't getting called. stream.filter(() => true); diff --git a/test/parallel/test-stream-flatMap.js b/test/parallel/test-stream-flatMap.js index 07c534a9c1f481..0e55119f7a767d 100644 --- a/test/parallel/test-stream-flatMap.js +++ b/test/parallel/test-stream-flatMap.js @@ -124,7 +124,7 @@ function oneTo5() { { const stream = oneTo5(); Object.defineProperty(stream, 'map', { - value: common.mustNotCall(() => {}), + value: common.mustNotCall(), }); // Check that map isn't getting called. stream.flatMap(() => true); diff --git a/test/parallel/test-stream-forEach.js b/test/parallel/test-stream-forEach.js index e3678352c41591..7a21e299534742 100644 --- a/test/parallel/test-stream-forEach.js +++ b/test/parallel/test-stream-forEach.js @@ -132,7 +132,7 @@ const { once } = require('events'); { const stream = Readable.from([1, 2, 3, 4, 5]); Object.defineProperty(stream, 'map', { - value: common.mustNotCall(() => {}), + value: common.mustNotCall(), }); // Check that map isn't getting called. stream.forEach(() => true); diff --git a/test/parallel/test-stream-readable-destroy.js b/test/parallel/test-stream-readable-destroy.js index fc82f44bc9d7eb..a62beb27961816 100644 --- a/test/parallel/test-stream-readable-destroy.js +++ b/test/parallel/test-stream-readable-destroy.js @@ -249,7 +249,7 @@ const assert = require('assert'); { const read = new Readable({ - read: common.mustNotCall(function() {}) + read: common.mustNotCall() }); read.destroy(); assert.strictEqual(read.destroyed, true); diff --git a/test/parallel/test-stream-readable-next-no-null.js b/test/parallel/test-stream-readable-next-no-null.js index 64ca40be11ed03..7599e386ca706e 100644 --- a/test/parallel/test-stream-readable-next-no-null.js +++ b/test/parallel/test-stream-readable-next-no-null.js @@ -14,6 +14,6 @@ stream.on('error', expectsError({ message: 'May not write null values to stream' })); -stream.on('data', mustNotCall((chunk) => {})); +stream.on('data', mustNotCall()); stream.on('end', mustNotCall()); diff --git a/test/parallel/test-stream-some-find-every.mjs b/test/parallel/test-stream-some-find-every.mjs index c4637d41deb181..0617102bc471e3 100644 --- a/test/parallel/test-stream-some-find-every.mjs +++ b/test/parallel/test-stream-some-find-every.mjs @@ -164,7 +164,7 @@ function oneTo5Async() { for (const op of ['some', 'every', 'find']) { const stream = oneTo5(); Object.defineProperty(stream, 'map', { - value: common.mustNotCall(() => {}), + value: common.mustNotCall(), }); // Check that map isn't getting called. stream[op](() => {}); diff --git a/test/parallel/test-worker-data-url.js b/test/parallel/test-worker-data-url.js index f224ebcf447c7b..6649565a0c1103 100644 --- a/test/parallel/test-worker-data-url.js +++ b/test/parallel/test-worker-data-url.js @@ -5,9 +5,9 @@ const { Worker } = require('worker_threads'); const assert = require('assert'); new Worker(new URL('data:text/javascript,')) - .on('error', common.mustNotCall(() => {})); + .on('error', common.mustNotCall()); new Worker(new URL('data:text/javascript,export{}')) - .on('error', common.mustNotCall(() => {})); + .on('error', common.mustNotCall()); new Worker(new URL('data:text/plain,')) .on('error', common.mustCall()); @@ -15,7 +15,7 @@ new Worker(new URL('data:text/javascript,module.exports={}')) .on('error', common.mustCall()); new Worker(new URL('data:text/javascript,await Promise.resolve()')) - .on('error', common.mustNotCall(() => {})); + .on('error', common.mustNotCall()); new Worker(new URL('data:text/javascript,await Promise.reject()')) .on('error', common.mustCall()); new Worker(new URL('data:text/javascript,await new Promise(()=>{})'))