I like the idea behind the unicorn/no-array-sort rule. When I'm dealing with plain arrays, I'd like to turn it on.
However, often I am dealing with, e.g., a Set, which I want to convert to a sorted array. In such cases, my choices are:
const sortedArray = [...mySet].sort(); // faster, but trips the linter
const sortedArray = [...mySet].toSorted(); // double allocation, but makes linter happy
I'd like to have some option, e.g. { allowAfterSpread: true }, which specifically allows the [...spreadSomething].sort() pattern.
I'm willing to give a shot at contributing this (with the help of Claude Code) if I can get some signal it'll be accepted.
I like the idea behind the unicorn/no-array-sort rule. When I'm dealing with plain arrays, I'd like to turn it on.
However, often I am dealing with, e.g., a
Set, which I want to convert to a sorted array. In such cases, my choices are:I'd like to have some option, e.g.
{ allowAfterSpread: true }, which specifically allows the[...spreadSomething].sort()pattern.I'm willing to give a shot at contributing this (with the help of Claude Code) if I can get some signal it'll be accepted.