eslint-plugin-importer
raw JSON → 0.3.0 verified Sat Apr 25 auth: no javascript
An ESLint plugin that provides a subset of import/export rules from eslint-plugin-import and eslint-plugin-antfu. Current stable version is v0.3.0 (supports ESLint v9 and v10). Zero dependencies, no module resolution — only focuses on import/export syntax. Active development with frequent breaking changes in minor versions due to rule renames and removals. Compared to eslint-plugin-import, it is leaner but may not support all scenarios (e.g., no Flow support since v0.2.1). Ships TypeScript types.
Common errors
error Error [ERR_REQUIRE_ESM]: require() of ES Module /node_modules/eslint-plugin-importer/dist/index.mjs not supported. ↓
cause Package is ESM-only and cannot be required() in CommonJS context.
fix
Use
import() or set type: "module" in package.json and use ESM imports. error ESLint configuration error: Config (flat) 'importer' is not a valid plugin name (missing 'plugins' entry?) ↓
cause Plugin not registered in `plugins` object when using flat config.
fix
// eslint.config.js
import importer from 'eslint-plugin-importer'
export default [
{
plugins: { importer },
rules: { 'importer/no-default-export': 'error' },
},
];
error Rule 'import/no-duplicates' is not defined in eslint-plugin-importer ↓
cause Rule name mismatch: package uses `importer/no-duplicates` not `import/no-duplicates`.
fix
Prefix rule with 'importer/', e.g., 'importer/no-duplicates'.
error Cannot find module 'eslint-plugin-importer/configs' ↓
cause Package does not export `configs` as separate module path; only named export.
fix
Use import { configs } from 'eslint-plugin-importer'.
Warnings
breaking Rule `import-dedupe` was renamed to `no-duplicates-specifier` in v0.2.0. Using old rule name will throw an error. ↓
fix Rename rule to `no-duplicates-specifier`.
breaking Rule `prefer-inline` was renamed to `preferInline` in v0.1.1. Using the old name will silently fail or cause undefined rule. ↓
fix Use `preferInline` instead.
breaking Flow support was removed in v0.2.1. Rules that depended on Flow parsing may be disabled or removed. ↓
fix Migrate to non-Flow rules or use eslint-plugin-import-x for Flow support.
gotcha The plugin does not perform module resolution; `import/no-unresolved` is not implemented. Use eslint-plugin-import-x for resolution features. ↓
fix For resolution, use `eslint-plugin-import-x`. This plugin is strictly syntax-only.
gotcha CommonJS `require()` does not work; plugin is ESM-only. Attempting `require('eslint-plugin-importer')` throws MODULE_NOT_FOUND or ERR_REQUIRE_ESM. ↓
fix Use dynamic `import()` in flat config or convert project to ESM.
Install
npm install eslint-plugin-importer yarn add eslint-plugin-importer pnpm add eslint-plugin-importer Imports
- default wrong
const importer = require('eslint-plugin-importer')correctimport importer from 'eslint-plugin-importer' - rules
import { rules } from 'eslint-plugin-importer' - configs wrong
import configs from 'eslint-plugin-importer/configs'correctimport { configs } from 'eslint-plugin-importer'
Quickstart
// eslint.config.js
export default [
{
plugins: {
importer: (await import('eslint-plugin-importer')).default,
},
rules: {
'importer/no-default-export': 'error',
'importer/no-duplicates': 'warn',
},
},
];