array-type
What it does
Section titled “What it does”Reports Array<T>, ReadonlyArray<T> and Readonly<T[]> written as generic types, each level of a nested one (Array<Array<number>> is two reports). The bare Array is not reported.
Why it matters
Section titled “Why it matters”Two spellings of one type make code harder to scan and search; the bracket form T[] is shorter and reads left to right.
To fix, write T[] and readonly T[].
Example
Section titled “Example”...interface F { a: 1 }...type M = A | B;let g: Array<number>, h: ReadonlyArray<string>, i: Readonly<string[]>, j: Array<number, string>, k: number[];Configuration
Section titled “Configuration”js: lint: rules: array-type: warn # off (default), warn, errorSuppress one line with sudsy-disable-next-line array-type in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| typescript-eslint | array-type |
partial | only the default array style (default and readonly options); a local type named Array is still reported |