sonarjs/no-alphabetical-sort
eslint-plugin-sonarjs
SuggestionRecommended
eslint.config.js
export default [
{
rules: {
"sonarjs/no-alphabetical-sort": "error",
},
},
];"Array.prototype.sort()" and "Array.prototype.toSorted()" should use a compare function
var myarray = [80, 3, 9, 34, 23, 5, 1];
myarray.sort();
console.log(myarray); // outputs: [1, 23, 3, 34, 5, 80, 9]var myarray = [80, 3, 9, 34, 23, 5, 1];
myarray.sort((a, b) => (a - b));
console.log(myarray); // outputs: [1, 3, 5, 9, 23, 34, 80]Examples from the ESLint documentation.
sonarjs/no-alphabetical-sort
eslint-plugin-sonarjs
export default [
{
rules: {
"sonarjs/no-alphabetical-sort": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
All branches in a conditional structure should not have exactly the same implementation
Angular built-in sanitization should not be disabled
"new" should only be used with functions and classes
"for" loop increment clauses should modify the loops' counters