From 7f1a9421c01e1a7a8342676efe7698e6c0d31f41 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Mon, 12 Feb 2018 12:31:23 +0100 Subject: [PATCH] tools: fix eslint isRequired Currently the call can lead to a TypeError with the message: `Cannot read property 'value' of undefined`. This fixes it by first checking that the first argument is truthy. PR-URL: https://github.com/nodejs/node/pull/18729 Reviewed-By: Anatoli Papirovski Reviewed-By: Benjamin Gruenbaum --- tools/eslint-rules/rules-utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/eslint-rules/rules-utils.js b/tools/eslint-rules/rules-utils.js index 2bfab1c6399ee8..0fda705fb290b7 100644 --- a/tools/eslint-rules/rules-utils.js +++ b/tools/eslint-rules/rules-utils.js @@ -8,7 +8,7 @@ * require calls. */ module.exports.isRequired = function(node, modules) { - return node.callee.name === 'require' && + return node.callee.name === 'require' && node.arguments.length !== 0 && modules.includes(node.arguments[0].value); };