Socket
Socket
Sign inDemoInstall

eslint-plugin-import-sorting

Package Overview
Dependencies
Maintainers
0
Versions
10
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


Version published
Maintainers
0
Created
Source

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

// eslint.config.js

import importSortingPlugin from 'eslint-plugin-import-sorting'

export default [
	{
		plugins: {
			'import-sorting': importSortingPlugin,
		},
		rules: {
			'import-sorting/order': 'warn',
		},
	},
]
Legacy config example
// .eslintrc.js

module.exports = {
	plugins: ['import-sorting'],
	rules: {
		'import-sorting/order': 'warn',
	},
}

See the order rule docs for more configuration options.

Keywords

FAQs

Package last updated on 30 Aug 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc