Skip to content

Latest commit

 

History

History
34 lines (22 loc) · 989 Bytes

prefer-event-target.md

File metadata and controls

34 lines (22 loc) · 989 Bytes

Prefer EventTarget over EventEmitter

💼 This rule is enabled in 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();