mirror of https://github.com/nodejs/node.git
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>pull/10301/head
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…
Reference in New Issue