Skip to content

Commit

Permalink
tools: replace custom new-with-error rule
Browse files Browse the repository at this point in the history
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 <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>
  • Loading branch information
Trott authored and MylesBorins committed Jul 11, 2017
1 parent 19d9551 commit b2a08fb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 34 deletions.
8 changes: 5 additions & 3 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,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
operator-linebreak: [2, after, {overrides: {'?': ignore, ':': ignore}}]
Expand Down Expand Up @@ -142,7 +145,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-useless-regex-char-class-escape: [2, { override: ['[', ']'] }]

# Global scoped method and vars
Expand Down
31 changes: 0 additions & 31 deletions tools/eslint-rules/new-with-error.js

This file was deleted.

0 comments on commit b2a08fb

Please sign in to comment.