tools icon indicating copy to clipboard operation
tools copied to clipboard

📎 `useShorthandArrayType` should handle read-only arrays

Open Conaclos opened this issue 3 years ago • 1 comments

Description

Summary

For now, Rome's useShorthandArrayType does not handle read-only arrays. ESLint's rule array-type handles read-only arrays.

Examples

This code:

const y: ReadonlyArray<string> = ['a', 'b'];

should be turned into:

const y: readonly string[] = ['a', 'b'];

Conaclos avatar Nov 26 '22 14:11 Conaclos

I'll take a look.

unvalley avatar Nov 29 '22 07:11 unvalley

👋 @rome/staff please triage this issue by adding one of the following labels: S-Bug: confirmed, S-Planned , S-Wishlist or umbrella

github-actions[bot] avatar Dec 13 '22 12:12 github-actions[bot]

We need to be careful with this problem here: https://github.com/rome/tools/issues/3111

xunilrj avatar Dec 13 '22 12:12 xunilrj

I guess we may not need to handle #3111 for now. My understanding is that current rome's useShorthandArrayType follows typescript-eslint's array-type (array-simple). In this case, e.g. const c: Array<() => void> = [() => {}]; is correct (it doesn't need a suggested fix). And, the current playground doesn't suggest the fix. Please comment if I'm wrong.

unvalley avatar Dec 13 '22 17:12 unvalley