-
-
Notifications
You must be signed in to change notification settings - Fork 412
Description
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!