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

eslint-import-resolver-webpack not resolving imports when using resolve.modules #510

Closed
grahamb opened this issue Aug 22, 2016 · 5 comments

Comments

@grahamb
Copy link
Contributor

grahamb commented Aug 22, 2016

Per the request in #352 (#352 (comment)) to open a new issue…

webpack version: 2.1.0-beta.21
eslint: 3.3.1
eslint-plugin-import: 1.14.0
eslint-import-resolver-webpack: 0.5.1

I have configured Webpack's resolve.modules property as follows:

    resolve: {
      modules: [
        resolve('./client'),
        resolve('./node_modules')
      ]
    },

Full webpack.config.js file

.eslintrc file

Project's file structure:

.
├── .DS_Store
├── .babelrc
├── .env.development
├── .env.example
├── .env.production
├── .env.test
├── .eslintrc
├── .gitignore
├── .npmrc
├── .nvmrc
├── .travis.yml
├── README.md
├── babelRelayPlugin.js
├── client
│   ├── components
│   │   ├── App
│   │   ├── CampusConditions
│   │   ├── Header
│   │   └── UserBio
│   └── index.js
├── data
├── environment.js
├── package.json
├── public
├── scripts
├── server
├── templates
└── webpack.config.js

In client/components/App/index.js I'm importing another module from client/components with import UserBio from 'components/UserBio'. This works, but eslint is throwing an import/no-unresolved error.

Output from running DEBUG=eslint-plugin-import:* $(npm bin)/eslint client/components/App/index.js: https://gist.github.com/grahamb/9f7ad28563af2c5a7fcece5f251a96d3

@benmosher
Copy link
Member

Is your config file a function? I don't think that's supported ATM.

@grahamb
Copy link
Contributor Author

grahamb commented Aug 23, 2016

Which config file, eslint or webpack? .eslint is JSON, webpack is a function that returns the config object. This is a valid way of configuring Webpack 2.

@grahamb
Copy link
Contributor Author

grahamb commented Aug 25, 2016

Adding a simple

if( typeof webpackConfig === 'function' ) {
  webpackConfig = webpackConfig()
}

… after the config is required seems to work, though I haven't run the test suite yet. Would you like a PR for this?

@benmosher
Copy link
Member

👍 that would be great!

@grahamb
Copy link
Contributor Author

grahamb commented Aug 29, 2016

PR #533

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

2 participants