prefer-spread
reports on String#split('')
, fixing to a typical ...
. That matches the design of string iterability as it was originally intended. However, allowing primitives to be iterated over is widely considered a mistake: https://github.com/tc39/how-we-work/blob/main/normative-conventions.md#reject-primitives-in-iterable-taking-positions.
Proposal: can eslint-plugin-unicorn
remove the preference of String#split('')
from prefer-spread
?
const text = 'hello π';
text.split(''); // "fixed" to [...text]
I'm roughly quoting @Josh-Cena from this discussion: https://github.com/typescript-eslint/typescript-eslint/pull/8509/files#r1781707713. Context: in typescript-eslint, we're implementing typescript-eslint/typescript-eslint#748 Rule proposal: prevent array, iterable and function spreads into objects. The rule is set to report on ...string
by default... and then unicorn/prefer-spread
reports on String#split('')
. You can't win!
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too