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

[Feature request] `prefer-readonly-array`

Open SevenOutman opened this issue 2 years ago • 0 comments

Enforces an array argument of a function to be declared as readonly if it's never mutated in the function body.

function getValues(
  items: { value: number }[]  // Should be readonly!
) {
  return items.map(item => item.value)
}

Rationale: https://x.com/leishenghao/status/1664067474097332224?s=46&t=A5GTMNUCLTkLO8tQ8jEQJA

SevenOutman avatar Oct 30 '23 15:10 SevenOutman