Browse Source

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>
v4.x
Michaël Zasso 8 years ago
committed by Myles Borins
parent
commit
9f13b5f7d5
No known key found for this signature in database GPG Key ID: 933B01F40B5CA946
  1. 3
      tools/eslint-rules/assert-throws-arguments.js

3
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

Loading…
Cancel
Save