Open FlorianWendelborn opened 3 years ago
I agree, because Interfaces with numbers also do not sort correctly.
This:
export interface RankCount {
rank1: number;
rank2To5: number;
rank6To10: number;
rank11To20: number;
rank21To50: number;
rank51Plus: number;
}
Gets incorrectly sorted to this:
export interface RankCount {
rank1: number;
rank11To20: number;
rank21To50: number;
rank2To5: number;
rank51Plus: number;
rank6To10: number;
}
Allowing a custom sort function would help.
I am now using the amazing eslint-plugin-perfectionist for the same purpose.
It has alphabetical or natural sorting. Sorts everything; Interfaces, Objects, ect. Handles comments and more gracefully. Also very configurable to your exact needs.
Currently,
gets sorted because
_
is considered to be afterS
. This unfortunately clashes with expectations and with other sorting extensions.IMO, the most sustainable solution would be to allow passing a custom
Array.prototype.sort
callback as an option in the rule. Then, users can configure it exactly as they wish.