This plugin sorts your typescript and interfaces in a custom defined order.
References:
yarn add -D eslint-plugin-typescript-custom-sort-keys
{
"plugins": ["typescript-custom-sort-keys"]
}
Then configure the rules you want to use under the rules section.
displayFirst: Define array of fields that you want to show on top
showFunctionsAtEnd: keep it true if you want to show your functions in end
{
"rules": {
"typescript-custom-sort-keys/interface": [
"warn",
"asc",
{
"caseSensitive": true,
"displayFirst": ["id"],
"showFunctionsAtEnd": true,
},
],
}
}
Before | After |
---|---|