thisBeforeSuper
Reports using
thisorsuperbefore callingsuper()in derived class constructors.
✅ This rule is included in the ts untyped 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.
Examples
Section titled “Examples”class Child extends Parent { constructor() { this.value = 0; super(); }}class Child extends Parent { constructor() { super.initialize(); super(); }}class Child extends Parent { constructor() { super(); this.value = 0; }}class Child extends Parent { constructor() { super(); super.initialize(); }}Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”If your code is transpiled in a way that does not match modern ECMAScript semantics, this rule may not be for you.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Biome:
noUnreachableSuper - Deno:
no-this-before-super - ESLint:
no-this-before-super - Oxlint:
eslint/no-this-before-super
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.