Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

📎 useShorthandArrayType should handle read-only arrays #3864

Closed
Conaclos opened this issue Nov 26, 2022 · 4 comments · Fixed by #3954
Closed

📎 useShorthandArrayType should handle read-only arrays #3864

Conaclos opened this issue Nov 26, 2022 · 4 comments · Fixed by #3954
Assignees
Labels
A-Linter Area: linter enhancement New feature request or improvement to existing functionality good first issue Good for newcomers task A task, an action that needs to be performed

Comments

@Conaclos
Copy link
Contributor

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 Conaclos added the task A task, an action that needs to be performed label Nov 26, 2022
@ematipico ematipico added enhancement New feature request or improvement to existing functionality A-Linter Area: linter good first issue Good for newcomers labels Nov 28, 2022
@unvalley
Copy link
Contributor

I'll take a look.

@github-actions
Copy link

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

@xunilrj
Copy link
Contributor

xunilrj commented Dec 13, 2022

We need to be careful with this problem here: #3111

@ematipico ematipico removed the S-Stale label Dec 13, 2022
@unvalley
Copy link
Contributor

unvalley commented Dec 13, 2022

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Linter Area: linter enhancement New feature request or improvement to existing functionality good first issue Good for newcomers task A task, an action that needs to be performed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants