summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.eslintrc.yaml8
-rw-r--r--tools/eslint-rules/new-with-error.js31
2 files changed, 5 insertions, 34 deletions
diff --git a/.eslintrc.yaml b/.eslintrc.yaml
index f4809c0fc9..07ef483c3f 100644
--- a/.eslintrc.yaml
+++ b/.eslintrc.yaml
@@ -106,8 +106,11 @@ rules:
message: "setTimeout() must be invoked with at least two arguments."
}, {
selector: "CallExpression[callee.name='setInterval'][arguments.length<2]",
- message: "setInterval() must be invoked with at least 2 arguments"
- }]
+ message: "setInterval() must be invoked with at least 2 arguments."
+ }, {
+ selector: "ThrowStatement > CallExpression[callee.name=/Error$/]",
+ message: "Use new keyword when throwing an Error."
+ }]
no-tabs: 2
no-trailing-spaces: 2
one-var-declaration-per-line: 2
@@ -141,7 +144,6 @@ rules:
align-multiline-assignment: 2
assert-fail-single-argument: 2
assert-throws-arguments: [2, { requireTwo: false }]
- new-with-error: [2, Error, RangeError, TypeError, SyntaxError, ReferenceError]
no-unescaped-regexp-dot: 2
# Global scoped method and vars
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
-};