eslint-plugin-functional icon indicating copy to clipboard operation
eslint-plugin-functional copied to clipboard

[prefer-readonly-type] Support Readonly<T>

Open ulrichb opened this issue 5 years ago • 7 comments

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.

ulrichb avatar Jul 29 '19 13:07 ulrichb

I'm interested in taking this on.

kevinbarabash avatar Dec 27 '19 18:12 kevinbarabash

@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

RebeccaStevens avatar Dec 28 '19 09:12 RebeccaStevens

Thanks. I'll start work on this this weekend.

kevinbarabash avatar Jan 04 '20 03:01 kevinbarabash

@kevinbarabash How you going with this?

RebeccaStevens avatar Mar 01 '20 03:03 RebeccaStevens

I ended up getting side-tracked by something else and have put my TypeScript development on hold.

kevinbarabash avatar Mar 01 '20 04:03 kevinbarabash

+1 for this. Having to put the readonly modifier before every single key decreases readability. And this rule is critical.

ColemanGariety avatar Mar 12 '20 22:03 ColemanGariety

+1

safareli avatar May 03 '20 16:05 safareli

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 avatar Oct 28 '22 16:10 adrian-gierakowski

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

RebeccaStevens avatar Oct 28 '22 23:10 RebeccaStevens