diff --git a/lib/rules/audit-argument-checks.js b/lib/rules/audit-argument-checks.js index 2ee83fe116..e2b5dcd53c 100644 --- a/lib/rules/audit-argument-checks.js +++ b/lib/rules/audit-argument-checks.js @@ -55,12 +55,14 @@ module.exports = function (context) { CallExpression: (node) => { if ( node.callee.type === 'MemberExpression' && - !node.callee.computed && node.callee.object.type === 'Identifier' && node.callee.object.name === 'Meteor' ) { // publications - if (node.callee.property.name === 'publish') { + if ( + (node.callee.property.type === 'Identifier' && node.callee.property.name === 'publish') || + (node.callee.property.type === 'Literal' && node.callee.property.value === 'publish') + ) { if (node.arguments.length < 2) { return; } @@ -69,7 +71,10 @@ module.exports = function (context) { } // method - if (node.callee.property.name === 'methods') { + if ( + (node.callee.property.type === 'Identifier' && node.callee.property.name === 'methods') || + (node.callee.property.type === 'Literal' && node.callee.property.value === 'methods') + ) { if ( node.arguments.length > 0 && node.arguments[0].type === 'ObjectExpression' diff --git a/tests/lib/rules/audit-argument-checks.js b/tests/lib/rules/audit-argument-checks.js index 87aae45824..9cd80d44e6 100644 --- a/tests/lib/rules/audit-argument-checks.js +++ b/tests/lib/rules/audit-argument-checks.js @@ -32,6 +32,7 @@ ruleTester.run('audit-argument-checks', rule, { 'Meteor.methods()', 'Meteor.methods({ x: function () {} })', + 'Meteor["methods"]({ x: function () {} })', 'Meteor.methods({ x: true })', {code: 'Meteor.methods({ x () {} })', parser: 'babel-eslint'}, 'Meteor.methods({ x: function (bar) { check(bar, Match.Any); } })', @@ -46,6 +47,13 @@ ruleTester.run('audit-argument-checks', rule, { type: 'Identifier' }] }, + { + code: 'Meteor["publish"]("foo", function (bar) { foo(); })', + errors: [{ + message: 'bar is not checked', + type: 'Identifier' + }] + }, { code: 'Meteor.publish("foo", function (bar) {})', errors: [{