unicorn/no-array-sort
eslint-plugin-unicorn
Suggestion
eslint.config.js
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/no-array-sort": "error",
},
},
];const sorted = [...array].sort();const sorted = [...iterable].sort();const sorted = [...array].sort((a, b) => a - b);const sorted = array.toSorted();const sorted = [...iterable].toSorted();const sorted = array.toSorted((a, b) => a - b);Examples from the ESLint documentation.
unicorn/no-array-sort
eslint-plugin-unicorn
import unicorn from "eslint-plugin-unicorn";
export default [
{
plugins: { unicorn },
rules: {
"unicorn/no-array-sort": "error",
},
},
];unicorn/no-array-sort
unicorn plugin · suspicious
{
"rules": {
"unicorn/no-array-sort": "error"
}
}Biome does not have this rule.
Prefer Array#toReversed() over Array#reverse().
Disallow the use of objects as default parameters.
Disallow using the this argument in array methods.
Disallow assigning this to a variable.
Disallow using reference values as Array#fill() values.
Disallow comparing undefined using typeof.