Skip to content

Commit

Permalink
Issue #476 foreach rule doesn't work for arrays in object property
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmanuelDemey committed Jun 3, 2017
1 parent 6621eee commit f294fb1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rules/foreach.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = {
create: function(context) {
return {
MemberExpression: function(node) {
if (node.object.type === 'Identifier' && node.object.name !== 'angular' && node.property.name === 'forEach') {
if (node.object.name !== 'angular' && node.property.name === 'forEach') {
context.report(node, 'You should use the angular.forEach method', {});
}
}
Expand Down
3 changes: 2 additions & 1 deletion test/foreach.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ eslintTester.run('foreach', rule, {
'angular.forEach(variable, function() {})'
].concat(commonFalsePositives),
invalid: [
{code: 'variable.forEach(function() {})', errors: [{message: 'You should use the angular.forEach method'}]}
{code: 'variable.forEach(function() {})', errors: [{message: 'You should use the angular.forEach method'}]},
{code: 'a.b.forEach(function() {})', errors: [{message: 'You should use the angular.forEach method'}]}
]
});

0 comments on commit f294fb1

Please sign in to comment.