Skip to content

Commit

Permalink
tools: auto fix custom eslint rule for crypto-check.js
Browse files Browse the repository at this point in the history
Removes extra spaces ( lint-error ) + rules-utils argument check
suggestoin

Refs : #16636
  • Loading branch information
shobhitchittora committed Feb 17, 2018
1 parent 1018b5b commit 46206b7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/parallel/test-eslint-crypto-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ new RuleTester().run('crypto-check', rule, {
'require("crypto")'
},
{
code: 'require("common")\n' +
code: 'require("common")\n' +
'if (common.foo) {}\n' +
'require("crypto")',
errors: [{ message }],
Expand Down
3 changes: 2 additions & 1 deletion tools/eslint-rules/rules-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ module.exports.isRequired = function(node, modules) {
var commonModuleRegExp = new RegExp(/^(\.\.\/)*common(\.js)?$/);
module.exports.isCommonModule = function(node) {
return node.callee.name === 'require' &&
commonModuleRegExp.test(node.arguments[0].value);
node.arguments.length !== 0 &&
commonModuleRegExp.test(node.arguments[0].value);
};

/**
Expand Down

0 comments on commit 46206b7

Please sign in to comment.