tools: forbid template literals in assert.throws

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: https://github.com/nodejs/node/pull/10301
Ref: https://github.com/nodejs/node/pull/10282#discussion_r92607290
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>
pull/10301/head
Michaël Zasso 2016-12-16 09:34:25 +01:00
parent 348e69c89d
commit 7cb98138a9
1 changed files with 2 additions and 1 deletions

View File

@ -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