You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following warning has an fixer available which transforms the code into
⚠ eslint-plugin-unicorn(no-useless-spread): Using a spread operator here creates a new array unnecessarily.
╭─[src/helpers.js:703:19]
702 │
703 │ const uniq = [...new Set(devs)];
· ───
704 │ uniq.sort();
╰────
help: `new Set(devs)` returns a new array. Spreading it into an array expression to create a new array is redundant.
This would fails as a Set has no sort(), but maybe more importantly the spread operator isn't useless as removing it produces different code as can be seen below:
> new Set([1,2,3,3]).sort()
Uncaught TypeError: (intermediate value).sort is not a function
> [...new Set([1,2,3,3])].sort()
[ 1, 2, 3 ]
> [new Set([1,2,3,3])].sort()
[ Set(3) { 1, 2, 3 } ]
The text was updated successfully, but these errors were encountered:
jelly
changed the title
no-useless-spread fixers produces broken code and flags for a false posiitve
no-useless-spread false positive when spreading a Set()
Aug 19, 2024
The following warning has an fixer available which transforms the code into
This would fails as a
Set
has nosort()
, but maybe more importantly the spread operator isn't useless as removing it produces different code as can be seen below:The text was updated successfully, but these errors were encountered: