Lint Rules

noInvalidConstructorSuper (since v10.0.0)

Prevents the incorrect use of super() inside classes. It also checks whether a call super() is missing from classes that extends other constructors.

Examples

Invalid

class A extends B {
    constructor() {}
}
nursery/noInvalidConstructorSuper.js:1:9 lint/nursery/noInvalidConstructorSuper ━━━━━━━━━━━━━━━━━━━━

   This class extends another class and a super() call is expected.
  
  > 1 │ class A extends B {
           ^^^^^^^^^
    2 │     constructor() {}
    3 │ }
  
class A {
    constructor() {
        super();
    }
}
nursery/noInvalidConstructorSuper.js:3:9 lint/nursery/noInvalidConstructorSuper ━━━━━━━━━━━━━━━━━━━━

   This class should not have a super() call. You should remove it.
  
    1 │ class A {
    2 │     constructor() {
  > 3 │         super();
           ^^^^^
    4 │     }
    5 │ }
  

Valid

export default class A extends B {
    constructor() {
        super();
    }
}
export class A {
    constructor() {}
}