super()
should be called only once in the constructor
- MULTIPLE_SUPER_CALL
- Error
- High
- es6
This rule applies when super()
is called multiple times in the constructor.
Multiple super()
calls throw a ReferenceError
exception.
Noncompliant Code Example
View with compliant examples side by sideclass A {}
class B extends A {
constructor(props) {
super(props);
props.forEach(p => test(p));
super(props); // MULTIPLE_SUPER_CALL alarm
}
}
var obj = new B(props);
Compliant Code Example
View with noncompliant examples side by sideclass A {}
class B extends A {
constructor(props) {
super(props);
props.forEach(p => test(p));
}
}
var obj = new B(props);
Version
This rule was introduced in DeepScan 1.11.0-beta.