Vue-cli: VSCode shows eslint error with '@vue/airbnb' when using webpack aliases in import paths

Created on 18 Sep 2018  Â·  16Comments  Â·  Source: vuejs/vue-cli

Version

3.0.3

image

Node and OS info

Node 10.7.0

Steps to reproduce

Vscode will throw error, but app running successful.

What is expected?

no error info

What is actually happening?

throw error info


eslint

Most helpful comment

In case anyone else is still struggling with this, I realized the same thing as others that the issue was caused by my front-end code being in a sub-directory of the main project. To fix, add this to your settings.json (change "client" to the name of your front-end sub-directory):

    "eslint.workingDirectories": [
      { "directory": "./client", "changeProcessCWD": true },
    ],

All 16 comments

Please share the repository

image
Build with default configuration @LinusBorg

Do npm run serve and npm run build work?

yes, running successful.

and npm run lint ?

The same situation,app can work,but error still exist.
image
image

So the error is only in your editor? Then I think your editor's eslint integration doesn't play nice with eslint-airbnb ?

I use Vscode, I don't know. OK, I try to see it.

1 upgrade vscode editor
2 upgrade vscode-plugin ESLint to 1.7
3 ok

Actually, red herring. The project folder is a subdirectory of a larger project. (SublimeLinter-)eslint was getting confused.

~SublimeLinter-eslint seems to also have the same issue.~

~eslint version v5.12.0 (local and global)~
~Latest Sublime Linter and SublimeLinter-eslint~

~Built with vue cli 3.3.0. Vuex, Router and Airbnb linting.~
~node version 11.5.0.~

~npm run build also works fine.~
screen shot 2019-01-14 at 15 32 09

Then you should probably open an issue in their repository. We can't influence how your editor plugins work

No longer reproducible with the latest versions of vscode, vscode-eslint, @vue/cli…
So I'm closing this issue.

Actually, red herring. The project folder is a subdirectory of a larger project. (SublimeLinter-)eslint was getting confused.

SublimeLinter-eslint seems to also have the same issue.

eslint version v5.12.0 (local and global)
Latest Sublime Linter and SublimeLinter-eslint

Built with vue cli 3.3.0. Vuex, Router and Airbnb linting.
node version 11.5.0.

npm run build also works fine.
screen shot 2019-01-14 at 15 32 09

Same problem with you! When I open the subdirectory only, everything works well. But if I open the large project, vscode shows no-unresolved error.

vscode: v1.30.2
eslint extension: v1.8.0

Same problem with you! When I open the subdirectory only, everything works well. But if I open the large project, vscode shows no-unresolved error

Thanks for that - spent a good hour on this one trying to figure out why it wasn't resolving.

In case anyone else is still struggling with this, I realized the same thing as others that the issue was caused by my front-end code being in a sub-directory of the main project. To fix, add this to your settings.json (change "client" to the name of your front-end sub-directory):

    "eslint.workingDirectories": [
      { "directory": "./client", "changeProcessCWD": true },
    ],
Was this page helpful?
0 / 5 - 0 ratings