Commit 0ae16843 authored by Michaël Zasso's avatar Michaël Zasso
Browse files

tools: add ESLint rule for assert.throws arguments

The second argument to "assert.throws" is usually a validation RegExp or
function for the thrown error. However, the function also accepts a
string and in this case it is interpreted as a message for the
AssertionError and not used for validation. It is common for people to
forget this and pass a validation string by mistake.
This new rule checks that we never pass a string literal as a second argument
to "assert.throws". Additionally, there is an option to enforce the
function to be called with at least two arguments. It is currently off
because we have many tests that do not comply with this rule.

PR-URL: https://github.com/nodejs/node/pull/10089


Reviewed-By: default avatarColin Ihrig <cjihrig@gmail.com>
Reviewed-By: default avatarTeddy Katz <teddy.katz@gmail.com>
Reviewed-By: default avatarRich Trott <rtrott@gmail.com>
parent 9366b8d9
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment