Suggest replacing the combination of map
(or mapWithIndex
) followed by
sequence
with traverse
(or traverseWithIndex
).
💡 Fixable: This rule provides in-editor suggested fixes.
Examples of incorrect code for this rule:
import { pipe } from "fp-ts/pipeable";
import { map, sequence } from "fp-ts/Array";
import { option, some } from "fp-ts/Option";
pipe(
[1, 2, 3],
map((n) => some(n)),
sequence(option)
);
import { pipe } from "fp-ts/pipeable";
import { mapWithIndex, sequence } from "fp-ts/Array";
import { option, some } from "fp-ts/Option";
pipe(
[1, 2, 3],
mapWithIndex((i) => some(i)),
sequence(option)
);
Examples of correct code for this rule:
import { pipe } from "fp-ts/pipeable";
import { traverse } from "fp-ts/Array";
import { option, some } from "fp-ts/Option";
pipe(
[1, 2, 3],
traverse(option)((n) => some(n))
);
import { pipe } from "fp-ts/pipeable";
import { traverseWithIndex } from "fp-ts/Array";
import { option, some } from "fp-ts/Option";
pipe(
[1, 2, 3],
traverseWithIndex(option)((i) => some(i))
);