[英]Using Webpack alias cause to ESLint error on import alias in WebStorm
I set the alias Webpack config by the following code: 我通过以下代码设置别名Webpack配置:
module: {
...
resolve: {
alias: {
utils: path.resolve(__dirname, 'src/utils/'),
'@SharedBlocks': path.resolve(__dirname, 'src/application/shared-blocks'),
},
extensions: ['.js', '.json', '.jsx', '.scss'],
},
...
Then I find the ESLint
error out in WebStorm like below: 然后我在
ESLint
找到ESLint
错误,如下所示:
Definitely, the ESLint cannot resolve '@SharedBlocks/explorer'
so I add an import/resolver
to .eslint.js
file to configure it: 当然,ESLint无法解析
'@SharedBlocks/explorer'
因此我将一个import/resolver
添加到.eslint.js
文件中进行配置:
settings: {
"import/resolver": {
webpack: {
config: "webpack.template.js",
}
}
},
Now everything works well in all editors like VSCode
and etc. but just in WebStorm I see below: 现在一切都适用于所有编辑器,如
VSCode
等, 但只是在WebStorm我看到如下:
It is so weird because even running eslint .
它是如此奇怪,因为即使运行
eslint .
command doesn't return ESLint rules error but JUST in WebStorm I see red underline for import
also works well but show red underline for import
. 命令不会返回ESLint规则错误但是在WebStorm中我看到
import
红色下划线也运行良好,但import
显示红色下划线。 It's so weird that VSCode has no any problem and works well VSCode没有任何问题并且运行良好,这太奇怪了
How can I fix it? 我该如何解决?
no-extraneous-dependencies
ESLint rule doesn't consider EsLint resolvers, see https://github.com/benmosher/eslint-plugin-import/issues/496 . no-extraneous-dependencies
extraneous no-extraneous-dependencies
ESLint规则不考虑EsLint解析器,请参阅https://github.com/benmosher/eslint-plugin-import/issues/496 。 I'm not sure though why the error can only be seen in WebStorm. 我不确定为什么错误只能在WebStorm中看到。 I'd suggest contacting support on this
我建议联系支持
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.