Skip to content

eslint/no-this-before-super Correctness

This rule is turned on by default.

What it does

Requires calling super() before using this or super.

Why is this bad?

Getters should always return a value. If they don't, it's probably a mistake.

Example

javascript
class A1 extends B {
  constructor() {
    // super() needs to be called first
    this.a = 0;
    super();
  }
}

How to use

To enable this rule in the CLI or using the config file, you can use:

bash
oxlint --deny no-this-before-super
json
{
  "rules": {
    "no-this-before-super": "error"
  }
}

References

Released under the MIT License.