eslint-plugin-functional
eslint-plugin-functional copied to clipboard
[prefer-readonly-type] Support Readonly<T>
Support the following case (at the moment functional/prefer-readonly-type
gets emitted):
type MyType = Readonly<{ a: string, b: number }>;
This is a prerequisite for #32 (which is about a fixer to Readonly<T>
if I understand it correctly); but the validation can implemented before.
I'm interested in taking this on.
@kevinbarabash it's yours 😄.
Edit: removed the rest of this comment as it was irrelevant to this issue. Moved it to here: https://github.com/jonaskello/eslint-plugin-functional/issues/32#issuecomment-569416066
Thanks. I'll start work on this this weekend.
@kevinbarabash How you going with this?
I ended up getting side-tracked by something else and have put my TypeScript development on hold.
+1 for this. Having to put the readonly
modifier before every single key decreases readability. And this rule is critical.
+1
Just wanted to point out that https://typescript-eslint.io/rules/prefer-readonly-parameter-types works with Readonly
as well as ReadonlyDeep
from https://github.com/sindresorhus/type-fest, so maybe we could borrow from it's implementation
@adrian-gierakowski I've actually been working over there helping with that rule. I've also since extracted out the relevant bits and improved upon them in a new lib called is-immutable-type. v5 of this lib (currently in beta) uses that library and resolves this issue.