ESLint plugin
This project is maintained by iliubinskii
ESLint plugin / sort-array
Sorts arrays.
module.exports = {
plugins: ["misc"],
rules: {
"misc/sort-array": [
"error",
{
customOrder: string[],
selector: string | string[],
sendToBottom: string,
sendToTop: string,
sortKey: string,
triggerByComment: boolean
}
]
}
};
| Option | Description | Default | | :—– | :———- | :—— |
customOrder |
Array elements with custom order | - |
selector |
AST elements to be sorted (AST selector) | "ArrayExpression" |
sendToBottom |
Array elements that should be sent to bottom | - |
sendToTop |
Array elements that should be sent to top | - |
sortKey |
Determines which object key should be used to compare objects | - |
triggerByComment |
Triggers sorting by “// @sorted” comment | true |
// @sorted
const x = [2, 1];
const x = [2, 1];
// @sorted
const y = [1, 2];