mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
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 <apapirovski@mac.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user