Skip to content

Latest commit

 

History

History
33 lines (22 loc) · 856 Bytes

prefer-event-target.md

File metadata and controls

33 lines (22 loc) · 856 Bytes

Prefer EventTarget over EventEmitter

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();