diff options
author | Rich Trott <rtrott@gmail.com> | 2017-04-05 19:11:48 -0700 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2017-04-08 12:33:46 -0700 |
commit | 8191af5b292aa5d5f07492105781b6cf1d91c42f (patch) | |
tree | 86dcf9c5ce38cc237673b5cfb6ca4f8e0397b0d8 /tools | |
parent | a37273c1e4b93ed048e1d45818fe6c525480b121 (diff) | |
download | node-new-8191af5b292aa5d5f07492105781b6cf1d91c42f.tar.gz |
tools: replace custom new-with-error rule
Use no-restricted-syntax to implement the requirement that `Error`
objects must be thrown with the `new` keyword.
PR-URL: https://github.com/nodejs/node/pull/12249
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/eslint-rules/new-with-error.js | 31 |
1 files changed, 0 insertions, 31 deletions
diff --git a/tools/eslint-rules/new-with-error.js b/tools/eslint-rules/new-with-error.js deleted file mode 100644 index 655f34bf08..0000000000 --- a/tools/eslint-rules/new-with-error.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @fileoverview Require `throw new Error()` rather than `throw Error()` - * @author Rich Trott - */ -'use strict'; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -module.exports = function(context) { - - var errorList = context.options.length !== 0 ? context.options : ['Error']; - - return { - 'ThrowStatement': function(node) { - if (node.argument.type === 'CallExpression' && - errorList.indexOf(node.argument.callee.name) !== -1) { - context.report(node, 'Use new keyword when throwing.'); - } - } - }; -}; - -module.exports.schema = { - 'type': 'array', - 'additionalItems': { - 'type': 'string' - }, - 'uniqueItems': true -}; |