sindresorhus/eslint-plugin-unicorn

`no-useless-spread` False positive with iterator helpers

クローズ

#2,018 opened on 2022/12/19

 (6 件のコメント) (2 件のリアクション) (0 人の担当者)JavaScript (468 件のフォーク)user submission
bughelp wanted

Repository metrics

Stars
 (5,022 個のスター)
PR merge metrics
 (平均マージ 1d 16h) (30d で 399 merged PRs)

説明

When using a polyfill for TC39 Iterator Helpers, trying to convert a generator produced by one of the helpers to an array via the spread operator, results in said spread operator being marked as useless.

Rule effected: unicorn/no-useless-spread

Example:

const data = new Map([["a", 1], ["b", 2], ["c", 3]]);
const foo = [...data.values().map((d) => d * 2)]; // [2, 4, 6]

is incorrectly flagged and fixed to:

const data = new Map([["a", 1], ["b", 2], ["c", 3]]);
const foo = data.values().map((d) => d * 2); // Generator<number, void, undefined>

コントリビューターガイド