From 7cb98138a9bd5b87010c49011e281ee4c4024eec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Fri, 16 Dec 2016 09:34:25 +0100 Subject: [PATCH] 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 Reviewed-By: Jeremiah Senkpiel Reviewed-By: Colin Ihrig Reviewed-By: Roman Reiss Reviewed-By: Anna Henningsen Reviewed-By: Italo A. Casas --- tools/eslint-rules/assert-throws-arguments.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/eslint-rules/assert-throws-arguments.js b/tools/eslint-rules/assert-throws-arguments.js index 434a0ca455b471..3b51188c0c89bc 100644 --- a/tools/eslint-rules/assert-throws-arguments.js +++ b/tools/eslint-rules/assert-throws-arguments.js @@ -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