Skip to content

Commit 7cb9813

Browse files
committed
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: #10301 Ref: #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>
1 parent 348e69c commit 7cb9813

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tools/eslint-rules/assert-throws-arguments.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ function checkThrowsArguments(context, node) {
2121
});
2222
} else if (args.length > 1) {
2323
const error = args[1];
24-
if (error.type === 'Literal' && typeof error.value === 'string') {
24+
if (error.type === 'Literal' && typeof error.value === 'string' ||
25+
error.type === 'TemplateLiteral') {
2526
context.report({
2627
message: 'Unexpected string as second argument',
2728
node: error

0 commit comments

Comments
 (0)