jfmengels/eslint-plugin-lodash-fp

`prefer-composition` rule

Open

#4 opened on Apr 14, 2016

View on GitHub
 (0 comments) (1 reaction) (0 assignees)JavaScript (24 forks)github user discovery
enhancementhelp wanted

Repository metrics

Stars
 (150 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Use composition methods (_.compose, _.flow, ...) instead of chaining multiple map/filter/reduce/... array methods

a.map(fn1).filter(fn2).every(fn3);
// -->
_.flow(_.map(fn1), _.filter(fn2), _.every(fn3))(a);
// or
_.compose(_.every(fn3), _.filter(fn2), _.map(fn1))(a);

In the documentation, there should be a section saying that this should probably not be used with projects that use Observables, as it will create a lot of false positives.

Contributor guide