Skip to content
This repository has been archived by the owner on Sep 28, 2020. It is now read-only.

Does not work with eslint-import-resolver-webpack #103

Closed
calvinnwq opened this issue Aug 4, 2016 · 4 comments
Closed

Does not work with eslint-import-resolver-webpack #103

calvinnwq opened this issue Aug 4, 2016 · 4 comments

Comments

@calvinnwq
Copy link

// webpack.config.js
module.exports = {
  ...
  resolve: {
    root: [
      path.resolve(__dirname, './src')
    ],
    modulesDirectories: ['node_modules']
  }
  ...
}
// .eslintrc.js
module.exports = {
  ...
  'plugins': [ 'import' ],
  'settings': {
    'import/resolver': 'webpack'
  }
}

It seems that the config settings that is used by eslint-import-resolver-webpack is not a config in the eslint CLIEngine.

If i ran eslint from the terminal it works, but doesn't work if it's going through eslint-loader

@MoOx
Copy link
Contributor

MoOx commented Aug 4, 2016

It seems that the config settings that is used by eslint-import-resolver-webpack is not a config in the eslint CLIEngine.

Any other idea on what to use then?

@IanVS
Copy link

IanVS commented Oct 21, 2016

It seems that the config settings that is used by eslint-import-resolver-webpack is not a config in the eslint CLIEngine.

This is true, but the keys of the eslint config file are not being passed directly as keys to CLIEngine. I think you're having a different problem. I found that I needed to turn off the cache option when setting things up, or else it seemed that changes to the .eslintrc had no effect, which might have been what you were seeing.

@adrienharnay
Copy link

adrienharnay commented Feb 4, 2017

Edit: figured it out: had to move to a .eslintrc.js and use

settings: {
    'import/resolver': {
      webpack: {
        config: path.join(__dirname, '/webpack.config.dev.js'),
      },
    },
  },

Original comment: I have the same problem, and the cache is off. Any ideas?

To elaborate, I have:

.eslintrc:

[...]
"settings": {
    "import/parser": "babel-eslint",
    "import/cache": {
      "lifetime": 5
    },
    "import/resolver": {
      "webpack": {
        "config": "webpack.config.dev.js"
      }
    }
  }

webpack.config.dev.js:

const eslintSettings = {
  extends: path.join(__dirname, '/.eslintrc'),
  configFile: '.eslintrc',
  failOnWarning: true,
  failOnError: true,
  cache: false,
};
const roots = [
  path.resolve(__dirname, 'node_modules'),
  path.resolve(__dirname, 'client'),
];
[...]
  resolve: {
    modules: roots,
  },
  resolveLoader: {
    modules: roots,
  },
[...]
      {
        enforce: 'pre',
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'eslint-loader',
        options: eslintSettings,
      },

I'm using Webpack 2. And I get all sorts of errors like: Resolve error: package not found above [path].

When I run ESLint via CLI or Webstorm I have 0 errors, and I use the same .eslintrc that for webpack (I messed it up and tried running the CLI and webpack, both crashed on the .eslintrc).

@MoOx
Copy link
Contributor

MoOx commented Oct 30, 2017

Seems to work then.

@MoOx MoOx closed this as completed Oct 30, 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

4 participants