Skip to content

Commit

Permalink
fix unwrap to not fail when using _.prototype.commit()
Browse files Browse the repository at this point in the history
  • Loading branch information
ganimomer committed Sep 16, 2015
1 parent 4d0b29e commit ff1ee24
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 1 addition & 5 deletions lib/rules/unwrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@ module.exports = function (context) {
return {
CallExpression: function (node) {
if (lodashUtil.isEndOfChain(node) &&
(lodashUtil.isChainable(node) || (lodashUtil.isExplicitMethodChaining(node) && !lodashUtil.isChainBreaker(node)))) {
((lodashUtil.isChainable(node) && !lodashUtil.isCallToMethod(node, 'commit')) || (lodashUtil.isExplicitMethodChaining(node) && !lodashUtil.isChainBreaker(node)))) {
context.report(node, 'Missing unwrapping at end of chain');
}
}
};
};

module.exports.schema = [
// JSON Schema for rule options goes here
];
2 changes: 2 additions & 0 deletions tests/lib/rules/unwrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ ruleTester.run('unwrap', rule, {
code: 'var x = _(a).map(f).filter(g).value()'
}, {
code: 'var x = _.chain(a).map(f).value()'
}, {
code: 'var stillWrapped = _(a).forEach(f).commit();'
}],
invalid: [{
code: 'var x = _(a).map(f);',
Expand Down

0 comments on commit ff1ee24

Please sign in to comment.