Auto-fixable sort rules for ESLint.
npm install -D eslint-plugin-sort
yarn add -D eslint-plugin-sort
pnpm add -D eslint-plugin-sort
bun add -d eslint-plugin-sort
After installing, add sort
to your list of ESLint plugins and extend the
recommended configuration. This will enable all available rules as warnings.
Flat config (eslint.config.js)
import sort from "eslint-plugin-sort"
export default [
sort.configs["flat/recommended"],
{
rules: {
// Customize rules...
},
},
]
Legacy config (.eslintrc)
{
"extends": "plugin:sort/recommended",
"plugins": ["sort"]
}
✔: Enabled in the recommended
configuration.
🔧: Fixable with eslint --fix
.
✔ | 🔧 | Rule | Description |
---|---|---|---|
✔ | 🔧 | sort/destructuring-properties | Sorts object destructuring properties |
✔ | 🔧 | sort/exports | Sorts exports |
✔ | 🔧 | sort/export-members | Sorts export members |
✔ | 🔧 | sort/imports | Sorts imports |
✔ | 🔧 | sort/import-members | Sorts import members |
✔ | 🔧 | sort/object-properties | Sorts object properties |
🔧 | sort/type-properties | Sorts TypeScript type properties | |
🔧 | sort/string-enums | Sorts TypeScript string enums | |
🔧 | sort/string-unions | Sorts TypeScript string unions |