eslint-plugin-fp-ts icon indicating copy to clipboard operation
eslint-plugin-fp-ts copied to clipboard

Prefer flow to multiple maps and chains

Open thewilkybarkid opened this issue 3 years ago • 1 comments

T.map(one),
T.map(two),

and

T.map(one),
T.chain(two),

can become

T.map(flow(
  one,
  two,
)),

and

T.chain(flow(
  one,
  two,
)),

respectively to avoid working in the Task (applies to other categories too).

This applies to 1..n map optionally followed by a chain (where the total number is at least 2).

Probably a bit thorny to catch these cases, but can help readability.

Real examples

thewilkybarkid avatar Mar 24 '21 11:03 thewilkybarkid

👍

This also makes it easier to extract a function, e.g. to convert from

T.map(flow(
  one,
  two,
)),

to

const fn = flow(
  one,
  two,
);

T.map(fn),

OliverJAsh avatar Nov 15 '21 14:11 OliverJAsh