Skip to content

Latest commit

 

History

History
39 lines (25 loc) · 978 Bytes

prefer-event-target.md

File metadata and controls

39 lines (25 loc) · 978 Bytes

Prefer EventTarget over EventEmitter

This rule is part of the recommended config.

While EventEmitter is only available in Node.js, EventTarget is also available in Deno and browsers.

This rule reduces the bundle size and makes your code more cross-platform friendly.

See the differences between EventEmitter and EventTarget.

Fail

import EventEmitter from 'node:event';

class Foo extends EventEmitter {

}
const emitter = new EventEmitter;

Pass

class Foo extends EventTarget {

}
const target = new EventTarget;