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>
This commit is contained in:
parent
348e69c89d
commit
7cb98138a9
@ -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…
x
Reference in New Issue
Block a user