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 <[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]>
  • Loading branch information
targos authored and cjihrig committed Dec 20, 2016
1 parent 67c2930 commit be6d362
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 be6d362

Please sign in to comment.