Sorting is attempted under limited conditions.
npm install eslint-plugin-hardsortSorting is attempted under limited conditions.
You'll first need to install ESLint:
``sh`
npm i eslint --save-dev
Next, install eslint-plugin-hardsort:
`sh`
npm install eslint-plugin-hardsort --save-dev
Add hardsort to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:
`json`
{
"plugins": ["hardsort"]
}
Then configure the rules you want to use under the rules section.
`json`
{
"rules": {
"hardsort/object-sort": [
"error",
{
"sortedOrders": ["keyNameLengthAsc"],
"functionKeyNames": ["select"],
"ignoreEnterGroup": false,
"functionValueTypes": [
"AsyncFunction",
"MethodDefinition",
"GeneratorFunction",
"FunctionExpression",
"ArrowFunctionExpression"
],
"functionKeyNamePatterns": ["^on", "^callback"]
}
],
"hardsort/jsx-attr-sort": [
"error",
{
"sortedOrders": ["keyNameLengthAsc"],
"functionKeyNames": ["select"],
"ignoreEnterGroup": true,
"functionValueTypes": [
"AsyncFunction",
"MethodDefinition",
"GeneratorFunction",
"FunctionExpression",
"ArrowFunctionExpression"
],
"functionKeyNamePatterns": ["^on", "^callback"]
}
],
"hardsort/import-grouping": [
"error",
[
{
"id": "components",
"pathPatterns": ["^./components(/.)?"]
},
{
"id": "pages",
"pathPatterns": ["^./pages(/.)?"]
},
{
"id": "default",
"sortedOrders": ["aliasAsc"]
}
],
{
"alias": {
"@": "src"
},
"orders": ["default", "pages", "components"]
}
]
}
}
🔧 Automatically fixable by the --fix` CLI option.
| Name | Description | 🔧 |
| :----------------------------------------------- | :------------------------------ | :-- |
| import-grouping | import를 그룹화하여 ì •ë¦¬í•©ë‹ˆë‹¤. | 🔧 |
| jsx-attr-sort | JSX Attributes를 ì •ë ¬í•©ë‹ˆë‹¤. | 🔧 |
| object-sort | Object를 ì •ë ¬í•©ë‹ˆë‹¤. | 🔧 |