Skip to content

Commit

Permalink
tools: fix eslint isRequired
Browse files Browse the repository at this point in the history
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 9da102f commit 80cd943
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/eslint-rules/rules-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down

0 comments on commit 80cd943

Please sign in to comment.