59 lines
964 B
Plaintext

//// This rule is superseded by RSPEC-3854
//// Please consider implementing this latter instead.
In the constructor of a derived class, accessing ``++this++`` or ``++super++`` before ``++super()++`` is called raises a reference error. ``++super()++`` should always be called first.
== Noncompliant Code Example
----
class Bar {
}
class Foo extends Bar {
constructor() {
this.val = 0; // Noncompliant
super();
}
}
class Foobar extends Foo {
constructor() {
super.val = 1; // Noncompliant
super();
}
}
----
== Compliant Solution
----
class Bar {
}
class Foo extends Bar {
constructor() {
super();
this.val = 0;
}
}
class Foobar extends Foo {
constructor() {
super();
super.val = 1;
}
}
----
ifdef::env-github,rspecator-view[]
'''
== Comments And Links
(visible only on this page)
include::comments-and-links.adoc[]
endif::env-github,rspecator-view[]