π Disallow unnecessary Error.captureStackTrace(β¦).
πΌ This rule is enabled in the following configs: β
recommended, βοΈ unopinionated.
π§ This rule is automatically fixable by the --fix CLI option.
Calling Error.captureStackTrace(β¦) inside the constructor of a built-in Error subclass is unnecessary, since the Error constructor calls it automatically.
// β
class MyError extends Error {
constructor() {
Error.captureStackTrace(this, MyError);
}
}// β
class MyError extends Error {
constructor() {
Error.captureStackTrace?.(this, MyError);
}
}// β
class MyError extends Error {
constructor() {
Error.captureStackTrace(this, this.constructor);
}
}// β
class MyError extends Error {
constructor() {
Error.captureStackTrace?.(this, this.constructor);
}
}// β
class MyError extends Error {
constructor() {
Error.captureStackTrace(this, new.target);
}
}// β
class MyError extends Error {
constructor() {
Error.captureStackTrace?.(this, new.target);
}
}