2.2.0 • Published 9 months ago
eslint-plugin-import-sorting v2.2.0
eslint-plugin-import-sorting
Enforce a convention in the order of import statements, inspired by 
isort’s grouping style:
- Node standard modules
- Framework modules
- External modules
- Internal modules
- Explicitly local modules
This 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.
npm install --save-dev eslint eslint-plugin-import-sortingInclude the plugin in the plugins key of your ESLint config and enable the
rules.
// eslint.config.js
import importSortingPlugin from 'eslint-plugin-import-sorting'
export default [
	{
		plugins: {
			'import-sorting': importSortingPlugin,
		},
		rules: {
			'import-sorting/order': 'error',
		},
	},
]🔧 Automatically fixable by the --fix CLI option.
| Name | Description | 🔧 | 
|---|---|---|
| order | Consistently order importstatements. | 🔧 | 
| specifier-order | Consistently order named import specifiers. | 🔧 |