Skip to content

Commit f0ede65

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 <[email protected]> Reviewed-By: Jeremiah Senkpiel <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Roman Reiss <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Italo A. Casas <[email protected]>
1 parent 6625373 commit f0ede65

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)