Socket
Socket
Sign inDemoInstall

eslint-plugin-simple-import-sort

Package Overview
Dependencies
88
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    eslint-plugin-simple-import-sort

Easy autofixable import sorting


Version published
Weekly downloads
2.1M
increased by3.43%
Maintainers
1
Install size
37.3 kB
Created
Weekly downloads
 

Package description

What is eslint-plugin-simple-import-sort?

The eslint-plugin-simple-import-sort package is an ESLint plugin that automatically sorts import statements in your JavaScript and TypeScript files. It helps in maintaining a consistent order of imports, making the codebase easier to read and maintain. It can sort imports alphabetically, group and separate different types of imports, and remove duplicate imports.

What are eslint-plugin-simple-import-sort's main functionalities?

Sorting import statements

This feature automatically sorts import statements alphabetically and groups them. After running ESLint with this plugin, the imports would be sorted as follows: import React from 'react'; import z from 'zoo'; import { a, b } from 'alphabet'; import { c as cat, d as dog } from 'animals';

import React from 'react';
import { b, a } from 'alphabet';
import z from 'zoo';
import { d as dog, c as cat } from 'animals';

Grouping and separating imports

This feature groups and separates imports by their origin. Built-in modules, external modules, internal modules, and local modules are grouped together and separated by a blank line. After sorting, the imports would be grouped as follows: import fs from 'fs'; import path from 'path'; import React from 'react'; import myLocalModule from './myLocalModule';

import fs from 'fs';
import path from 'path';
import myLocalModule from './myLocalModule';
import React from 'react';

Removing duplicate imports

This feature detects and removes duplicate import statements. After running ESLint with this plugin, only one import statement will remain: import { a } from 'module';

import { a } from 'module';
import { a } from 'module';

Other packages similar to eslint-plugin-simple-import-sort

Changelog

Source

Version 12.1.0 (2024-04-13)

This release adds TypeScript type definitions for the plugin itself. This is useful when you use TypeScript to check your ESLint configuration. It assumes that you install @types/eslint yourself. Thanks to @Logicer16!

Readme

Source

eslint-plugin-simple-import-sort

Easy autofixable import sorting.

  • ✅️ Runs via eslint --fix – no new tooling
  • ✅️ Also sorts exports where possible
  • ✅️ Handles comments
  • ✅️ Handles type imports/exports
  • ✅️ TypeScript friendly (via @typescript-eslint/parser)
  • ✅️ Prettier friendly
  • ✅️ dprint friendly (with configuration)
  • ✅️ eslint-plugin-import friendly
  • ✅️ git diff friendly
  • ✅️ 100% code coverage
  • ✅️ No dependencies
  • Does not support require

This is for those who use eslint --fix (autofix) a lot and want to completely forget about sorting imports!

Example

➡️ Full readme

Keywords

FAQs

Last updated on 13 Apr 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc