eslint-plugin-custom-sort-imports
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

eslint-plugin-import-sorter

NPM version Build Status License: MIT

eslint-plugin-custom-sort-imports is an ESLint plugin that allow you to sort your imports according to a customizable pattern.

Features

  • Sort import statements in a custom order according to an array of regex.
  • Easily configurable via ESLint configuration file.

Installation

You can install the plugin via npm:

npm install eslint-plugin-custom-sort-imports --save-dev

yarn

yarn install -D eslint-plugin-custom-sort-imports

bun

bun install -D eslint-plugin-custom-sort-imports

Configuration

The following code snippet gives a configuration example on eslint.config.mjs. The "patterns" array holds some regex to define how to sort your imports

import .....
import pluginSortImports from "eslint-plugin-sort-imports";

export default [
  {
    plugins: {
      "eslint-plugin-custom-sort-imports": pluginSortImports
    },
    rules: {
      "eslint-plugin-custom-sort-imports/sort-imports": [
        "error",
        {
          patterns: [
            "^react$",
            "^react-.*",
            "^@tanstack/.*",
            "^@auth0/.*",
            "^zustand.*",
            "^@mantine/.*(?!.css$)$",
            "^@mantine/.*(?<!.css$)$",
            "@tabler/icons-react",
            ".*"
          ]
        }
      ],
    }
  }
];

Readme

Keywords

none

Package Sidebar

Install

npm i eslint-plugin-custom-sort-imports

Weekly Downloads

34

Version

0.1.0

License

MIT

Unpacked Size

101 kB

Total Files

7

Last publish

Collaborators

  • wsu