fix(methods): Restirct warnings on NewExpressions to Meteor.Error

Previously the rule would warn on all NewExpressions with no arguments.
This commit is contained in:
Dominik Ferber
2015-10-20 23:15:34 +02:00
parent a2144b5e43
commit addc889052
2 changed files with 7 additions and 1 deletions

View File

@@ -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

View File

@@ -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 () {})',