eslint-plugin-import-helpers
raw JSON → 2.0.1 verified Sat Apr 25 auth: no javascript
ESLint plugin providing configurable import ordering rules, forked from eslint-plugin-import. Current stable version is 2.0.1, supporting ESLint v9. It allows custom grouping (e.g., modules, absolute paths, parent/sibling), newlines between groups, and alphabetical sorting. Compared to eslint-plugin-import, it offers more flexible group definitions and is simpler for import sorting specifically. The maintainer recommends using Prettier instead for formatting. No frequent releases; v2 is a major bump for ESLint v9 support with no other breaking changes.
Common errors
error ESLint couldn't find the plugin "eslint-plugin-import-helpers". ↓
cause Plugin not installed or ESLint cannot resolve it.
fix
Run 'npm install eslint-plugin-import-helpers --save-dev' and ensure node_modules contains it.
error Configuration for rule "import-helpers/order-imports" is invalid. ↓
cause Invalid options object shape (e.g., missing groups array).
fix
Ensure rule options have at least a 'groups' array. Example: ["warn", { groups: ["module"] }]
error Cannot read property 'sort' of undefined ↓
cause Occurs when groups array is empty or malformed.
fix
Provide a non-empty groups array with at least one valid group (e.g., 'module').
Warnings
breaking Version 2.x requires ESLint v9. ESLint v8 not supported. ↓
fix Upgrade to ESLint v9 or use version 1.x.
deprecated The plugin is not actively maintained; maintainer recommends Prettier plugin instead. ↓
fix Consider using @ianvs/prettier-plugin-sort-imports for formatting.
gotcha TypeScript type imports (import type { X }) are not supported and may be incorrectly sorted. ↓
fix Use a separate rule or plugin for type imports, or configure group order to place type imports manually.
gotcha Regular expression groups must start with '/^' and end with '/' to be interpreted as regex; otherwise treated as module names. ↓
fix Ensure regex patterns are surrounded by '/^.../' in the groups array.
Install
npm install eslint-plugin-import-helpers yarn add eslint-plugin-import-helpers pnpm add eslint-plugin-import-helpers Imports
- order-imports wrong
eslint-plugin-import-helpers/order-importscorrectimport-helpers/order-imports (in rules config) - plugin wrong
plugins: ['import-helpers']correctplugins: ['eslint-plugin-import-helpers'] - require('eslint-plugin-import-helpers') wrong
const plugin = require('eslint-plugin-import')correctconst plugin = require('eslint-plugin-import-helpers')
Quickstart
// Install: npm install --save-dev eslint-plugin-import-helpers
// .eslintrc.js
module.exports = {
plugins: ['eslint-plugin-import-helpers'],
rules: {
'import-helpers/order-imports': [
'warn',
{
newlinesBetween: 'always',
groups: [
'module',
'/^@shared/',
['parent', 'sibling', 'index'],
],
alphabetize: { order: 'asc', ignoreCase: true },
},
],
},
};