eslint-plugin-fp-ts
eslint-plugin-fp-ts copied to clipboard
ESLint rules for fp-ts
If the argument for a pipe is only referenced in the first step, it can be replaced with a `flow`: ```ts (foo) => pipe( foo, ... ) ``` and ```ts...
`foo(bar(baz))` can be `pipe(baz, bar, foo)`. (Suspect there might be quite a few gotchas implementing this one!) [Example](https://github.com/sciety/sciety/commit/3336fe71fad7f28386d7c2bd2139dbcf7aa65a37)
I've seen a few cases of `Either`, it'd be useful to have a rule to prevent these (doubt many, if any, cases are fixable though). [Example](https://github.com/sciety/sciety/commit/7d6ee1df58713bb1ba72a4cfe4ce49dac42e09e1)
`A.filter` followed by `A.last` can be `A.findLast`.
Thanks for the plugin, learnt a couple of things already with it. `O.fromPredicate((array) => array.length > 0)` could be replaced with `RNEA.fromArray`/`RNEA.fromReadonlyArray` (found a few usages in https://github.com/sciety/sciety/commit/103fe14d019960d9cc7ebd863b022f199887c02e).
Opposite to `no-module-imports`, imports from modules could be enforced. Also, the standard namespaces (`O`, `TE`, `RNEA` etc) could be enforced (eg `import * as O from "fp-ts/Option"`).
`O.of`/`O.some` followed by an `O.filter` could be replaced with `O.fromPredicate`.
`E.fold(() => O.none, (value) => O.some(value))` could be fixed with `O.fromEither` (seen https://github.com/sciety/sciety/commit/ecd230c3d794dfa994a3fb3baee10cea152ee449 recently).
First, thanks for putting together this plugin, I already found a few places in our codebase that were simplified by the usage of this so kudos! I have some suggestions...