diff options
author | Rich Trott <rtrott@gmail.com> | 2017-05-03 21:07:54 -0700 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2017-07-03 11:39:35 -0700 |
commit | 380929ec0c4c4004b522bed5e3800ebce2b68bfd (patch) | |
tree | 6c086dfe2f734dff7a66181f81da24c450e9796a /test/parallel/test-event-emitter-listener-count.js | |
parent | 932ee65cd280808dd27e08fea7dfc4ebdc492b7a (diff) | |
download | node-new-380929ec0c4c4004b522bed5e3800ebce2b68bfd.tar.gz |
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
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Diffstat (limited to 'test/parallel/test-event-emitter-listener-count.js')
-rw-r--r-- | test/parallel/test-event-emitter-listener-count.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/test/parallel/test-event-emitter-listener-count.js b/test/parallel/test-event-emitter-listener-count.js index 50247f4277..117d38f575 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); |