From e879a56aeca5bd5a6791c14fc7a2c1b416b5ba5c Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 3 May 2017 21:07:54 -0700 Subject: [PATCH] test: remove common.noop This change removes `common.noop` from the Node.js internal testing common module. Over the last few weeks, I've grown to dislike the `common.noop` abstraction. First, new (and experienced) contributors are unaware of it and so it results in a large number of low-value nits on PRs. It also increases the number of things newcomers and infrequent contributors have to be aware of to be effective on the project. Second, it is confusing. Is it a singleton/property or a getter? Which should be expected? This can lead to subtle and hard-to-find bugs. (To my knowledge, none have landed on master. But I also think it's only a matter of time.) Third, the abstraction is low-value in my opinion. What does it really get us? A case could me made that it is without value at all. Lastly, and this is minor, but the abstraction is wordier than not using the abstraction. `common.noop` doesn't save anything over `() => {}`. So, I propose removing it. PR-URL: https://github.com/nodejs/node/pull/12822 Backport-PR-URL: https://github.com/nodejs/node/pull/14174 Reviewed-By: Anna Henningsen Reviewed-By: Refael Ackermann --- test/common/README.md | 21 ++++--------------- test/common/index.js | 1 - .../unhandled_promise_trace_warnings.js | 4 ++-- test/parallel/test-assert.js | 9 ++++---- test/parallel/test-buffer-includes.js | 4 ++-- test/parallel/test-child-process-bad-stdio.js | 2 +- ...est-child-process-spawnsync-kill-signal.js | 2 +- .../parallel/test-cluster-rr-domain-listen.js | 6 +++--- .../test-cluster-worker-wait-server-close.js | 4 ++-- test/parallel/test-common.js | 2 +- test/parallel/test-console-instance.js | 2 +- .../test-event-emitter-get-max-listeners.js | 6 +++--- .../test-event-emitter-listener-count.js | 10 ++++----- ...-emitter-max-listeners-warning-for-null.js | 4 ++-- ...mitter-max-listeners-warning-for-symbol.js | 4 ++-- ...est-event-emitter-max-listeners-warning.js | 6 +++--- .../test-event-emitter-remove-listeners.js | 4 ++-- .../test-event-emitter-special-event-names.js | 2 +- test/parallel/test-event-emitter-subclass.js | 2 +- test/parallel/test-events-list.js | 1 - test/parallel/test-fs-buffertype-writesync.js | 2 +- test/parallel/test-fs-mkdir.js | 2 +- test/parallel/test-handle-wrap-isrefed.js | 4 ++-- test/parallel/test-http-client-defaults.js | 8 +++---- test/parallel/test-http-parser-bad-ref.js | 4 ++-- test/parallel/test-http-upgrade-server.js | 4 ++-- test/parallel/test-https-close.js | 2 +- test/parallel/test-https-socket-options.js | 4 ++-- test/parallel/test-instanceof.js | 4 ++-- .../test-net-listen-exclusive-random-ports.js | 4 ++-- test/parallel/test-net-options-lookup.js | 4 ++-- test/parallel/test-net-socket-timeout.js | 8 +++---- test/parallel/test-net-stream.js | 4 ++-- test/parallel/test-no-enter-tickcallback.js | 2 +- .../test-process-getactiverequests.js | 4 ++-- ...promises-warning-on-unhandled-rejection.js | 2 +- test/parallel/test-readline-interface.js | 8 +++---- test/parallel/test-readline-keys.js | 2 +- test/parallel/test-regress-GH-4948.js | 6 +++--- test/parallel/test-regress-GH-5051.js | 4 ++-- ...test-repl-function-definition-edge-case.js | 2 +- test/parallel/test-repl-history-perm.js | 2 +- test/parallel/test-repl-mode.js | 2 +- test/parallel/test-repl-save-load.js | 6 +++--- test/parallel/test-repl-tab-complete-crash.js | 2 +- .../test-stream-decoder-objectmode.js | 4 ++-- test/parallel/test-stream-duplex.js | 4 ++-- test/parallel/test-stream-pipe-await-drain.js | 2 +- .../test-stream-pipe-cleanup-pause.js | 2 +- .../test-stream-pipe-error-handling.js | 4 ++-- .../test-stream-pipe-multiple-pipes.js | 2 +- .../test-stream-pipe-unpipe-streams.js | 6 +++--- .../test-stream-readable-emittedReadable.js | 6 +++--- .../test-stream-readable-invalid-chunk.js | 4 ++-- .../test-stream-readable-needReadable.js | 8 +++---- .../test-stream-readableListening-state.js | 4 ++-- .../test-stream2-pipe-error-once-listener.js | 4 ++-- .../test-stream2-readable-wrap-empty.js | 6 +++--- test/parallel/test-timers-unref-call.js | 4 ++-- ...-timers-unref-remove-other-unref-timers.js | 2 +- test/parallel/test-timers-unref.js | 8 +++---- .../test-timers-unrefed-in-beforeexit.js | 4 ++-- test/parallel/test-timers-zero-timeout.js | 2 +- test/parallel/test-util-inspect.js | 8 +++---- .../test-vm-sigint-existing-handler.js | 2 +- test/parallel/test-whatwg-url-parsing.js | 2 +- test/pseudo-tty/ref_keeps_node_running.js | 4 ++-- 67 files changed, 135 insertions(+), 149 deletions(-) diff --git a/test/common/README.md b/test/common/README.md index 78145b412fd6be..07f9bc6583d918 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -209,7 +209,7 @@ Gets IP of localhost Array of IPV6 hosts. ### mustCall([fn][, exact]) -* `fn` [<Function>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) default = `common.noop` +* `fn` [<Function>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) default = () => {} * `exact` [<Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) default = 1 * return [<Function>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) @@ -217,10 +217,10 @@ Returns a function that calls `fn`. If the returned function has not been called exactly `expected` number of times when the test is complete, then the test will fail. -If `fn` is not provided, `common.noop` will be used. +If `fn` is not provided, an empty function will be used. ### mustCallAtLeast([fn][, minimum]) -* `fn` [<Function>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) default = `common.noop` +* `fn` [<Function>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) default = () => {} * `minimum` [<Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) default = 1 * return [<Function>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) @@ -228,7 +228,7 @@ Returns a function that calls `fn`. If the returned function has not been called at least `minimum` number of times when the test is complete, then the test will fail. -If `fn` is not provided, `common.noop` will be used. +If `fn` is not provided, an empty function will be used. ### mustNotCall([msg]) * `msg` [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) default = 'function should not have been called' @@ -243,19 +243,6 @@ Returns a function that triggers an `AssertionError` if it is invoked. `msg` is Returns `true` if the exit code `exitCode` and/or signal name `signal` represent the exit code and/or signal name of a node process that aborted, `false` otherwise. -### noop - -A non-op `Function` that can be used for a variety of scenarios. - -For instance, - - -```js -const common = require('../common'); - -someAsyncAPI('foo', common.mustCall(common.noop)); -``` - ### opensslCli * return [<Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type) diff --git a/test/common/index.js b/test/common/index.js index f92b535efc524f..3caed88e203158 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -37,7 +37,6 @@ const testRoot = process.env.NODE_TEST_DIR ? const noop = () => {}; -exports.noop = noop; exports.fixturesDir = path.join(__dirname, '..', 'fixtures'); exports.tmpDirName = 'tmp'; // PORT should match the definition in test/testpy/__init__.py. diff --git a/test/message/unhandled_promise_trace_warnings.js b/test/message/unhandled_promise_trace_warnings.js index 8aad957fb5cf49..48450fb21e2169 100644 --- a/test/message/unhandled_promise_trace_warnings.js +++ b/test/message/unhandled_promise_trace_warnings.js @@ -1,5 +1,5 @@ // Flags: --trace-warnings 'use strict'; -const common = require('../common'); +require('../common'); const p = Promise.reject(new Error('This was rejected')); -setImmediate(() => p.catch(common.noop)); +setImmediate(() => p.catch(() => {})); diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index 561ce6d79b4af3..e24997ec65d18c 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -571,29 +571,30 @@ a.throws(makeBlock(a.deepEqual, args, [])); // check messages from assert.throws() { + const noop = () => {}; assert.throws( - () => { a.throws(common.noop); }, + () => { a.throws((noop)); }, common.expectsError({ code: 'ERR_ASSERTION', message: /^Missing expected exception\.$/ })); assert.throws( - () => { a.throws(common.noop, TypeError); }, + () => { a.throws(noop, TypeError); }, common.expectsError({ code: 'ERR_ASSERTION', message: /^Missing expected exception \(TypeError\)\.$/ })); assert.throws( - () => { a.throws(common.noop, 'fhqwhgads'); }, + () => { a.throws(noop, 'fhqwhgads'); }, common.expectsError({ code: 'ERR_ASSERTION', message: /^Missing expected exception: fhqwhgads$/ })); assert.throws( - () => { a.throws(common.noop, TypeError, 'fhqwhgads'); }, + () => { a.throws(noop, TypeError, 'fhqwhgads'); }, common.expectsError({ code: 'ERR_ASSERTION', message: /^Missing expected exception \(TypeError\): fhqwhgads$/ diff --git a/test/parallel/test-buffer-includes.js b/test/parallel/test-buffer-includes.js index 9ce9578b3a1a5d..a114ad264e5fd7 100644 --- a/test/parallel/test-buffer-includes.js +++ b/test/parallel/test-buffer-includes.js @@ -1,5 +1,5 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const b = Buffer.from('abcdef'); @@ -274,7 +274,7 @@ for (let lengthIndex = 0; lengthIndex < lengths.length; lengthIndex++) { const expectedError = /^TypeError: "val" argument must be string, number, Buffer or Uint8Array$/; assert.throws(() => { - b.includes(common.noop); + b.includes(() => {}); }, expectedError); assert.throws(() => { b.includes({}); diff --git a/test/parallel/test-child-process-bad-stdio.js b/test/parallel/test-child-process-bad-stdio.js index 2e06f4e2b12176..45294d7d82d4f6 100644 --- a/test/parallel/test-child-process-bad-stdio.js +++ b/test/parallel/test-child-process-bad-stdio.js @@ -5,7 +5,7 @@ const assert = require('assert'); const cp = require('child_process'); if (process.argv[2] === 'child') { - setTimeout(common.noop, common.platformTimeout(100)); + setTimeout(() => {}, common.platformTimeout(100)); return; } diff --git a/test/parallel/test-child-process-spawnsync-kill-signal.js b/test/parallel/test-child-process-spawnsync-kill-signal.js index 1b8b267ff6b170..ff0b36150f15a2 100644 --- a/test/parallel/test-child-process-spawnsync-kill-signal.js +++ b/test/parallel/test-child-process-spawnsync-kill-signal.js @@ -4,7 +4,7 @@ const assert = require('assert'); const cp = require('child_process'); if (process.argv[2] === 'child') { - setInterval(common.noop, 1000); + setInterval(() => {}, 1000); } else { const { SIGKILL } = process.binding('constants').os.signals; diff --git a/test/parallel/test-cluster-rr-domain-listen.js b/test/parallel/test-cluster-rr-domain-listen.js index 4b511d0d204d9e..45e1200a3d65d1 100644 --- a/test/parallel/test-cluster-rr-domain-listen.js +++ b/test/parallel/test-cluster-rr-domain-listen.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -const common = require('../common'); +require('../common'); const cluster = require('cluster'); const domain = require('domain'); @@ -29,10 +29,10 @@ const domain = require('domain'); if (cluster.isWorker) { const d = domain.create(); - d.run(common.noop); + d.run(() => {}); const http = require('http'); - http.Server(common.noop).listen(0, '127.0.0.1'); + http.Server(() => {}).listen(0, '127.0.0.1'); } else if (cluster.isMaster) { diff --git a/test/parallel/test-cluster-worker-wait-server-close.js b/test/parallel/test-cluster-worker-wait-server-close.js index a563d52beb3592..b8183afb06ae18 100644 --- a/test/parallel/test-cluster-worker-wait-server-close.js +++ b/test/parallel/test-cluster-worker-wait-server-close.js @@ -11,7 +11,7 @@ if (cluster.isWorker) { const server = net.createServer(function(socket) { // Wait for any data, then close connection socket.write('.'); - socket.on('data', common.noop); + socket.on('data', () => {}); }).listen(0, common.localhostIPv4); server.once('close', function() { @@ -20,7 +20,7 @@ if (cluster.isWorker) { // Although not typical, the worker process can exit before the disconnect // event fires. Use this to keep the process open until the event has fired. - const keepOpen = setInterval(common.noop, 9999); + const keepOpen = setInterval(() => {}, 9999); // Check worker events and properties process.once('disconnect', function() { diff --git a/test/parallel/test-common.js b/test/parallel/test-common.js index 47ed7d9f3138da..819cd815538b43 100644 --- a/test/parallel/test-common.js +++ b/test/parallel/test-common.js @@ -101,7 +101,7 @@ const HIJACK_TEST_ARRAY = [ 'foo\n', 'bar\n', 'baz\n' ]; assert.notStrictEqual(originalWrite, stream.write); HIJACK_TEST_ARRAY.forEach((val) => { - stream.write(val, common.mustCall(common.noop)); + stream.write(val, common.mustCall()); }); assert.strictEqual(HIJACK_TEST_ARRAY.length, stream.writeTimes); diff --git a/test/parallel/test-console-instance.js b/test/parallel/test-console-instance.js index dee0cae5430c22..7d56def3747213 100644 --- a/test/parallel/test-console-instance.js +++ b/test/parallel/test-console-instance.js @@ -43,7 +43,7 @@ assert.throws(() => { // Console constructor should throw if stderr exists but is not writable assert.throws(() => { - out.write = common.noop; + out.write = () => {}; err.write = undefined; new Console(out, err); }, /^TypeError: Console expects writable stream instances$/); diff --git a/test/parallel/test-event-emitter-get-max-listeners.js b/test/parallel/test-event-emitter-get-max-listeners.js index 98ac02e87130b5..43f9f0cebc4be3 100644 --- a/test/parallel/test-event-emitter-get-max-listeners.js +++ b/test/parallel/test-event-emitter-get-max-listeners.js @@ -1,5 +1,5 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const EventEmitter = require('events'); @@ -15,5 +15,5 @@ assert.strictEqual(emitter.getMaxListeners(), 3); // https://github.com/nodejs/node/issues/523 - second call should not throw. const recv = {}; -EventEmitter.prototype.on.call(recv, 'event', common.noop); -EventEmitter.prototype.on.call(recv, 'event', common.noop); +EventEmitter.prototype.on.call(recv, 'event', () => {}); +EventEmitter.prototype.on.call(recv, 'event', () => {}); diff --git a/test/parallel/test-event-emitter-listener-count.js b/test/parallel/test-event-emitter-listener-count.js index 50247f42770ba8..117d38f575da6b 100644 --- a/test/parallel/test-event-emitter-listener-count.js +++ b/test/parallel/test-event-emitter-listener-count.js @@ -1,15 +1,15 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const EventEmitter = require('events'); const emitter = new EventEmitter(); -emitter.on('foo', common.noop); -emitter.on('foo', common.noop); -emitter.on('baz', common.noop); +emitter.on('foo', () => {}); +emitter.on('foo', () => {}); +emitter.on('baz', () => {}); // Allow any type -emitter.on(123, common.noop); +emitter.on(123, () => {}); assert.strictEqual(EventEmitter.listenerCount(emitter, 'foo'), 2); assert.strictEqual(emitter.listenerCount('foo'), 2); diff --git a/test/parallel/test-event-emitter-max-listeners-warning-for-null.js b/test/parallel/test-event-emitter-max-listeners-warning-for-null.js index c8a904b9bb6173..2929e1c709328f 100644 --- a/test/parallel/test-event-emitter-max-listeners-warning-for-null.js +++ b/test/parallel/test-event-emitter-max-listeners-warning-for-null.js @@ -18,5 +18,5 @@ process.on('warning', common.mustCall((warning) => { assert.ok(warning.message.includes('2 null listeners added.')); })); -e.on(null, common.noop); -e.on(null, common.noop); +e.on(null, () => {}); +e.on(null, () => {}); diff --git a/test/parallel/test-event-emitter-max-listeners-warning-for-symbol.js b/test/parallel/test-event-emitter-max-listeners-warning-for-symbol.js index 551c1276b85bfd..51c31ba0cf2f31 100644 --- a/test/parallel/test-event-emitter-max-listeners-warning-for-symbol.js +++ b/test/parallel/test-event-emitter-max-listeners-warning-for-symbol.js @@ -20,5 +20,5 @@ process.on('warning', common.mustCall((warning) => { assert.ok(warning.message.includes('2 Symbol(symbol) listeners added.')); })); -e.on(symbol, common.noop); -e.on(symbol, common.noop); +e.on(symbol, () => {}); +e.on(symbol, () => {}); diff --git a/test/parallel/test-event-emitter-max-listeners-warning.js b/test/parallel/test-event-emitter-max-listeners-warning.js index 1a4a1b8bf2af03..0be7fc84bce17b 100644 --- a/test/parallel/test-event-emitter-max-listeners-warning.js +++ b/test/parallel/test-event-emitter-max-listeners-warning.js @@ -18,6 +18,6 @@ process.on('warning', common.mustCall((warning) => { assert.ok(warning.message.includes('2 event-type listeners added.')); })); -e.on('event-type', common.noop); -e.on('event-type', common.noop); // Trigger warning. -e.on('event-type', common.noop); // Verify that warning is emitted only once. +e.on('event-type', () => {}); +e.on('event-type', () => {}); // Trigger warning. +e.on('event-type', () => {}); // Verify that warning is emitted only once. diff --git a/test/parallel/test-event-emitter-remove-listeners.js b/test/parallel/test-event-emitter-remove-listeners.js index 01ed0141354117..d1c01e0bc3cfae 100644 --- a/test/parallel/test-event-emitter-remove-listeners.js +++ b/test/parallel/test-event-emitter-remove-listeners.js @@ -140,7 +140,7 @@ function listener2() {} { const ee = new EventEmitter(); - assert.deepStrictEqual(ee, ee.removeListener('foo', common.noop)); + assert.deepStrictEqual(ee, ee.removeListener('foo', () => {})); } // Verify that the removed listener must be a function @@ -152,7 +152,7 @@ assert.throws(() => { { const ee = new EventEmitter(); - const listener = common.noop; + const listener = () => {}; ee._events = undefined; const e = ee.removeListener('foo', listener); assert.strictEqual(e, ee); diff --git a/test/parallel/test-event-emitter-special-event-names.js b/test/parallel/test-event-emitter-special-event-names.js index 116cdfcc16a8c9..7ff781f0f90c5a 100644 --- a/test/parallel/test-event-emitter-special-event-names.js +++ b/test/parallel/test-event-emitter-special-event-names.js @@ -5,7 +5,7 @@ const EventEmitter = require('events'); const assert = require('assert'); const ee = new EventEmitter(); -const handler = common.noop; +const handler = () => {}; assert.deepStrictEqual(ee.eventNames(), []); diff --git a/test/parallel/test-event-emitter-subclass.js b/test/parallel/test-event-emitter-subclass.js index 00ebd1e3567873..5189c3aa13422f 100644 --- a/test/parallel/test-event-emitter-subclass.js +++ b/test/parallel/test-event-emitter-subclass.js @@ -62,6 +62,6 @@ MyEE2.prototype = new EventEmitter(); const ee1 = new MyEE2(); const ee2 = new MyEE2(); -ee1.on('x', common.noop); +ee1.on('x', () => {}); assert.strictEqual(ee2.listenerCount('x'), 0); diff --git a/test/parallel/test-events-list.js b/test/parallel/test-events-list.js index 5d2e8c019a196a..4e589b07f2d60c 100644 --- a/test/parallel/test-events-list.js +++ b/test/parallel/test-events-list.js @@ -5,7 +5,6 @@ const EventEmitter = require('events'); const assert = require('assert'); const EE = new EventEmitter(); -// Do not use common.noop here, these need to be separate listener functions const m = () => {}; EE.on('foo', () => {}); assert.deepStrictEqual(['foo'], EE.eventNames()); diff --git a/test/parallel/test-fs-buffertype-writesync.js b/test/parallel/test-fs-buffertype-writesync.js index 02d2cb58f83112..73a6f211893aaf 100644 --- a/test/parallel/test-fs-buffertype-writesync.js +++ b/test/parallel/test-fs-buffertype-writesync.js @@ -9,7 +9,7 @@ const fs = require('fs'); const path = require('path'); const filePath = path.join(common.tmpDir, 'test_buffer_type'); -const v = [true, false, 0, 1, Infinity, common.noop, {}, [], undefined, null]; +const v = [true, false, 0, 1, Infinity, () => {}, {}, [], undefined, null]; common.refreshTmpDir(); diff --git a/test/parallel/test-fs-mkdir.js b/test/parallel/test-fs-mkdir.js index 17a945c97533e4..679e0b255ace92 100644 --- a/test/parallel/test-fs-mkdir.js +++ b/test/parallel/test-fs-mkdir.js @@ -77,4 +77,4 @@ common.refreshTmpDir(); // Keep the event loop alive so the async mkdir() requests // have a chance to run (since they don't ref the event loop). -process.nextTick(common.noop); +process.nextTick(() => {}); diff --git a/test/parallel/test-handle-wrap-isrefed.js b/test/parallel/test-handle-wrap-isrefed.js index c027b6f2d1a9a1..66353fcc0362b3 100644 --- a/test/parallel/test-handle-wrap-isrefed.js +++ b/test/parallel/test-handle-wrap-isrefed.js @@ -87,7 +87,7 @@ const strictEqual = require('assert').strictEqual; // tcp { const net = require('net'); - const server = net.createServer(common.noop).listen(0); + const server = net.createServer(() => {}).listen(0); strictEqual(Object.getPrototypeOf(server._handle).hasOwnProperty('hasRef'), true, 'tcp_wrap: hasRef() missing'); strictEqual(server._handle.hasRef(), @@ -112,7 +112,7 @@ const strictEqual = require('assert').strictEqual; // timers { - const timer = setTimeout(common.noop, 500); + const timer = setTimeout(() => {}, 500); timer.unref(); strictEqual(Object.getPrototypeOf(timer._handle).hasOwnProperty('hasRef'), true, 'timer_wrap: hasRef() missing'); diff --git a/test/parallel/test-http-client-defaults.js b/test/parallel/test-http-client-defaults.js index 57ac0e99d65c5a..43419d1dfd6cff 100644 --- a/test/parallel/test-http-client-defaults.js +++ b/test/parallel/test-http-client-defaults.js @@ -1,23 +1,23 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const ClientRequest = require('http').ClientRequest; { - const req = new ClientRequest({ createConnection: common.noop }); + const req = new ClientRequest({ createConnection: () => {} }); assert.strictEqual(req.path, '/'); assert.strictEqual(req.method, 'GET'); } { - const req = new ClientRequest({ method: '', createConnection: common.noop }); + const req = new ClientRequest({ method: '', createConnection: () => {} }); assert.strictEqual(req.path, '/'); assert.strictEqual(req.method, 'GET'); } { - const req = new ClientRequest({ path: '', createConnection: common.noop }); + const req = new ClientRequest({ path: '', createConnection: () => {} }); assert.strictEqual(req.path, '/'); assert.strictEqual(req.method, 'GET'); } diff --git a/test/parallel/test-http-parser-bad-ref.js b/test/parallel/test-http-parser-bad-ref.js index 70c6a1e515cc3d..6e9fb2f9ac6033 100644 --- a/test/parallel/test-http-parser-bad-ref.js +++ b/test/parallel/test-http-parser-bad-ref.js @@ -4,7 +4,7 @@ // Flags: --expose_gc -const common = require('../common'); +require('../common'); const assert = require('assert'); const HTTPParser = process.binding('http_parser').HTTPParser; @@ -39,7 +39,7 @@ function demoBug(part1, part2) { console.log('url', info.url); }; - parser[kOnBody] = common.noop; + parser[kOnBody] = () => {}; parser[kOnMessageComplete] = function() { messagesComplete++; diff --git a/test/parallel/test-http-upgrade-server.js b/test/parallel/test-http-upgrade-server.js index 11c0aba5b4dc0e..3b91afc03fbf7f 100644 --- a/test/parallel/test-http-upgrade-server.js +++ b/test/parallel/test-http-upgrade-server.js @@ -21,7 +21,7 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const util = require('util'); @@ -38,7 +38,7 @@ function createTestServer() { } function testServer() { - http.Server.call(this, common.noop); + http.Server.call(this, () => {}); this.on('connection', function() { requests_recv++; diff --git a/test/parallel/test-https-close.js b/test/parallel/test-https-close.js index 6b22192e99a5b7..1590f3cb5b38cf 100644 --- a/test/parallel/test-https-close.js +++ b/test/parallel/test-https-close.js @@ -47,7 +47,7 @@ server.listen(0, function() { }; const req = https.request(requestOptions, function(res) { - res.on('data', common.noop); + res.on('data', () => {}); setImmediate(shutdown); }); req.end(); diff --git a/test/parallel/test-https-socket-options.js b/test/parallel/test-https-socket-options.js index 75c5f51bb0c80a..2a6fc8f84f78af 100644 --- a/test/parallel/test-https-socket-options.js +++ b/test/parallel/test-https-socket-options.js @@ -55,7 +55,7 @@ server_http.listen(0, function() { }); // These methods should exist on the request and get passed down to the socket req.setNoDelay(true); - req.setTimeout(1000, common.noop); + req.setTimeout(1000, () => {}); req.setSocketKeepAlive(true, 1000); req.end(); }); @@ -79,7 +79,7 @@ server_https.listen(0, function() { }); // These methods should exist on the request and get passed down to the socket req.setNoDelay(true); - req.setTimeout(1000, common.noop); + req.setTimeout(1000, () => {}); req.setSocketKeepAlive(true, 1000); req.end(); }); diff --git a/test/parallel/test-instanceof.js b/test/parallel/test-instanceof.js index c3d4ece42ab264..658f1e29c7a60f 100644 --- a/test/parallel/test-instanceof.js +++ b/test/parallel/test-instanceof.js @@ -1,11 +1,11 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); // Regression test for instanceof, see // https://github.com/nodejs/node/issues/7592 -const F = common.noop; +const F = () => {}; F.prototype = {}; assert(Object.create(F.prototype) instanceof F); diff --git a/test/parallel/test-net-listen-exclusive-random-ports.js b/test/parallel/test-net-listen-exclusive-random-ports.js index 9ca023cfa4088d..00d5e73cb17675 100644 --- a/test/parallel/test-net-listen-exclusive-random-ports.js +++ b/test/parallel/test-net-listen-exclusive-random-ports.js @@ -1,6 +1,6 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const cluster = require('cluster'); const net = require('net'); @@ -20,7 +20,7 @@ if (cluster.isMaster) { }); }); } else { - const server = net.createServer(common.noop); + const server = net.createServer(() => {}); server.on('error', function(err) { process.send(err.code); diff --git a/test/parallel/test-net-options-lookup.js b/test/parallel/test-net-options-lookup.js index c61f338b701591..f0e8b34c807df0 100644 --- a/test/parallel/test-net-options-lookup.js +++ b/test/parallel/test-net-options-lookup.js @@ -1,5 +1,5 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const net = require('net'); @@ -20,7 +20,7 @@ function connectThrows(input) { }, expectedError); } -connectDoesNotThrow(common.noop); +connectDoesNotThrow(() => {}); function connectDoesNotThrow(input) { const opts = { diff --git a/test/parallel/test-net-socket-timeout.js b/test/parallel/test-net-socket-timeout.js index 0319e181739f8c..de4a7ed37ccf20 100644 --- a/test/parallel/test-net-socket-timeout.js +++ b/test/parallel/test-net-socket-timeout.js @@ -27,7 +27,7 @@ const assert = require('assert'); // Verify that invalid delays throw const s = new net.Socket(); const nonNumericDelays = [ - '100', true, false, undefined, null, '', {}, common.noop, [] + '100', true, false, undefined, null, '', {}, () => {}, [] ]; const badRangeDelays = [-0.001, -1, -Infinity, Infinity, NaN]; const validDelays = [0, 0.001, 1, 1e6]; @@ -35,19 +35,19 @@ const validDelays = [0, 0.001, 1, 1e6]; for (let i = 0; i < nonNumericDelays.length; i++) { assert.throws(function() { - s.setTimeout(nonNumericDelays[i], common.noop); + s.setTimeout(nonNumericDelays[i], () => {}); }, TypeError); } for (let i = 0; i < badRangeDelays.length; i++) { assert.throws(function() { - s.setTimeout(badRangeDelays[i], common.noop); + s.setTimeout(badRangeDelays[i], () => {}); }, RangeError); } for (let i = 0; i < validDelays.length; i++) { assert.doesNotThrow(function() { - s.setTimeout(validDelays[i], common.noop); + s.setTimeout(validDelays[i], () => {}); }); } diff --git a/test/parallel/test-net-stream.js b/test/parallel/test-net-stream.js index 1eb984936c0199..4690cf7c905ecb 100644 --- a/test/parallel/test-net-stream.js +++ b/test/parallel/test-net-stream.js @@ -21,7 +21,7 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const net = require('net'); @@ -54,7 +54,7 @@ const server = net.createServer(function(socket) { }); for (let i = 0; i < N; ++i) { - socket.write(buf, common.noop); + socket.write(buf, () => {}); } socket.end(); diff --git a/test/parallel/test-no-enter-tickcallback.js b/test/parallel/test-no-enter-tickcallback.js index 34c7eb8e08e8d8..aab22c5f3edc72 100644 --- a/test/parallel/test-no-enter-tickcallback.js +++ b/test/parallel/test-no-enter-tickcallback.js @@ -27,6 +27,6 @@ setImmediate(common.mustCall(() => { require('domain'); setImmediate(common.mustCall(() => setImmediate(common.mustCall(() => { allsGood = true; - process.nextTick(common.noop); + process.nextTick(() => {}); })))); })); diff --git a/test/parallel/test-process-getactiverequests.js b/test/parallel/test-process-getactiverequests.js index 2885eb861373e5..f55f298298d446 100644 --- a/test/parallel/test-process-getactiverequests.js +++ b/test/parallel/test-process-getactiverequests.js @@ -1,10 +1,10 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const fs = require('fs'); for (let i = 0; i < 12; i++) - fs.open(__filename, 'r', common.noop); + fs.open(__filename, 'r', () => {}); assert.strictEqual(12, process._getActiveRequests().length); diff --git a/test/parallel/test-promises-warning-on-unhandled-rejection.js b/test/parallel/test-promises-warning-on-unhandled-rejection.js index f3c7a8771e9f55..10f95162a09597 100644 --- a/test/parallel/test-promises-warning-on-unhandled-rejection.js +++ b/test/parallel/test-promises-warning-on-unhandled-rejection.js @@ -26,4 +26,4 @@ process.on('warning', common.mustCall((warning) => { }, 3)); const p = Promise.reject('This was rejected'); -setImmediate(common.mustCall(() => p.catch(common.noop))); +setImmediate(common.mustCall(() => p.catch(() => {}))); diff --git a/test/parallel/test-readline-interface.js b/test/parallel/test-readline-interface.js index 6f8849a322618a..5628107069a442 100644 --- a/test/parallel/test-readline-interface.js +++ b/test/parallel/test-readline-interface.js @@ -34,10 +34,10 @@ function FakeInput() { EventEmitter.call(this); } inherits(FakeInput, EventEmitter); -FakeInput.prototype.resume = common.noop; -FakeInput.prototype.pause = common.noop; -FakeInput.prototype.write = common.noop; -FakeInput.prototype.end = common.noop; +FakeInput.prototype.resume = () => {}; +FakeInput.prototype.pause = () => {}; +FakeInput.prototype.write = () => {}; +FakeInput.prototype.end = () => {}; function isWarned(emitter) { for (const name in emitter) { diff --git a/test/parallel/test-readline-keys.js b/test/parallel/test-readline-keys.js index 6b46874f72ba7f..1b05b06f58f04f 100644 --- a/test/parallel/test-readline-keys.js +++ b/test/parallel/test-readline-keys.js @@ -298,7 +298,7 @@ const runKeyIntervalTests = [ { name: 'escape', sequence: '\x1b', meta: true }, { name: 'escape', sequence: '\x1b', meta: true } ]) -].reverse().reduce((acc, fn) => fn(acc), common.noop); +].reverse().reduce((acc, fn) => fn(acc), () => {}); // run key interval tests one after another runKeyIntervalTests(); diff --git a/test/parallel/test-regress-GH-4948.js b/test/parallel/test-regress-GH-4948.js index bdf60e2e539a79..5ec79b8685b409 100644 --- a/test/parallel/test-regress-GH-4948.js +++ b/test/parallel/test-regress-GH-4948.js @@ -1,7 +1,7 @@ 'use strict'; // https://github.com/joyent/node/issues/4948 -const common = require('../common'); +require('../common'); const http = require('http'); let reqCount = 0; @@ -22,10 +22,10 @@ const server = http.createServer(function(serverReq, serverRes) { serverRes.end(); // required for test to fail - res.on('data', common.noop); + res.on('data', () => {}); }); - r.on('error', common.noop); + r.on('error', () => {}); r.end(); serverRes.write('some data'); diff --git a/test/parallel/test-regress-GH-5051.js b/test/parallel/test-regress-GH-5051.js index f0a2d7aa7f1825..0fef879c6f15d5 100644 --- a/test/parallel/test-regress-GH-5051.js +++ b/test/parallel/test-regress-GH-5051.js @@ -1,11 +1,11 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const agent = require('http').globalAgent; // small stub just so we can call addRequest directly const req = { - getHeader: common.noop + getHeader: () => {} }; agent.maxSockets = 0; diff --git a/test/parallel/test-repl-function-definition-edge-case.js b/test/parallel/test-repl-function-definition-edge-case.js index 90234eb1313b30..1e3063e3db53ff 100644 --- a/test/parallel/test-repl-function-definition-edge-case.js +++ b/test/parallel/test-repl-function-definition-edge-case.js @@ -19,7 +19,7 @@ assert.strictEqual(got, expected); function initRepl() { const input = new stream(); - input.write = input.pause = input.resume = common.noop; + input.write = input.pause = input.resume = () => {}; input.readable = true; const output = new stream(); diff --git a/test/parallel/test-repl-history-perm.js b/test/parallel/test-repl-history-perm.js index 3b58986dc08efc..259c96fe8aa0f7 100644 --- a/test/parallel/test-repl-history-perm.js +++ b/test/parallel/test-repl-history-perm.js @@ -18,7 +18,7 @@ const Duplex = require('stream').Duplex; // and mode 600. const stream = new Duplex(); -stream.pause = stream.resume = common.noop; +stream.pause = stream.resume = () => {}; // ends immediately stream._read = function() { this.push(null); diff --git a/test/parallel/test-repl-mode.js b/test/parallel/test-repl-mode.js index cf492a7e4b3f93..5606200859ee2c 100644 --- a/test/parallel/test-repl-mode.js +++ b/test/parallel/test-repl-mode.js @@ -52,7 +52,7 @@ function testAutoMode() { function initRepl(mode) { const input = new Stream(); - input.write = input.pause = input.resume = common.noop; + input.write = input.pause = input.resume = () => {}; input.readable = true; const output = new Stream(); diff --git a/test/parallel/test-repl-save-load.js b/test/parallel/test-repl-save-load.js index 746f6f2b6cdeec..4ef2a633541494 100644 --- a/test/parallel/test-repl-save-load.js +++ b/test/parallel/test-repl-save-load.js @@ -98,7 +98,7 @@ putIn.write = function(data) { // make sure I get a failed to load message and not some crazy error assert.strictEqual(data, `Failed to load:${loadFile}\n`); // eat me to avoid work - putIn.write = common.noop; + putIn.write = () => {}; }; putIn.run([`.load ${loadFile}`]); @@ -106,7 +106,7 @@ putIn.run([`.load ${loadFile}`]); loadFile = common.tmpDir; putIn.write = function(data) { assert.strictEqual(data, `Failed to load:${loadFile} is not a valid file\n`); - putIn.write = common.noop; + putIn.write = () => {}; }; putIn.run([`.load ${loadFile}`]); @@ -122,7 +122,7 @@ putIn.write = function(data) { // make sure I get a failed to save message and not some other error assert.strictEqual(data, `Failed to save:${invalidFileName}\n`); // reset to no-op - putIn.write = common.noop; + putIn.write = () => {}; }; // save it to a file diff --git a/test/parallel/test-repl-tab-complete-crash.js b/test/parallel/test-repl-tab-complete-crash.js index fe9c1573666fcd..ba8de7888e3b09 100644 --- a/test/parallel/test-repl-tab-complete-crash.js +++ b/test/parallel/test-repl-tab-complete-crash.js @@ -4,7 +4,7 @@ const common = require('../common'); const assert = require('assert'); const repl = require('repl'); -common.ArrayStream.prototype.write = common.noop; +common.ArrayStream.prototype.write = () => {}; const putIn = new common.ArrayStream(); const testMe = repl.start('', putIn); diff --git a/test/parallel/test-stream-decoder-objectmode.js b/test/parallel/test-stream-decoder-objectmode.js index b536fbc4e8df67..4c572fed6b665b 100644 --- a/test/parallel/test-stream-decoder-objectmode.js +++ b/test/parallel/test-stream-decoder-objectmode.js @@ -1,11 +1,11 @@ 'use strict'; -const common = require('../common'); +require('../common'); const stream = require('stream'); const assert = require('assert'); const readable = new stream.Readable({ - read: common.noop, + read: () => {}, encoding: 'utf16le', objectMode: true }); diff --git a/test/parallel/test-stream-duplex.js b/test/parallel/test-stream-duplex.js index f0c8a47a507cfa..1cc54db05206a3 100644 --- a/test/parallel/test-stream-duplex.js +++ b/test/parallel/test-stream-duplex.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const Duplex = require('stream').Duplex; @@ -38,7 +38,7 @@ stream._write = (obj, _, cb) => { cb(); }; -stream._read = common.noop; +stream._read = () => {}; stream.on('data', (obj) => { read = obj; diff --git a/test/parallel/test-stream-pipe-await-drain.js b/test/parallel/test-stream-pipe-await-drain.js index b90a9d0edd1fd2..5bdf48008479e7 100644 --- a/test/parallel/test-stream-pipe-await-drain.js +++ b/test/parallel/test-stream-pipe-await-drain.js @@ -15,7 +15,7 @@ const writer3 = new stream.Writable(); // See: https://github.com/nodejs/node/issues/5820 const buffer = Buffer.allocUnsafe(560000); -reader._read = common.noop; +reader._read = () => {}; writer1._write = common.mustCall(function(chunk, encoding, cb) { this.emit('chunk-received'); diff --git a/test/parallel/test-stream-pipe-cleanup-pause.js b/test/parallel/test-stream-pipe-cleanup-pause.js index 2f3754de3ee445..3cdab94648d465 100644 --- a/test/parallel/test-stream-pipe-cleanup-pause.js +++ b/test/parallel/test-stream-pipe-cleanup-pause.js @@ -11,7 +11,7 @@ const writer2 = new stream.Writable(); // See: https://github.com/nodejs/node/issues/2323 const buffer = Buffer.allocUnsafe(560000); -reader._read = common.noop; +reader._read = () => {}; writer1._write = common.mustCall(function(chunk, encoding, cb) { this.emit('chunk-received'); diff --git a/test/parallel/test-stream-pipe-error-handling.js b/test/parallel/test-stream-pipe-error-handling.js index e7eca593e762a1..e725465e079682 100644 --- a/test/parallel/test-stream-pipe-error-handling.js +++ b/test/parallel/test-stream-pipe-error-handling.js @@ -101,10 +101,10 @@ const Stream = require('stream').Stream; }); w.on('error', common.mustCall()); - w._write = common.noop; + w._write = () => {}; r.pipe(w); // Removing some OTHER random listener should not do anything - w.removeListener('error', common.noop); + w.removeListener('error', () => {}); removed = true; } diff --git a/test/parallel/test-stream-pipe-multiple-pipes.js b/test/parallel/test-stream-pipe-multiple-pipes.js index d89dcbd947615d..890c274b9d9f51 100644 --- a/test/parallel/test-stream-pipe-multiple-pipes.js +++ b/test/parallel/test-stream-pipe-multiple-pipes.js @@ -4,7 +4,7 @@ const stream = require('stream'); const assert = require('assert'); const readable = new stream.Readable({ - read: common.noop + read: () => {} }); const writables = []; diff --git a/test/parallel/test-stream-pipe-unpipe-streams.js b/test/parallel/test-stream-pipe-unpipe-streams.js index 067b7f44820be0..916bd2cdfacf53 100644 --- a/test/parallel/test-stream-pipe-unpipe-streams.js +++ b/test/parallel/test-stream-pipe-unpipe-streams.js @@ -4,9 +4,9 @@ const assert = require('assert'); const { Readable, Writable } = require('stream'); -const source = Readable({read: common.noop}); -const dest1 = Writable({write: common.noop}); -const dest2 = Writable({write: common.noop}); +const source = Readable({read: () => {}}); +const dest1 = Writable({write: () => {}}); +const dest2 = Writable({write: () => {}}); source.pipe(dest1); source.pipe(dest2); diff --git a/test/parallel/test-stream-readable-emittedReadable.js b/test/parallel/test-stream-readable-emittedReadable.js index 82d8b645efe7af..65b6b5b15a5895 100644 --- a/test/parallel/test-stream-readable-emittedReadable.js +++ b/test/parallel/test-stream-readable-emittedReadable.js @@ -4,7 +4,7 @@ const assert = require('assert'); const Readable = require('stream').Readable; const readable = new Readable({ - read: common.noop + read: () => {} }); // Initialized to false. @@ -37,7 +37,7 @@ process.nextTick(common.mustCall(() => { })); const noRead = new Readable({ - read: common.noop + read: () => {} }); noRead.on('readable', common.mustCall(() => { @@ -52,7 +52,7 @@ noRead.push('foo'); noRead.push(null); const flowing = new Readable({ - read: common.noop + read: () => {} }); flowing.on('data', common.mustCall(() => { diff --git a/test/parallel/test-stream-readable-invalid-chunk.js b/test/parallel/test-stream-readable-invalid-chunk.js index 990154144ab5ed..f528dfe693316a 100644 --- a/test/parallel/test-stream-readable-invalid-chunk.js +++ b/test/parallel/test-stream-readable-invalid-chunk.js @@ -1,11 +1,11 @@ 'use strict'; -const common = require('../common'); +require('../common'); const stream = require('stream'); const assert = require('assert'); const readable = new stream.Readable({ - read: common.noop + read: () => {} }); const errMessage = /Invalid non-string\/buffer chunk/; diff --git a/test/parallel/test-stream-readable-needReadable.js b/test/parallel/test-stream-readable-needReadable.js index dba188c5726090..be397dc5dc5f74 100644 --- a/test/parallel/test-stream-readable-needReadable.js +++ b/test/parallel/test-stream-readable-needReadable.js @@ -4,7 +4,7 @@ const assert = require('assert'); const Readable = require('stream').Readable; const readable = new Readable({ - read: common.noop + read: () => {} }); // Initialized to false. @@ -28,7 +28,7 @@ readable.on('end', common.mustCall(() => { })); const asyncReadable = new Readable({ - read: common.noop + read: () => {} }); asyncReadable.on('readable', common.mustCall(() => { @@ -51,7 +51,7 @@ process.nextTick(common.mustCall(() => { })); const flowing = new Readable({ - read: common.noop + read: () => {} }); // Notice this must be above the on('data') call. @@ -69,7 +69,7 @@ flowing.on('data', common.mustCall(function(data) { }, 3)); const slowProducer = new Readable({ - read: common.noop + read: () => {} }); slowProducer.on('readable', common.mustCall(() => { diff --git a/test/parallel/test-stream-readableListening-state.js b/test/parallel/test-stream-readableListening-state.js index 84e09aabca0355..5e3071faf370e5 100644 --- a/test/parallel/test-stream-readableListening-state.js +++ b/test/parallel/test-stream-readableListening-state.js @@ -5,7 +5,7 @@ const assert = require('assert'); const stream = require('stream'); const r = new stream.Readable({ - read: common.noop + read: () => {} }); // readableListening state should start in `false`. @@ -19,7 +19,7 @@ r.on('readable', common.mustCall(() => { r.push(Buffer.from('Testing readableListening state')); const r2 = new stream.Readable({ - read: common.noop + read: () => {} }); // readableListening state should start in `false`. diff --git a/test/parallel/test-stream2-pipe-error-once-listener.js b/test/parallel/test-stream2-pipe-error-once-listener.js index de65c2469e095c..71ce19b36062e5 100644 --- a/test/parallel/test-stream2-pipe-error-once-listener.js +++ b/test/parallel/test-stream2-pipe-error-once-listener.js @@ -21,7 +21,7 @@ 'use strict'; -const common = require('../common'); +require('../common'); const util = require('util'); const stream = require('stream'); @@ -50,7 +50,7 @@ Write.prototype._write = function(buffer, encoding, cb) { const read = new Read(); const write = new Write(); -write.once('error', common.noop); +write.once('error', () => {}); write.once('alldone', function(err) { console.log('ok'); }); diff --git a/test/parallel/test-stream2-readable-wrap-empty.js b/test/parallel/test-stream2-readable-wrap-empty.js index 39bc509a394022..1489717f3e49c3 100644 --- a/test/parallel/test-stream2-readable-wrap-empty.js +++ b/test/parallel/test-stream2-readable-wrap-empty.js @@ -26,13 +26,13 @@ const Readable = require('_stream_readable'); const EE = require('events').EventEmitter; const oldStream = new EE(); -oldStream.pause = common.noop; -oldStream.resume = common.noop; +oldStream.pause = () => {}; +oldStream.resume = () => {}; const newStream = new Readable().wrap(oldStream); newStream - .on('readable', common.noop) + .on('readable', () => {}) .on('end', common.mustCall()); oldStream.emit('end'); diff --git a/test/parallel/test-timers-unref-call.js b/test/parallel/test-timers-unref-call.js index 45263f617886f5..0015318c4bad8d 100644 --- a/test/parallel/test-timers-unref-call.js +++ b/test/parallel/test-timers-unref-call.js @@ -1,12 +1,12 @@ 'use strict'; -const common = require('../common'); +require('../common'); const Timer = process.binding('timer_wrap').Timer; Timer.now = function() { return ++Timer.now.ticks; }; Timer.now.ticks = 0; -const t = setInterval(common.noop, 1); +const t = setInterval(() => {}, 1); const o = { _idleStart: 0, _idleTimeout: 1 }; t.unref.call(o); diff --git a/test/parallel/test-timers-unref-remove-other-unref-timers.js b/test/parallel/test-timers-unref-remove-other-unref-timers.js index 221f5bb6fd93ab..84dd75025d6c0d 100644 --- a/test/parallel/test-timers-unref-remove-other-unref-timers.js +++ b/test/parallel/test-timers-unref-remove-other-unref-timers.js @@ -29,4 +29,4 @@ timers.enroll(foo, 50); timers._unrefActive(foo); // Keep the process open. -setTimeout(common.noop, 100); +setTimeout(() => {}, 100); diff --git a/test/parallel/test-timers-unref.js b/test/parallel/test-timers-unref.js index f0d0a27536e216..7f66a364e3f24b 100644 --- a/test/parallel/test-timers-unref.js +++ b/test/parallel/test-timers-unref.js @@ -21,7 +21,7 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); let interval_fired = false; @@ -35,11 +35,11 @@ const LONG_TIME = 10 * 1000; const SHORT_TIME = 100; assert.doesNotThrow(function() { - setTimeout(common.noop, 10).unref().ref().unref(); + setTimeout(() => {}, 10).unref().ref().unref(); }, 'ref and unref are chainable'); assert.doesNotThrow(function() { - setInterval(common.noop, 10).unref().ref().unref(); + setInterval(() => {}, 10).unref().ref().unref(); }, 'ref and unref are chainable'); setInterval(function() { @@ -78,7 +78,7 @@ setInterval(function() { // Should not assert on args.Holder()->InternalFieldCount() > 0. See #4261. { - const t = setInterval(common.noop, 1); + const t = setInterval(() => {}, 1); process.nextTick(t.unref.bind({})); process.nextTick(t.unref.bind(t)); } diff --git a/test/parallel/test-timers-unrefed-in-beforeexit.js b/test/parallel/test-timers-unrefed-in-beforeexit.js index 487a4ecef52d8b..530d97674d8bf7 100644 --- a/test/parallel/test-timers-unrefed-in-beforeexit.js +++ b/test/parallel/test-timers-unrefed-in-beforeexit.js @@ -1,6 +1,6 @@ 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); let once = 0; @@ -9,7 +9,7 @@ process.on('beforeExit', () => { if (once > 1) throw new RangeError('beforeExit should only have been called once!'); - setTimeout(common.noop, 1).unref(); + setTimeout(() => {}, 1).unref(); once++; }); diff --git a/test/parallel/test-timers-zero-timeout.js b/test/parallel/test-timers-zero-timeout.js index 4e1eefb40d2779..7feb01854e0d64 100644 --- a/test/parallel/test-timers-zero-timeout.js +++ b/test/parallel/test-timers-zero-timeout.js @@ -26,7 +26,7 @@ const assert = require('assert'); // https://github.com/joyent/node/issues/2079 - zero timeout drops extra args { setTimeout(common.mustCall(f), 0, 'foo', 'bar', 'baz'); - setTimeout(common.noop, 0); + setTimeout(() => {}, 0); function f(a, b, c) { assert.strictEqual(a, 'foo'); diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 19424f6b0be21e..388479b8f5332f 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -const common = require('../common'); +require('../common'); const assert = require('assert'); const util = require('util'); const vm = require('vm'); @@ -785,9 +785,9 @@ if (typeof Symbol !== 'undefined') { const rejected = Promise.reject(3); assert.strictEqual(util.inspect(rejected), 'Promise { 3 }'); // squelch UnhandledPromiseRejection - rejected.catch(common.noop); + rejected.catch(() => {}); - const pending = new Promise(common.noop); + const pending = new Promise(() => {}); assert.strictEqual(util.inspect(pending), 'Promise { }'); const promiseWithProperty = Promise.resolve('foo'); @@ -885,7 +885,7 @@ if (typeof Symbol !== 'undefined') { 'SetSubclass { 1, 2, 3 }'); assert.strictEqual(util.inspect(new MapSubclass([['foo', 42]])), 'MapSubclass { \'foo\' => 42 }'); - assert.strictEqual(util.inspect(new PromiseSubclass(common.noop)), + assert.strictEqual(util.inspect(new PromiseSubclass(() => {})), 'PromiseSubclass { }'); } diff --git a/test/parallel/test-vm-sigint-existing-handler.js b/test/parallel/test-vm-sigint-existing-handler.js index 217d56dd972421..eb67820ff20d73 100644 --- a/test/parallel/test-vm-sigint-existing-handler.js +++ b/test/parallel/test-vm-sigint-existing-handler.js @@ -42,7 +42,7 @@ if (process.argv[2] === 'child') { assert.strictEqual(onceHandlerCalled, 0); // Keep the process alive for a while so that the second SIGINT can be caught. - const timeout = setTimeout(common.noop, 1000); + const timeout = setTimeout(() => {}, 1000); let afterHandlerCalled = 0; diff --git a/test/parallel/test-whatwg-url-parsing.js b/test/parallel/test-whatwg-url-parsing.js index 35658d94a912bc..39756449c08c6a 100644 --- a/test/parallel/test-whatwg-url-parsing.js +++ b/test/parallel/test-whatwg-url-parsing.js @@ -22,7 +22,7 @@ const failureTests = tests.filter((test) => test.failure).concat([ { input: null }, { input: new Date() }, { input: new RegExp() }, - { input: common.noop } + { input: () => {} } ]); const expectedError = common.expectsError( diff --git a/test/pseudo-tty/ref_keeps_node_running.js b/test/pseudo-tty/ref_keeps_node_running.js index 7eb2d1a60a72f7..7832e9ee21ba26 100644 --- a/test/pseudo-tty/ref_keeps_node_running.js +++ b/test/pseudo-tty/ref_keeps_node_running.js @@ -1,6 +1,6 @@ 'use strict'; -const common = require('../common'); +require('../common'); const { TTY, isTTY } = process.binding('tty_wrap'); const strictEqual = require('assert').strictEqual; @@ -9,7 +9,7 @@ strictEqual(isTTY(0), true, 'fd 0 is not a TTY'); const handle = new TTY(0); handle.readStart(); -handle.onread = common.noop; +handle.onread = () => {}; function isHandleActive(handle) { return process._getActiveHandles().some((active) => active === handle);