lib: validate Error.captureStackTrace() calls

This adds a custom eslint rule to verify that
`Error.captureStackTrace()` is only called if necessary. In most
cases the helper function should be used instead.

PR-URL: https://github.com/nodejs/node/pull/26738
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This commit is contained in:
Ruben Bridgewater committed 2019-03-23 02:55:55 +01:00
1 parent bfbce289c3
commit 3fe1e80896
9 files changed
+15

No files matched your search

+1
View File
@@ -398,6 +398,7 @@ class AssertionError extends Error {
this.actual = actual;
this.expected = expected;
this.operator = operator;
// eslint-disable-next-line no-restricted-syntax
Error.captureStackTrace(this, stackStartFn);
// Create error message including the error code in the name.
this.stack;