Skip to content

thisBeforeSuper

Reports using this or super before calling super() in derived class constructors.

✅ This rule is included in the ts javascript presets.

In JavaScript, when a class extends another class, the constructor must call super() before accessing this or super.property. Attempting to access this or super properties before calling super() throws a ReferenceError.

AEcla5<3 sp ansty="le--0:#FFCB8B;--1:#1111">11Chi5<3 sp ansty="le--0:#C792EA;--1:#8844">AEexten5<3 sp ansty="le--0:#C5E478;--1:#3B61">B0Pare53< {d ivclassNa="meec-li">nt< sp ansty="le--0:#82AAFF;--1:#3B61">B0construct11<()sp ansty="le--0:#D6DEEB;--1:#403F">53< {d ivclassNa="meec-li">nt < sp ansty="le--0:#7FDBCA;--1:#096E">72thA72val5<3 sp ansty="le--0:#C792EA;--1:#8844">A5<3 sp ansty="le--0:#F78C6C;--1:#AA09">8<20sp ansty="le--0:#D6DEEB;--1:#403F">5<3;d ivclassNa="meec-li">nt < sp ansty="le--0:#7FDBCA;--1:#096E">72sup53(<);d ivclassNa="meec-li">53< sp ansty="le--0:#D6DEEB;--1:#403F">5<3}d ivclassNa="meec-li">5<3}d ivclassNa="meco"><}d>AEcla5<3 sp ansty="le--0:#FFCB8B;--1:#1111">11Chi5<3 sp ansty="le--0:#C792EA;--1:#8844">AEexten5<3 sp ansty="le--0:#C5E478;--1:#3B61">B0Pare53< {d ivclassNa="meec-li">nt< sp ansty="le--0:#82AAFF;--1:#3B61">B0construct11<()sp ansty="le--0:#D6DEEB;--1:#403F">53< {d ivclassNa="meec-li">nt < sp ansty="le--0:#7FDBCA;--1:#096E">72supAB0initiali53(<);d ivclassNa="meec-li">nt < sp ansty="le--0:#7FDBCA;--1:#096E">72sup53(<);d ivclassNa="meec-li">53< sp ansty="le--0:#D6DEEB;--1:#403F">5<3}d ivclassNa="meec-li">5<3}d ivclassNa="meco"><}d>
44AEc31111C344AEext361B0Pa3F<53 {divclass="Nameec-">de61B0constru11<11() spans="tyle--0:#D6DEEB;--1:#40">3F<53 {divclass="Nameec-">dent< spans="tyle--0:#7FDBCA;--1:#09">6E72s3F5<3() ;divclass="Nameec-">dent< spans="tyle--0:#7FDBCA;--1:#09">6E724<4AE. spans="tyle--0:#7FDBCA;--1:#09">6E72v34<4AE= spans="tyle--0:#D6DEEB;--1:#40">30<9820 spans="tyle--0:#D6DEEB;--1:#40">33F<53 spans="tyle--0:#D6DEEB;--1:#40">33< }><}di vdivclass="Nameexpressive-">44AEc31111C344AEext361B0Pa3F<53 {divclass="Nameec-">de61B0constru11<11() spans="tyle--0:#D6DEEB;--1:#40">3F<53 {divclass="Nameec-">dent< spans="tyle--0:#7FDBCA;--1:#09">6E72s3F5<3() ;divclass="Nameec-">dent< spans="tyle--0:#7FDBCA;--1:#09">6E72s4<4AE. spans="tyle--0:#82AAFF;--1:#3B">61B0initia3F5<3() ;divclass="Nameec-">3F<53 spans="tyle--0:#D6DEEB;--1:#40">33< }>

This rule is not configurable.

If your code is transpiled in a way that does not match modern ECMAScript semantics, this rule may not be for you.