[英]how to resolve import/no-unresolved with setup of eslint in webpack 4
I have researched for a few hours. 我研究了几个小时。 build a prototype myself and found that the webpack is working on its resolving alias but eslint kept reporting unable to resolve, EVEN after I jammed in setting supposedly resolve this issue.
我自己构建了一个原型,发现webpack正在使用其解析别名,但是eslint一直报告无法解决,即使在我介入设置据说可以解决此问题之后也是如此。
Anyone know why adding 谁知道为什么要添加
"settings": {
"import/resolver": {
"alias": [
[ "mycomponents", "./app/components" ]
]
}
}
to .eslintrc and add two packages related to it won't do it? 到.eslintrc并添加两个与之相关的软件包不会这样做吗?
to see what I did check this repo diff link: https://github.com/KleoPetroff/react-webpack-boilerplate/compare/master...adamchenwei:master 看看我做了什么检查此仓库差异链接: https : //github.com/KleoPetroff/react-webpack-boilerplate/compare/master...adamchenwei : master
Note: i could have just hide the eslint error, but that's just a hack route which I would rather not to take, if there is a proper setup. 注意:我本可以隐藏eslint错误,但这只是如果有适当的设置,我不希望采用的黑客途径。
Thanks 谢谢
Try adding eslint-import-resolver-alias to your project: 尝试将eslint-import-resolver-alias添加到您的项目中:
npm i eslint-import-resolver-alias --save-dev
Then update your .eslintrc
file as follows: 然后,如下更新您的
.eslintrc
文件:
"settings": {
"import/resolver": {
"alias": {
map: [
[ "mycomponents", "./app/components" ]
]
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.