Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New rule: io-ts codec restrictions #334

Open
danielnixon opened this issue Apr 8, 2021 · 5 comments
Open

New rule: io-ts codec restrictions #334

danielnixon opened this issue Apr 8, 2021 · 5 comments
Labels
good first issue Good for newcomers

Comments

@danielnixon
Copy link
Owner

  • Prevent use of t.type unless it is nested within a t.readonly.
  • Prevent use of t.array, with fixer to t.readonlyArray.
@danielnixon
Copy link
Owner Author

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

@danielnixon danielnixon added the good first issue Good for newcomers label Apr 9, 2021
@danielnixon
Copy link
Owner Author

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

@adamlthomas
Copy link

  • 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.

@danielnixon
Copy link
Owner Author

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
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants