Implement JavaScript equivalent to ESLint require-array-sort-compare
#7950
OIRNOIR
started this conversation in
Rule suggestion
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
It would be cool if we could implement something similar or identical to ESLint's require-array-sort-compare, which warns against calling
.sort()(with no arguments) on an array that is not an array of strings. This warning is desired because calling.sort()on an array of non-strings may lead to undesired effects due to the way JS converts items to strings and sorts by ASCII on non-string arrays.Consider this example, where we try to sort an array of numbers:
We should allow projects to use biome to warn or error against this kind of thing.
Beta Was this translation helpful? Give feedback.
All reactions