Exciting release!Introducing "safe npm". Learn more
Socket
Log inDemoInstall

eslint-import-resolver-root-import

Package Overview
Dependencies
2
Maintainers
1
Versions
5
Issues
File Explorer

Advanced tools

eslint-import-resolver-root-import

Babel Plugin Root Import ESLint resolver.

    1.0.4latest
    Github

Version published
Maintainers
1
Weekly downloads
910
increased by12.62%

Weekly downloads

Readme

Source

Babel Plugin Root Import ESLint resolver

npm

Babel Plugin Root Import ESLint resolver.

This is a fork of eslint-import-resolver-babel-root-import that works with latest version of Babel using babel.config.js for configaration.

Installation

yarn add eslint-plugin-import eslint-import-resolver-root-import

Usage

Inside your .eslintrc file, pass this resolver to eslint-plugin-import:

"settings": { "import/resolver": "root-import" }

And see [babel-plugin-root-import] to know how to configure your prefix/suffix.

Configuration will be parsed down from babel.config.js file.

Configuration

This plugin accept all configurations that eslint-import-resolver-node accepts plus rootPathSuffix and rootPathPrefix.

Both rootPathSuffix and rootPathPrefix are fetched by default from your babel.config.js, but if you prefer you can define these values inside .eslintrc.

Example

{ "extends": "airbnb", "rules": {}, "settings": { "import/resolver": { "root-import": { "rootPathPrefix": "~", "rootPathSuffix": "src/js", "extensions": [".js", ".android.js", ".ios.js"] } } } }

In this case we are using .android.js and .ios.js in our extensions so in React Native we can import files like:

import MyComponent from '~/components/MyComponent';

And it will resolve to components/MyComponent/index.android.js or components/MyComponent/index.ios.js;

License

MIT, see LICENSE.md for details.

Keywords

FAQs

Last updated on 29 May 2019

Did you know?

Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.

Install Socket
Socket
support@socket.devSocket SOC 2 Logo

Product

  • Package Issues
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc