🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

eslint-plugin-import-sorting

Package Overview
Dependencies
Maintainers
0
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eslint-plugin-import-sorting

ESLint plugin to group and sort imports by module, à la Python isort

2.2.0
latest
Source
npm
Version published
Weekly downloads
57
-65.87%
Maintainers
0
Weekly downloads
 
Created
Source

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-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.

NameDescription🔧
orderConsistently order import statements.🔧
specifier-orderConsistently order named import specifiers.🔧

Keywords

eslint

FAQs

Package last updated on 21 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts