1.1.3 • Published 4 years ago
eslint-plugin-jsort v1.1.3
eslint-plugin-jsort
ESLint plugin with rules to sort imports effortlessly.
$ npm install eslint-plugin-jsortThis rule sorts & formats import declaration with a lot of flexibility using eslint --fix.
JavaScript imports are frustrating and this tries to make them a bit easier to work with. Feel free to post any issues/suggestions you might have with the plugin on the issue tracker.
Capabilities
- Sort import declarations into distinct groups by type
- Sort import declarations by "global" packages vs "local" packages
- Sort import declarations by source
- Sort imported modules (aka specifiers)
- Combine import declarations that can be combined
- Force explicit default imports
- Force single line imports
- Force explicit type imports
- Normalize import source
Supported Parsers
Installation
- Install ESLint:
$ npm i eslint --save-dev- Install the plugin
eslint-plugin-jsort:
$ npm install eslint-plugin-jsort --save-devUsage
- Add
jsortto the plugins section of your.eslintrcconfiguration file. You can omit theeslint-plugin-prefix:
{
"plugins": ["jsort"]
}- Then configure the rules you want to use under the rules section.
{
"rules": {
"jsort/sort-imports": [
"error",
{
/* `sort-imports` Additional Configuration */
}
],
"jsort/normalize-import-source": [
"error",
{
/* `normalize-import-source` Additional Configuration */
}
]
}
}- For "
sort-importsAdditional Configuration" seejsort/sort-importsdocs. - For "
normalize-import-sourceAdditional Configuration" seejsort/normalize-import-sourcedocs
Available Rules
Other Alternatives
- ESLint Builtin
sort-importsRule - eslint-plugin-simple-import-sort
- eslint-plugin-sort-imports-es6-autofix
- prettier-plugin-sort-imports
- eslint-plugin-import