tslint-immutable
tslint-immutable copied to clipboard
"no-expression-statement" should allow super() call in constructors
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.
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.