{"record":{"id":"09b44c5a22fc25de","repo":"oxc-project/oxc","slug":"expected-to-call-super","errorCode":null,"errorMessage":"Expected to call `super()`.","messagePattern":"Expected to call `super\\(\\)`\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/eslint/constructor_super.rs","lineNumber":21,"sourceCode":"use rustc_hash::FxHashMap;\n\nuse oxc_ast::{AstKind, ast::*};\nuse oxc_cfg::{\n    BlockNodeId, ControlFlowGraph, EdgeType,\n    graph::{\n        Direction,\n        visit::{EdgeRef, neighbors_filtered_by_edge_weight},\n    },\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_semantic::NodeId;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{AstNode, context::LintContext, rule::Rule};\n\nfn missing_super_all(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Expected to call `super()`.\")\n        .with_help(\"Add a `super()` call to the constructor\")\n        .with_label(span)\n}\n\nfn missing_super_some(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Lacked a call of `super()` in some code paths.\")\n        .with_help(\"Ensure `super()` is called in all code paths\")\n        .with_label(span)\n}\n\nfn duplicate_super(span: Span, first_super_span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Unexpected duplicate `super()`.\")\n        .with_help(\"Remove the duplicate `super()` call\")\n        .with_labels([\n            span.primary_label(\"This path may call `super()` after it was already called.\"),\n            first_super_span.label(\"`super()` was first called here.\"),\n        ])\n}","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/constructor_super.rs#L3-L39","documentation":"Oxlint's port of ESLint constructor-super, missing_super_all variant (crates/oxc_linter/src/rules/eslint/constructor_super.rs:20). In a derived class, `this` cannot be used before `super()` runs, and instantiating a derived class whose constructor never calls super() throws a ReferenceError at runtime. The rule builds a control-flow graph (petgraph is imported in this file) and reports when no super() call is reachable from the constructor at all.","triggerScenarios":"Any derived-class constructor whose body contains no super() call, e.g. `class B extends A { constructor() { this.x = 1; } }`; the diagnostic labels the constructor span.","commonSituations":"Refactoring a base class into a hierarchy and forgetting to add super() to new subclasses; constructor templates copied into derived classes; converting a plain class into a derived one.","solutions":["Add `super(...)` as the first statement of the derived constructor.","Delete the constructor entirely if it does nothing custom — the implicit derived constructor forwards arguments and calls super().","If the class intentionally extends null, do not call super() and do not touch `this` before manual initialization; otherwise point `extends` at a real class."],"exampleFix":"// before\nclass Checkbox extends Input {\n  constructor(props) {\n    this.props = props; // ReferenceError at runtime\n  }\n}\n\n// after\nclass Checkbox extends Input {\n  constructor(props) {\n    super(props);\n  }\n}","handlingStrategy":"validation","validationCode":"// .oxlintrc.json — keep this rule at error level so CI fails before the runtime does\n{\n  \"rules\": {\n    \"constructor-super\": \"error\"\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat constructor-super findings as guaranteed runtime ReferenceErrors; never suppress them blindly.","When introducing inheritance, write `super(...)` first, then the body.","Omit trivial derived constructors — the implicit one calls super for you."],"tags":["eslint","oxlint","class","super","constructor","runtime-error"],"backgroundTag":"missing-super-constructor-call","analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}