Slight rule rework

This commit is contained in:
Tim Schaub
2016-08-08 21:57:06 -06:00
parent 508750712a
commit 4778efb772
3 changed files with 26 additions and 31 deletions
+2 -3
View File
@@ -13,13 +13,12 @@ exports.rule = {
return {
CallExpression: function(expression) {
if (util.isRequireExpression(expression)) {
const ancestors = context.getAncestors();
const parent = ancestors[ancestors.length - 1];
const parent = expression.parent;
if (parent.type !== 'ExpressionStatement') {
return context.report(expression, 'Expected goog.require() to in an expression statement');
}
if (ancestors.length !== 2) {
if (parent.parent.type !== 'Program') {
return context.report(expression, 'Expected goog.require() to be at the top level');
}