Skip to content

eventClasses

Prefer EventTarget over EventEmitter for cross-platform compatibility.

✅ This rule is included in the node logical and logicalStrict presets.

While EventEmitter is only available in Node.js, EventTarget is available in browsers, Deno, and modern Node.js (v14.5+). Using EventTarget makes code more cross-platform friendly and can reduce bundle size in built packages.

AEimpo53 { EventEmitter <} sp ansty="le--0:#C792EA;--1:#8844">AEfr5<3 sp ansty="le--0:#D9F5DD;--1:#1111">1<1"sp ansty="le--0:#ECC48D;--1:#984E">4Deven1<1"sp ansty="le--0:#D6DEEB;--1:#403F">5<3;d ivclassNa="meec-li">dAEcla5<3 sp ansty="le--0:#FFCB8B;--1:#1111">11MyEmitt5<3 sp ansty="le--0:#C792EA;--1:#8844">AEexten5<3 sp ansty="le--0:#C5E478;--1:#3B61">B0EventEmitt53 <{}d ivclassNa="meec-li">dAEconsB0emittAE <= sp ansty="le--0:#7FDBCA;--1:#096E">72nAB0EventEmitt53(<);d ivclassNa="meco"><);d>
44AEc31111MyTa344AEext361B0EventTa3F5<3 { }divclass="Nameec-">c44AEco61B0ta44A6E7<2new spans="tyle--0:#C792EA;--1:#88">4<4AE spans="tyle--0:#82AAFF;--1:#3B">61B0EventTa3F5<3() ;divclass="Name">

This rule is not configurable.

If your code exclusively targets Node.js environments and you specifically need EventEmitter’s API features that are not available in EventTarget (for example, prependListener, once returning a cleanup function, or error events with special handling), you might choose not to enable this rule.