Skip to content

Commit ff1ee24

Browse files
committed
fix unwrap to not fail when using _.prototype.commit()
1 parent 4d0b29e commit ff1ee24

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

lib/rules/unwrap.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,9 @@ module.exports = function (context) {
1313
return {
1414
CallExpression: function (node) {
1515
if (lodashUtil.isEndOfChain(node) &&
16-
(lodashUtil.isChainable(node) || (lodashUtil.isExplicitMethodChaining(node) && !lodashUtil.isChainBreaker(node)))) {
16+
((lodashUtil.isChainable(node) && !lodashUtil.isCallToMethod(node, 'commit')) || (lodashUtil.isExplicitMethodChaining(node) && !lodashUtil.isChainBreaker(node)))) {
1717
context.report(node, 'Missing unwrapping at end of chain');
1818
}
1919
}
2020
};
2121
};
22-
23-
module.exports.schema = [
24-
// JSON Schema for rule options goes here
25-
];

tests/lib/rules/unwrap.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ ruleTester.run('unwrap', rule, {
2020
code: 'var x = _(a).map(f).filter(g).value()'
2121
}, {
2222
code: 'var x = _.chain(a).map(f).value()'
23+
}, {
24+
code: 'var stillWrapped = _(a).forEach(f).commit();'
2325
}],
2426
invalid: [{
2527
code: 'var x = _(a).map(f);',

0 commit comments

Comments
 (0)