eslint-plugin-fast-import
raw JSON → 2.2.1 verified Sat Apr 25 auth: no javascript
An ESLint plugin for validating imports and exports, leveraging a novel algorithm with the OXC Rust-based parser for high performance. Current stable version is 2.2.1, with a rapid release cadence. It offers an editor mode that keeps in-memory data structures updated with filesystem changes, preventing stale errors. Unlike eslint-plugin-import and eslint-plugin-import-x, it does not support user-supplied resolvers and only analyzes first-party code within rootDir. It includes rules like no-cycle, no-entry-point-imports, no-external-barrel-reexports, and no-named-as-default. Requires ESLint >= 9.0.0 and ESM-only codebases.
Common errors
error Error: Cannot find module 'eslint-plugin-fast-import' ↓
cause Package not installed or missing from dependencies.
fix
Run 'npm install --save-dev eslint-plugin-fast-import' and ensure it's in package.json.
error ESLint couldn't determine the plugin 'fast-import' uniquely. ↓
cause Multiple versions or conflicting names in plugins object.
fix
Use a unique key, e.g., plugins: { 'fast-import': fastImport }.
error Configuration for rule "fast-import/no-cycle" is invalid: Value "warn" is not allowed. ↓
cause Rule severity must be 'off', 'warn', or 'error', or an array.
fix
Set rule to 'error', 'warn', 'off', or ['warn', { ... }].
error TypeError: Cannot read properties of undefined (reading 'rootDir') ↓
cause fast-import settings not defined or rootDir missing.
fix
Add settings: { 'fast-import': { rootDir: __dirname } } to ESLint config.
Warnings
breaking Version 2.0.0 dropped support for ESLint <= 8 and CommonJS. Flat config and ESM are required. ↓
fix Upgrade to ESLint 9+ and use flat config with ESM imports.
gotcha rootDir setting is required; all first-party code must reside under rootDir. Files outside are not analyzed. ↓
fix Set rootDir to the root of your project (e.g., path.resolve(__dirname, 'src')).
gotcha CommonJS (require, module.exports) is not supported. Only ESM import/export syntax is analyzed. ↓
fix Convert your codebase to ESM syntax.
gotcha Barrel re-exports of third-party modules are ignored; rules like no-external-barrel-reexports only apply to first-party code. ↓
fix For third-party re-exports, manually check or use a different plugin.
deprecated The 'all' configuration is deprecated in v2; use 'recommended' and opt-in to additional rules individually. ↓
fix Switch to configs.recommended and add extra rules as needed.
Install
npm install eslint-plugin-fast-import yarn add eslint-plugin-fast-import pnpm add eslint-plugin-fast-import Imports
- default wrong
const fastImport = require('eslint-plugin-fast-import')correctimport fastImport from 'eslint-plugin-fast-import' - rules wrong
import { noCycle } from 'eslint-plugin-fast-import'correctimport { rules } from 'eslint-plugin-fast-import' - configs wrong
import recommended from 'eslint-plugin-fast-import'correctimport { configs } from 'eslint-plugin-fast-import' - getESMInfo
import { getESMInfo } from 'eslint-plugin-fast-import'
Quickstart
// Install: npm install --save-dev eslint-plugin-fast-import
// eslint.config.js (flat config)
import fastImport from 'eslint-plugin-fast-import';
export default [
{
plugins: { 'fast-import': fastImport },
rules: {
'fast-import/no-cycle': 'error',
'fast-import/no-entry-point-imports': 'error',
'fast-import/no-external-barrel-reexports': 'error',
'fast-import/no-named-as-default': 'error',
},
settings: {
'fast-import': {
rootDir: __dirname, // required
alias: { '@': './src' },
mode: process.env.CI ? 'build' : 'editor',
},
},
},
];