From 3fe1e80896d69b2125e3a264d0707fdbc6f37740 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Mon, 18 Mar 2019 03:47:55 +0100 Subject: lib: validate Error.captureStackTrace() calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-By: Matteo Collina Reviewed-By: Michaƫl Zasso Reviewed-By: Joyee Cheung --- lib/.eslintrc.yaml | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/.eslintrc.yaml') diff --git a/lib/.eslintrc.yaml b/lib/.eslintrc.yaml index fcb9ea7feb..3b041d5db4 100644 --- a/lib/.eslintrc.yaml +++ b/lib/.eslintrc.yaml @@ -15,6 +15,8 @@ rules: # Config specific to lib - selector: "NewExpression[callee.name=/Error$/]:not([callee.name=/^(AssertionError|NghttpError)$/])" message: "Use an error exported by the internal/errors module." + - selector: "CallExpression[callee.object.name='Error'][callee.property.name='captureStackTrace']" + message: "Please use `require('internal/errors').hideStackFrames()` instead." # Custom rules in tools/eslint-rules node-core/require-globals: error node-core/no-let-in-for-declaration: error -- cgit v1.2.3