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.
Examples
Examples of incorrect code for this rule:
javascript
class Foo extends EventEmitter {}Examples of correct code for this rule:
javascript
class Foo extends OtherClass {}How to use
To enable this rule in the CLI or using the config file, you can use:
bash
oxlint --deny unicorn/prefer-event-targetjson
{
"rules": {
"unicorn/prefer-event-target": "error"
}
}