★ wanayoo — archive 1999 https://github.com/nodejs/node/commit/ae3398aad6Nouvelle recherche | Portail wanayoo
Skip to content
Permalink
Browse files
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: #18729
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
  • Loading branch information
BridgeAR authored and MylesBorins committed Feb 21, 2018
1 parent 8e39c3b commit ae3398aad69ff8e65ba4abc5de25bccaf0c72b8e
Showing with 1 addition and 1 deletion.
  1. +1 −1 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);
};

0 comments on commit ae3398a

Please sign in to comment.