eslint-import-resolver-babel-root-import
raw JSON → 0.0.2 verified Sat Apr 25 auth: no javascript maintenance
A resolver for eslint-plugin-import that works with babel-plugin-root-import to allow root-based module imports (e.g., importing from a root directory using a pattern). The current stable version is 1.0.0, released as a major update. This package is a thin wrapper around babel-plugin-root-import, providing an eslint resolver that understands the same root-import syntax. It has no active development. The key differentiator is enabling eslint-plugin-import to resolve modules using the babel-root-import plugin's custom prefix/suffix mappings.
Common errors
error Error: No resolver found for 'babel-root-import' ↓
cause The resolver is not installed or not referenced correctly in .eslintrc.
fix
Run
npm install --save-dev eslint-import-resolver-babel-root-import and use 'babel-root-import' in settings. error Unable to resolve path to module '~/components/Button' ↓
cause The root path mapping is not configured or babel-plugin-root-import is not set up.
fix
Configure both the resolver in .eslintrc and the plugin in your Babel config with same settings.
error Resolve error: Failed to load resolver: babel-root-import ↓
cause The package does not export the correct resolver interface for eslint-plugin-import.
fix
Check that you have the correct version (v1.0.0) and that babel-plugin-root-import is installed.
Warnings
breaking Version 1.0.0 changed the resolver name from 'eslint-import-resolver-babel-root-import' to 'babel-root-import' in settings. ↓
fix Update your .eslintrc to use the shorthand 'babel-root-import' instead of the full package name.
deprecated The babel-plugin-root-import package was renamed and is now maintained under a new repository. ↓
fix Ensure you are using the most up-to-date version of babel-plugin-root-import.
gotcha The resolver requires babel-plugin-root-import to be installed and configured separately. ↓
fix Install both packages and configure babel-plugin-root-import in your Babel config.
gotcha This resolver may not work with eslint-plugin-import versions that have breaking changes in the resolver API. ↓
fix Check compatibility with your eslint-plugin-import version; consider using the built-in eslint-import-resolver-node or eslint-import-resolver-alias.
breaking The package has very limited documentation and may break silently if dependencies are mismatched. ↓
fix Use a more robust resolver like eslint-import-resolver-alias if you need extensive support.
Install
npm install eslint-import-resolver-babel-root-import yarn add eslint-import-resolver-babel-root-import pnpm add eslint-import-resolver-babel-root-import Imports
- eslint-import-resolver-babel-root-import wrong
"settings": { "import/resolver": "eslint-import-resolver-babel-root-import" }correct"settings": { "import/resolver": "babel-root-import" } - babel-plugin-root-import
require('babel-plugin-root-import') - import/resolver object
"settings": { "import/resolver": { "babel-root-import": { "rootPathSuffix": "src" } } }
Quickstart
// .eslintrc.json
{
"settings": {
"import/resolver": {
"babel-root-import": {
"rootPathSuffix": "src",
"rootPathPrefix": "~"
}
}
}
}
// Install
npm install --save-dev eslint-plugin-import eslint-import-resolver-babel-root-import babel-plugin-root-import