https://github.com/stormwarning/eslint-plugin-import-sorting
π ESLint plugin to group and sort imports by module, Γ la Python isort
https://github.com/stormwarning/eslint-plugin-import-sorting
eslint-plugin isort sorting-imports
Last synced: 2 months ago
JSON representation
π ESLint plugin to group and sort imports by module, Γ la Python isort
- Host: GitHub
- URL: https://github.com/stormwarning/eslint-plugin-import-sorting
- Owner: stormwarning
- License: isc
- Created: 2019-02-21T04:55:17.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2025-01-21T04:30:29.000Z (4 months ago)
- Last Synced: 2025-03-15T19:46:49.128Z (2 months ago)
- Topics: eslint-plugin, isort, sorting-imports
- Language: TypeScript
- Homepage:
- Size: 455 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# eslint-plugin-import-sorting
Enforce a convention in the order of `import` statements, inspired by
[isort](https://timothycrosley.github.io/isort/#how-does-isort-work)βs grouping style:1. Node standard modules
2. Framework modules
3. External modules
4. Internal modules
5. Explicitly local modulesThis plugin includes an additional group for βstyleβ imports where the import
source ends in `.css` or other style format. Imports are sorted alphabetically,
except for local modules, which are sorted by the number of `.` segements in
the path first, then alphabetically.## Usage
Install the plugin, and ESLint if it is not already.
```sh
npm install --save-dev eslint eslint-plugin-import-sorting
```Include the plugin in the `plugins` key of your ESLint config and enable the
rules.```js
// eslint.config.jsimport importSortingPlugin from 'eslint-plugin-import-sorting'
export default [
{
plugins: {
'import-sorting': importSortingPlugin,
},
rules: {
'import-sorting/order': 'error',
},
},
]
```π§ Automatically fixable by the [`--fix` CLI option](https://eslint.org/docs/user-guide/command-line-interface#--fix).
| Name | Description | π§ |
| :----------------------------------------------- | :------------------------------------------ | :- |
| [order](docs/rules/order.md) | Consistently order `import` statements. | π§ |
| [specifier-order](docs/rules/specifier-order.md) | Consistently order named import specifiers. | π§ |