pi-lens
Version:
Real-time code feedback for pi — LSP, linters, formatters, type-checking, structural analysis & booboo
58 lines (48 loc) • 1.24 kB
YAML
# Constructor Super Call Detection
# Detects derived class constructors that don't call super()
id: constructor-super
name: Missing super() call in derived class constructor
severity: error
category: correctness
defect_class: correctness
inline_tier: blocking
language: typescript
message: "Constructor of derived class must call super() before accessing 'this'"
description: |
Constructors of derived classes must call super() before accessing 'this'.
This is a JavaScript runtime requirement that throws if violated.
query: |
(class_declaration
(class_heritage
(extends_clause) )
body: (class_body
(method_definition
name: (property_identifier)
(#eq? "constructor")
body: (statement_block) )))
metavars:
- EXTENDS
- CONSTRUCTOR
- BODY
post_filter: "no_super_call"
post_filter_params: {}
tags:
- correctness
- javascript
- typescript
- constructor
examples:
bad: |
class Derived extends Base {
constructor() {
this.value = 1; // ERROR: must call super() first
}
}
good: |
class Derived extends Base {
constructor() {
super();
this.value = 1;
}
}
has_fix: false