Registry / testing / eslint-plugin-esm-import

eslint-plugin-esm-import

JSON →
library1.0.1jsnpmunverified

ESLint plugin (v1.0.1, 2025) enforcing explicit .js extensions in local imports, aiding migration from CommonJS to ESM. Supports ESLint v9 with flat config and leverages existing import resolvers (node, webpack, typescript) to handle alias-based imports. Configurable ignored extensions and index file patterns, with --fix auto-correction. A more powerful alternative to eslint-plugin-require-extensions, supporting resolver aliases (e.g., webpack resolve.alias, tsconfig paths).

npm install eslint-plugin-esm-import
INSTALL
IMPORT
SIG · ESLINT-PLUGIN-ESM-
E
eslint-plugin-esm-import
testingjavascriptv1.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import esmImport from 'eslint-plugin-esm-import'
const esmImport = require('eslint-plugin-esm-import')
Plugin is ESM-only; use import syntax. For ESLint v9 flat config.
rules
esmImport.configs.recommended.rules
esmImport.rules
Use configs.recommended.rules to get the rule set. Direct access to rules object is not the recommended pattern.
processors
esmImport.processors
require('eslint-plugin-esm-import').processors
Processors are available but rarely needed. Access via import only.

Shows basic setup for v1.x with ESLint v9 flat config, import, and auto-fix.

// Install: npm install --save-dev eslint-plugin-esm-import eslint@^9 eslint-plugin-import@^2.31.0 eslint-module-utils@^2.12.0 // eslint.config.js import esmImport from 'eslint-plugin-esm-import'; export default [ { plugins: { 'esm-import': esmImport }, rules: { ...esmImport.configs.recommended.rules } } ]; // source.js (before fix) import RelativeFile from './RelativeFile'; // Run: npx eslint --fix source.js // Now: import RelativeFile from './RelativeFile.js';
Debug
Known issues
breakingv1.x requires ESLint v9 and flat config; v0.0.1 supports ESLint v8 with .eslintrc.
fix
Upgrade ESLint to v9 and migrate to flat config (eslint.config.js). See eslint-plugin-esm-import README for migration.
affects: >=1.0.0
deprecatedeslint-plugin-esm-import@0.0.1 is deprecated and no longer maintained.
fix
Update to v1.0.1 with ESLint v9 config.
affects: 0.0.1
gotchaPlugin only works with ESM-style imports; CommonJS require() statements are not checked.
fix
Ensure your project uses import/export syntax. The plugin will not modify require() calls.
affects: *
gotchaAliased imports must be resolvable by configured resolver (e.g., webpack, typescript). Unresolved aliases may be ignored or cause errors.
fix
Verify that your ESLint config includes a resolver (e.g., import/resolver: { node: {}, typescript: {} }).
affects: *
Errors
Common errors & fixes
Error: Failed to load plugin 'esm-import' declared in 'plugins': Cannot find module 'eslint-plugin-esm-import'
Missing or incorrect package installation.
fix
Run: npm install --save-dev eslint-plugin-esm-import
TypeError: eslintPluginEm.flat is not a function
Using deprecated flat() API from older versions.
fix
Use default import: import esmImport from 'eslint-plugin-esm-import'; then reference esmImport.configs.recommended.
ESLint configuration error: The requested module 'eslint-plugin-esm-import' is a CommonJS module, which may not support all module.exports
Using require() to import the ESM-only plugin.
fix
Use import syntax: import esmImport from 'eslint-plugin-esm-import' in a .mjs or package.json type: module file.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
eslintrequiredPeer dep: ESLint v9 required for v1.x.
eslint-plugin-importrequiredPeer dep: used for import resolution.
eslint-module-utilsrequiredPeer dep: used for path resolution.
Agent activity
4 hits · last 30 days
node
4
Resources
eslint-plugin-esm-import — npm install eslint-plugin-esm-import · libregistry