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

Unable to use eslint-import-resolver-webpack with webpackConfigFactory #481

Closed
rckahale opened this issue Aug 4, 2017 · 4 comments
Closed

Comments

@rckahale
Copy link

rckahale commented Aug 4, 2017

I have some alias in my webpack config. I want to fix eslint errors arising out of it.
I followed this, but I could not find webpack config json to be applied as react-universally uses config generated from factory. AFAIK, js imports and function calls can't be made in eslintrc file.
How can I fix these errors?

@diondirza
Copy link
Contributor

You can make separate file e.g eslint-import-resolver.js which reflect webpack config just contain resolve alias value like sample below

module.exports = {
  resolve: {
    extensions: ['.js', '.jsx', '.scss'],
    modules: [path.resolve(appRootDir.get(), './src'), path.resolve(appRootDir.get(), './node_modules')],
    alias: {
      TweenLite: 'gsap/src/uncompressed/TweenLite',
      TimelineLite: 'gsap/src/uncompressed/TimelineLite',
    },
  },
};

Then change your .eslintrc config path of import rules to point to this file.

@rckahale
Copy link
Author

rckahale commented Aug 4, 2017

Thanks for the quick response Dion! I tried above steps, but still found same errors.
I think the eslint-import-resolver-webpack is expecting entire config object along with resolve & other keys.
I also tried with

"settings": {
    "import/resolver": {
      "webpack": {
        "config": {
          "resolve" : "eslint-import-resolver.js"
        }
      }
    }
  }

@diondirza
Copy link
Contributor

It's should be config.path instead of config.resolve.

@rckahale
Copy link
Author

rckahale commented Aug 4, 2017

No luck with config.path
However, i found an alternative. I shifted my alias into babelrc from webpack's configFactory.
The modules which helped me for the cause are babel-plugin-module-resolver and eslint-import-resolver-babel-module

@rckahale rckahale closed this as completed Aug 4, 2017
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