pi-lens
Version:
Real-time code feedback for pi — LSP, linters, formatters, type-checking, structural analysis & booboo
25 lines (23 loc) • 813 B
YAML
# DISABLED (#206): needs `inside` + `not has` relational matching the runner's
# rule interpreter can't execute; also redundant with the equivalent TS check.
id: constructor-super-js
message: super() must be called in derived class constructors.
severity: error
language: JavaScript
rule:
pattern:
selector: method_definition
context: class A { constructor($$$) { $$$ }}
inside:
stopBy: end
pattern: class $CLASS extends $BASE { $$$ }
not:
has:
stopBy:
any:
- kind: class_declaration
- kind: class
- kind: arrow_function
pattern: super($$$)
note: |
Constructors of derived classes must call super(). Constructors of non derived classes must not call super(). If this is not observed, the JavaScript engine will raise a runtime error.