tools: prohibit Error.prepareStackTrace() usage

This eslint rule makes sure that `prepareStackTrace()` is not used in
Node.js core.

PR-URL: https://github.com/nodejs/node/pull/29827
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gus Caplan <me@gus.host>
This commit is contained in:
Ruben Bridgewater 2019-10-03 02:24:19 +02:00 committed by Rich Trott
parent 870eea303a
commit 0521a98fd6

View File

@ -33,6 +33,8 @@ rules:
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."
- selector: "AssignmentExpression:matches([left.name='prepareStackTrace'], [left.property.name='prepareStackTrace'])"
message: "Use 'overrideStackTrace' from 'lib/internal/errors.js' instead of 'Error.prepareStackTrace'."
# Custom rules in tools/eslint-rules
node-core/lowercase-name-for-primitive: error
node-core/non-ascii-character: error