Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-extraneous-dependencies should not complain when importing file from project name #541

Closed
alexmngn opened this issue Sep 4, 2016 · 5 comments

Comments

@alexmngn
Copy link

alexmngn commented Sep 4, 2016

Hi,
I have a React-native project named "MyProject".
When I import a file from 'MyProject/src/store' (which is valid with react-native, which is the way to load something from the root of the project), it complains.
I think it should detect that's the name of the current project, which is valid, and shouldn't throw an error.

screen shot 2016-09-04 at 10 48 26

@wmertens
Copy link
Contributor

I think this is a specific case of #479, see also #496.

@benmosher
Copy link
Member

I think you may be able to solve this with the following resolver config:

// MyProject/.eslintrc.json
{
  "settings": {
    "import/resolver": {
      "node": { "paths": [ ".." ] }
    }
  }
}

or, failing that:

// MyProject/.eslintrc.js
exports.settings = {
  "import/resolver": {
    "node": { "paths": [ path.join(__dirname, "..") ] }
  }
}

Notably, I'm assuming your .eslintrc.{js,json,yml} is located in the MyProject folder. If not, adjust accordingly.

@benmosher
Copy link
Member

If the first way works, let me know and I'll update config/react-native.js.

Or if I can make the assumption that ESLint will be run from the project folder, could do path.resolve(".."), IIRC it resolves relative to CWD.

@benmosher
Copy link
Member

@alexmngn et. al., check out #626: @guzart implemented a React Native resolver. that should fix this, I think.

@benmosher benmosher added this to the v3 - import/order internal milestone Nov 3, 2016
@benmosher
Copy link
Member

psst: added to import/order internal milestone to remember the react-native resolver when implementing the resolver-chooses-import-type API (#479)

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

No branches or pull requests

3 participants