From addc889052c25ffee3d8883ce0c021b7057b31f7 Mon Sep 17 00:00:00 2001 From: Dominik Ferber Date: Tue, 20 Oct 2015 23:15:34 +0200 Subject: [PATCH] fix(methods): Restirct warnings on NewExpressions to Meteor.Error Previously the rule would warn on all NewExpressions with no arguments. --- lib/rules/methods.js | 7 ++++++- tests/lib/rules/methods.js | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/rules/methods.js b/lib/rules/methods.js index 1cb0245880..075087f042 100644 --- a/lib/rules/methods.js +++ b/lib/rules/methods.js @@ -8,7 +8,7 @@ import {NON_METEOR} from '../util/environment' import {getExecutors} from '../util' -import {isMeteorCall, getPropertyName, refersTo, hasContext} from '../util/ast' +import {isMeteorCall, isMeteorProp, getPropertyName, refersTo, hasContext} from '../util/ast' // ----------------------------------------------------------------------------- // Rule Definition @@ -117,6 +117,11 @@ module.exports = getMeta => context => { return { NewExpression: function (node) { + + if (!isMeteorProp(node.callee, 'Error')) { + return + } + const executors = getExecutors(env, context.getAncestors()) if (executors.size === 0) { return diff --git a/tests/lib/rules/methods.js b/tests/lib/rules/methods.js index 3f131d020c..76fdb05f99 100644 --- a/tests/lib/rules/methods.js +++ b/tests/lib/rules/methods.js @@ -14,6 +14,7 @@ const rule = require('../../../dist/rules/methods') const RuleTester = require('eslint').RuleTester const commonValidCode = [ + 'new Meteor.foo()', 'Meteor.call("foo")', 'Meteor.call("foo", true)', 'Meteor.apply("foo", [], function () {})',