Skip to content

"no-expression-statement" should allow super() call in constructorsΒ #147

@karol-majewski

Description

@karol-majewski

Offending code

export class NullDereferenced extends Error {
  constructor(readonly message: string = 'This value was promised to never be undefined.') {
    super(message);

    Object.setPrototypeOf(this, NullDereferenced.prototype);

    if ('captureStackTrace' in Error) { // wotan-disable-line no-useless-predicate
      Error.captureStackTrace(this, NullDereferenced);
    }
  }
}

Actual behavior

The super() call causes an error.

Using expressions to cause side-effects not allowed. (no-expression-statement)

Expected bahavior

No error. There is no way around that.

Possible heuristic

If the offending node is a CallExpression, and the inner expression is of type SuperKeyword, then the error should not be raised.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions