Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: auto fix custom eslint rule for crypto-check.js #16647

Closed
Prev Previous commit
tools: auto fix custom eslint rule for crypto-check.js
Removes extra spaces ( lint-error ) + rules-utils argument check
suggestoin

Refs : #16636
  • Loading branch information
shobhitchittora committed Feb 17, 2018
commit 46206b738a1254e508944e081e9fb932493bdd8b
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