tools: add ESLint rule for assert.throws arguments · nodejs/node@c801de9 · GitHub
Skip to content

Commit c801de9

Browse files
targosMylesBorins
authored andcommitted
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: #10089 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 96ca40b commit c801de9

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

.eslintrc

Lines changed: 1 addition & 0 deletions
Lines changed: 59 additions & 0 deletions

0 commit comments

Comments
 (0)