agiledigital-labs / agiledigital-labs/eslint-plugin-total-functions

[no-unsafe-mutable-readonly-assignment] make exception for array concat parameter `ConcatArray`

オープン
#132 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
good first issue help wanted
主要言語
TypeScript
スター
92
フォーク
5
PR マージ指標
30日以内にマージされた PR はありません

説明

_NB this issue is distinct from (but related to) #100. That issue is about the return type, this is about the parameter type._

Concatenating a mutable array to another array is currently flagged by `no-unsafe-mutable-readonly-assignment`:

```ts
const arr: Array = [""];
const foo: Array = arr.concat(arr); // Flagged by no-unsafe-mutable-readonly-assignment
```

This is strictly correct, because `concat` takes a `ConcatArray` type that has **readonly** length and number index properties:

```ts
interface ConcatArray {
readonly length: number;
readonly [n: number]: T;
join(separator?: string): string;
slice(start?: number, end?: number): T[];
}
```

Even though this is correct (at least strictly speaking) it's not useful, because it cannot lead to surprising mutation in any readonly values.

We should treat this as a special case and ignore it in the `no-unsafe-mutable-readonly-assignment` rule.

**Bonus points**: are there any other methods (especially on the array type) that we should ignore for the same reason?

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。