-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
service lint break import/no-unresolved for extension .vue #3267
Comments
Your import path in |
Hi @kefranabg The webpack config use this option how you can see that: vue-cli/packages/@vue/cli-service/lib/config/base.js Lines 39 to 41 in e7af0d8
I wrong about that? Can you explain better your comment? I'm not expert about, maybe I miss something I think is a bug for vue-cli-service because the webpack config is provided, if the issue is for the webpack let me know |
the extension is not the issue. the path is wrong: import HelloWorld from 'components/HelloWorld.vue'; This makes webpack / eslint look for a package named You either need to provide a relative path: import HelloWorld from '../components/HelloWorld.vue'; Or use the special import HelloWorld from '@/components/HelloWorld.vue'; |
Ow, sorry @LinusBorg and @kefranabg Removed extension .vue and update the reference to @/ how expected |
Now it's another error ( See: vue-cli/packages/@vue/eslint-config-airbnb/index.js Lines 11 to 17 in 689f615
|
Thank you for support @sodatea , Cheers |
you can solve your problem by extending the original config in your own .eslintrc file: {
// other stuff
"settings": {
"import/resolver": {
"import/extensions": [
".js",
".jsx",
".mjs",
".ts",
".tsx",
".vue"
]
}
}
} |
Thanks for answer @LinusBorg Cheers |
For me, on vue-cli 3.5.0, it was extending the .eslintrc.js file:
|
@LinusBorg since older vue-cli generated websites didn't specify .vue in the end of component files, why not adding by default the related eslint rule out of the box? (since webpack correctly resolves the files without specifying the extension anyway, seems a bit confusing to not have the rule) (I can make a PR if OK) |
The solution is to disable eslint for all the import statements.
after all import statements, you enable eslint. This problem is peculiar to airbnb eslint preset. |
You saved my life men! Quick and efficient |
Version
3.3.0
Reproduction link
https://github.com/angeliski/vue-cli-typescript-lint-error-extension
Environment info
Steps to reproduce
npm install
npm run lint
What is expected?
No errors
What is actually happening?
error: Unable to resolve path to module 'components/HelloWorld.vue' (import/no-unresolved) at src/views/Home.vue:10:24:
I see the issue #2628, but not works how expected.
When I make the same steps in a project without Typescript the error happen in
npm run lint
but no innpm run serve
The text was updated successfully, but these errors were encountered: