1. eslint-plugin-sort-imports-es6-autofix
A sort-imports rule that properly distinguishes between ES6 import types.
eslint-plugin-sort-imports-es6-autofix
Package: eslint-plugin-sort-imports-es6-autofix
Created by: schuchertmanagementberatung
Last modified: Fri, 17 Jun 2022 20:42:02 GMT
Version: 0.6.0
License: MIT
Downloads: 533,977
Repository: https://github.com/schuchertmanagementberatung/eslint-plugin-sort-imports-es6-autofix

Install

npm install eslint-plugin-sort-imports-es6-autofix
yarn add eslint-plugin-sort-imports-es6-autofix

eslint-plugin-sort-imports-es6-autofix

A sort-imports rule that properly distinguishes between ES6 import types and that is also able to autofix all detected problems.

ESLint's built-in sort-imports rule considers the following to be the same type of import:

 import foo from 'foo';
import { bar } from 'bar';

This version of the rule fixes that.

It accepts the same options as the original rule, but the multiple type corresponds to all named imports (regardless of how many are imported), while the single type corresponds only to default imports.

This rule respects whitespace and comments between imports by only looking at the order of (and sorting) consecutive import statements (those without newlines/comments in between them).

This fork also fixes the import order on eslint --fix.
To avoid problems, it will only switch out the import statements, not comments on the same line, etc.

ESLint's built-in sort-imports is only able to sort variable names inside of multiple-imports.

Usage

npm i --save-dev eslint-plugin-sort-imports-es6-autofix

 {
  "plugins": [
    "sort-imports-es6-autofix"
  ],
  "rules": {
    "sort-imports-es6-autofix/sort-imports-es6": [2, {
      "ignoreCase": false,
      "ignoreMemberSort": false,
      "memberSyntaxSortOrder": ["none", "all", "multiple", "single"]
    }]
  }
}

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code