sindresorhus/eslint-plugin-unicorn

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

已关闭

#2,018 创建于 2022年12月19日

 (6 条评论) (2 个反应) (0 位负责人)JavaScript (468 个派生)user submission
bughelp wanted

仓库指标

星标
 (5,022 个星标)
PR 合并指标
 (平均合并 4小时 30分钟) (30 天内合并 26 个 PR)

描述

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>

贡献者指南