Skip to content

Latest commit

 

History

History
38 lines (27 loc) · 1.01 KB

consistent-compose.md

File metadata and controls

38 lines (27 loc) · 1.01 KB

Enforce a consistent composition method

It can be pretty confusing to mix left to right and right to left composition methods. This rule enforces the use of a consistent single method to compose functions, among the following:

Options

The rule takes one option, a string, which is either "flow", "pipe", "compose" or "flowRight". The option is mandatory.

You can set the option in configuration like this:

"lodash-fp/consistent-compose": ["error", "flow"]

Fail

import _, {pipe, compose} from 'lodash/fp';

/* eslint lodash-fp/consistent-compose: ["error", "flow"] */
pipe(fn1, fn2)(x);
compose(fn1, fn2)(x);
_.pipe(fn1, fn2)(x);
_.compose(fn1, fn2)(x);
_.flowRight(fn1, fn2)(x);

Pass

import _, {flow} from 'lodash/fp';

/* eslint lodash-fp/consistent-compose: ["error", "flow"] */
flow(fn1, fn2)(x);
_.flow(fn1, fn2)(x);