{"record":{"id":"57fdc7bea0c561d8","repo":"oxc-project/oxc","slug":"redundant-super-call-in-constructor","errorCode":null,"errorMessage":"Redundant super call in constructor","messagePattern":"Redundant super call in constructor","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/eslint/no_useless_constructor.rs","lineNumber":32,"sourceCode":"/// ```js\n/// class A { constructor(){} }\n/// ```\nfn no_empty_constructor(constructor_span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Empty constructors are unnecessary\")\n        .with_label(constructor_span)\n        .with_help(\"Remove the constructor or add code to it.\")\n}\n\n/// ```js\n/// class A { }\n/// class B extends A {\n///     constructor() {\n///         super();\n///     }\n/// }\n/// ```\nfn no_redundant_super_call(constructor_span: Span, super_span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Redundant super call in constructor\")\n        .with_labels([\n            constructor_span.primary_label(\"This constructor is unnecessary,\"),\n            super_span.label(\"because it only passes arguments through to the superclass\"),\n        ])\n        .with_note(\"Subclasses automatically use the constructor of their superclass, making this redundant.\")\n        .with_help(\"Remove this constructor or add code to it.\")\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoUselessConstructor;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallow constructors that can be safely removed without changing how the class works.\n    ///\n    /// ### Why is this bad?\n    ///","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/no_useless_constructor.rs#L14-L50","documentation":"Diagnostic from `no-useless-constructor` (redundant-super variant). A derived-class constructor does nothing but forward its exact arguments to `super(...)`, e.g. `constructor(...args) { super(...args); }` or `constructor(a, b) { super(a, b); }`. Omitting the constructor produces the same behavior through the implicit derived constructor, so the declaration is redundant. Oxc emits two labels (constructor primary, super call secondary) plus a note explaining subclass constructors default to the superclass one.","triggerScenarios":"`class B extends A { constructor(...args) { super(...args); } }` where parameter names/order match the super arguments exactly; also the classic `constructor() { super(); }` with no args. Fires when the constructor body consists solely of the pass-through super call.","commonSituations":"IDE-generated override stubs; refactors that removed logic from a forwarding constructor; Angular/React class components copied from templates that always emit `constructor(props) { super(props); }` where nothing else uses props.","solutions":["Remove the whole constructor; the implicit derived constructor forwards identically.","If other logic was planned, add it to the body so the constructor is no longer pass-through.","For React class components, drop the constructor and use class property state instead.","Run `oxlint --fix` to remove it automatically."],"exampleFix":"// before\nclass B extends A {\n  constructor(a, b) {\n    super(a, b);\n  }\n}\n\n// after\nclass B extends A {}","handlingStrategy":"validation","validationCode":"function isPassThroughConstructor(ctor) {\n  return ctor && ctor.body.length === 1 && /super\\(/.test(ctor.body[0]) &&\n    ctor.params.every((p, i) => ctor.body[0].arguments[i]?.name === (p.name ?? p.rest));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Omit derived constructors that only forward to super().","Delete IDE-generated `constructor(props) { super(props); }` when props is unused.","Re-add a constructor only when it adds logic beyond forwarding."],"tags":["lint","eslint","oxlint","class","constructor","super"],"backgroundTag":"redundant-super-constructor","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"}