Skip to content

πŸ”Œ ESLint plugin to group and sort imports by module, Γ  la Python isort

License

Notifications You must be signed in to change notification settings

stormwarning/eslint-plugin-import-sorting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

97f276f Β· Dec 19, 2024

History

50 Commits
Dec 19, 2024
Apr 29, 2024
Dec 12, 2023
Dec 13, 2024
Dec 19, 2024
Dec 19, 2024
Dec 19, 2024
Dec 19, 2024
Jan 18, 2024
Dec 19, 2024
Jan 19, 2024
Dec 13, 2024
Dec 19, 2024
Dec 19, 2024
Aug 30, 2024
Dec 19, 2024

Repository files navigation

eslint-plugin-import-sorting

Enforce a convention in the order of import statements, inspired by isort’s grouping style:

  1. Node standard modules
  2. Framework modules
  3. External modules
  4. Internal modules
  5. 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-sorting

Include 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 import statements. πŸ”§
specifier-order Consistently order named import specifiers. πŸ”§