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/events.js | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/events.js') diff --git a/lib/events.js b/lib/events.js index 8a676773b6..6a141f44d8 100644 --- a/lib/events.js +++ b/lib/events.js @@ -158,6 +158,7 @@ EventEmitter.prototype.emit = function emit(type, ...args) { try { const { kExpandStackSymbol } = require('internal/util'); const capture = {}; + // eslint-disable-next-line no-restricted-syntax Error.captureStackTrace(capture, EventEmitter.prototype.emit); Object.defineProperty(er, kExpandStackSymbol, { value: enhanceStackTrace.bind(null, er, capture), -- cgit v1.2.3