Skip to content

Commit

Permalink
fix collection-return bug with arrow functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ganimomer committed Dec 29, 2015
1 parent 7ec9360 commit 212b7f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/rules/collection-return.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ module.exports = function (context) {
if (last) {
last.found = true;
}
},
'CallExpression:exit': function (node) {
var last = _.last(callStack);
if (last && last.node === node) {
callStack.pop();
}
}
};
};
6 changes: 5 additions & 1 deletion tests/lib/rules/collection-return.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ ruleTester.run('collection-return', rule, {
},
'_.map(arr, function(a) {return a.some(function(x) {})})',
'_(a).transform(function(acc, item) {acc[item] = f(item);}, {}).mapValues(g).value()',
'function x(a) {return a;}'
'function x(a) {return a;}',
{
code: 'y = _.reject(x, p => p); _.forEach(t, s => {}).value();',
ecmaFeatures: {arrowFunctions: true}
}
],
invalid: [{
code: '_.map(arr, function(a) {console.log(a)})',
Expand Down

0 comments on commit 212b7f2

Please sign in to comment.