eslint-plugin-total-functions icon indicating copy to clipboard operation
eslint-plugin-total-functions copied to clipboard

New rule: io-ts codec restrictions

Open danielnixon opened this issue 3 years ago • 5 comments

  • Prevent use of t.type unless it is nested within a t.readonly.
  • Prevent use of t.array, with fixer to t.readonlyArray.

danielnixon avatar Apr 08 '21 22:04 danielnixon

You could probably fix t.type to t.readonly(t.type(...)) too.

danielnixon avatar Apr 08 '21 22:04 danielnixon

Similarly, we likely want to enforce t.exact / t.strict to avoid issues related to unsafe decoding, smuggling extra props, etc.

danielnixon avatar Jan 09 '23 23:01 danielnixon

  • Encourage providing a value for the optional name when using t.type This makes it somewhat easier to grok errors returned from deeply nested codecs.

adamlthomas avatar Jan 18 '23 05:01 adamlthomas

If we widen the scope of this to fp-ts generally, another useful rule might be forbidding lib imports.

Good:

import { flow } from 'fp-ts/function'

Bad:

import { flow } from 'fp-ts/lib/function'

danielnixon avatar Feb 16 '23 04:02 danielnixon

Oh look, that already exists https://github.com/buildo/eslint-plugin-fp-ts/blob/main/docs/rules/no-lib-imports.md

danielnixon avatar Feb 16 '23 04:02 danielnixon