noInvalidConstructorSuper
Diagnostic Category: lint/correctness/noInvalidConstructorSuper
Since: v1.0.0
Sources:
- Same as:
constructor-super
Description
Section titled DescriptionPrevents the incorrect use of super()
inside classes. It also checks whether a call super()
is missing from classes that extends other constructors.
Examples
Section titled ExamplesInvalid
Section titled Invalidclass A { constructor() { super(); }}
code-block.js:3:9 lint/correctness/noInvalidConstructorSuper ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ This class should not have a super() call. You should remove it.
1 │ class A {
2 │ constructor() {
> 3 │ super();
│ ^^^^^
4 │ }
5 │ }
class A extends undefined { constructor() { super(); }}
code-block.js:3:9 lint/correctness/noInvalidConstructorSuper ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✖ This class calls super(), but the class extends from a non-constructor.
1 │ class A extends undefined {
2 │ constructor() {
> 3 │ super();
│ ^^^^^
4 │ }
5 │ }
ℹ This is where the non-constructor is used.
> 1 │ class A extends undefined {
│ ^^^^^^^^^
2 │ constructor() {
3 │ super();
Valid
Section titled Validexport default class A extends B { constructor() { super(); }}
export class A { constructor() {}}
How to configure
Section titled How to configure{ "linter": { "rules": { "correctness": { "noInvalidConstructorSuper": "error" } } }}