Skip to content

Commit

Permalink
tools: forbid template literals in assert.throws
Browse files Browse the repository at this point in the history
Extend the assert-throws-arguments custom ESLint rule to also check for
the use of template literals as a second argument to assert.throws.

PR-URL: nodejs#10301
Ref: nodejs#10282 (comment)
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
  • Loading branch information
targos committed Dec 19, 2016
1 parent 348e69c commit 7cb9813
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/eslint-rules/assert-throws-arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ function checkThrowsArguments(context, node) {
});
} else if (args.length > 1) {
const error = args[1];
if (error.type === 'Literal' && typeof error.value === 'string') {
if (error.type === 'Literal' && typeof error.value === 'string' ||
error.type === 'TemplateLiteral') {
context.report({
message: 'Unexpected string as second argument',
node: error
Expand Down

0 comments on commit 7cb9813

Please sign in to comment.