Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

How to config custom root? #105

Open
phakphumi opened this issue Jul 25, 2019 · 2 comments
Open

How to config custom root? #105

phakphumi opened this issue Jul 25, 2019 · 2 comments

Comments

@phakphumi
Copy link

phakphumi commented Jul 25, 2019

I would like to use custom root, so I can import file like this import A from ‘/components/A;

Unfortunately, eslint-plugin-import can’t figure out that I mention to custom root.

I turn on import/no-relative-parent-imports.
When I import the path like import { UserContext } from '/contexts/UserContext';
It shows me an error Relative imports from parent directories are not allowed. Please either pass what you're importing through at runtime (dependency injection), move `useAuthorization.js` to same directory as `/contexts/UserContext` or consider making `/contexts/UserContext` a package.eslint(import/no-relative-parent-imports)

What did I miss? or it just can’t use like this.

.babelrc

{
  "plugins": [
    ["module-resolver", {
      "root": ["./"]
    }]
  ]
}

.eslintrc

{
  "extends": "airbnb",
  "rules": {
    "import/no-relative-parent-imports": "error"
  },
  "settings": {
    "import/resolver": {
      "babel-module": {}
    }
  }
}
@michaelnagy
Copy link

I have the same question above, I can't make it work and there's no clear example in the docs.

@michaelnagy
Copy link

I found out that the plugin in the newer versions reads config from .babelrc, as stated in this issue #95

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants