vscode-eslint: Bug with custom alias in Webpack

Version of used depedencies:

"webpack": "^3.5.6",
"eslint": "^4.3.0",
"eslint-config-airbnb": "^15.1.0",
"eslint-config-airbnb-base": "^11.3.1",
"eslint-config-prettier": "^2.9.0",
"eslint-import-resolver-webpack": "^0.8.4",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-prettier": "^2.3.1",
"eslint-plugin-react": "^7.5.1",

Configuration of resolving alias: webpack.config.js

resolve: {
    extensions: [".js", ".jsx"],
    alias: {
      myCustomAlias: path.resolve("src"),
    },
 },

Configuration of .eslint.js:

  settings: {
    "import/resolver": {
      webpack: {
        config: path.resolve("webpack/webpack.config.js"),
      },
    },
  },

Description of issue: As you can see I have defined custom alias in webpack and when I am running eslint from the CLI everything passes but somehow VS plugin cannot resolve aliases and highlights every line when I am trying to import things from myCustomAlias

Any idea what may causing that behavior?

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 6
  • Comments: 24 (8 by maintainers)

Most upvoted comments

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

@willisplummer @dbaeumer Sorry for a little absence. I had some business trips. I have resolve in webpack.config.js and my eslint settings are pointing to it. I have no errors when I run eslint from CLI but in VS Code everything is highlighted so I guess it isn’t a solution for me :C

Guys, I was getting the same issue, no errors with eslint command but vscode show me errors for import using aliases. Thanks for a vscode notification I just check the output tab and it shows me this: screenshot from 2018-04-11 22 49 31

yes, I was using spread operator in my webpack config, I’m using nodev8.9.0 and I don’t know why eslint plugin shows an error 🤔 (and I can run webpack-dev-server without problems). I change the spread operator in my webpack config and now I’m not getting more errors 🎉 : screenshot from 2018-04-11 22 50 58

So in my case, it was a webpack configuration error I think

If I set Node_ENV to development everything works for me both in the terminal and in VS Code. Please note that you need to start VS Code form the terminal having Node_ENV set so that the eslint plug-ins correctly see the environemt variable.

@chenxsan I have this 👇 and it still doesn’t work 😦

// webpack.config.js
module.exports = {
// your config
}

I think I figured it out, it’s not a VS code issue.

Es-lint webpack plugin only support webpack.config.js file that export Object.

not working

// webpack.config.js
module.exports = () => {
// your config
}

working

// webpack.config.js
module.exports = {
// your config
}