unicorn/prefer-event-target Pedantic ​
What it does ​
Prefers EventTarget
over EventEmitter
.
This rule reduces the bundle size and makes your code more cross-platform friendly.
See the differences between EventEmitter
and EventTarget
.
Why is this bad? ​
While EventEmitter
is only available in Node.js, EventTarget
is also available in Deno and browsers.
Example ​
Examples of incorrect code for this rule:
javascript
class Foo extends EventEmitter {}
Examples of correct code for this rule:
javascript
class Foo extends OtherClass {}