Class should inherit from a constructor

  • Error
  • High
  • es6

This rule applies when a class inherits from a non-constructor.

When a class inherits from non-constructor values like the following, a TypeError exception occurs:

  1. Arrow function
  2. Async function
  3. Generator function
  4. Non-function values except null

Noncompliant Code Example

View with compliant examples side by side
let Foo = () => { };
class Bar extends Foo { } // INHERIT_NON_CONSTRUCTOR alarm because an arrow function is not a constructor.

Compliant Code Example

View with noncompliant examples side by side
let Foo = function () { };
class Bar extends Foo { }


This rule was introduced in DeepScan 1.32.0.


Was this documentation helpful?