eslint-plugin-misc

ESLint plugin

This project is maintained by iliubinskii

typescript/prefer-readonly-array

ESLint plugin / typescript/prefer-readonly-array

Disallows writable arrays.

module.exports = {
  plugins: ["misc"],
  rules: {
    "misc/typescript/prefer-readonly-array": "error"
  }
};

Examples of incorrect code

function f(x: string[]) {}
function g(x: [string]) {}
function h(x: Array<string>) {}

Examples of correct code

function f(x: readonly string[]) {}
function g(x: readonly [string]) {}
function h(x: ReadonlyArray<string>) {}