Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
karol-majewski opened this issue Aug 7, 2019 · 1 comment

Comments

@karol-majewski
Copy link

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.

@jonaskello
Copy link
Owner

Yes, that seems reasonable to me and a PR could be accepted.

Btw, you may want to switch to eslint as tslint is being deprecated. See the new eslint-plugin-functional project which is a port of the rules in this repo to eslint. You should probably open the same issue over there too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants