Skip to content

Commit 8191af5

Browse files
committed
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: #12249 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Teddy Katz <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]>
1 parent a37273c commit 8191af5

File tree

2 files changed

+5
-34
lines changed

2 files changed

+5
-34
lines changed

.eslintrc.yaml

+5-3
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,11 @@ rules:
106106
message: "setTimeout() must be invoked with at least two arguments."
107107
}, {
108108
selector: "CallExpression[callee.name='setInterval'][arguments.length<2]",
109-
message: "setInterval() must be invoked with at least 2 arguments"
110-
}]
109+
message: "setInterval() must be invoked with at least 2 arguments."
110+
}, {
111+
selector: "ThrowStatement > CallExpression[callee.name=/Error$/]",
112+
message: "Use new keyword when throwing an Error."
113+
}]
111114
no-tabs: 2
112115
no-trailing-spaces: 2
113116
one-var-declaration-per-line: 2
@@ -141,7 +144,6 @@ rules:
141144
align-multiline-assignment: 2
142145
assert-fail-single-argument: 2
143146
assert-throws-arguments: [2, { requireTwo: false }]
144-
new-with-error: [2, Error, RangeError, TypeError, SyntaxError, ReferenceError]
145147
no-unescaped-regexp-dot: 2
146148

147149
# Global scoped method and vars

tools/eslint-rules/new-with-error.js

-31
This file was deleted.

0 commit comments

Comments
 (0)