[英]How I can change eslint resolve settings
I have project where I use webpack, eslint. 我有项目,我使用webpack,eslint。 Through webpack.config I set to resolve
index
and Index
files. 通过webpack.config我设置解析
index
和Index
文件。 Everything works, except that eslint throws errors import/no-unresolved
and import/extensions
, it doesn't know, that beside of index
, now it should resolve Index
files too ( import Index from ./components
, where in ./components
have file Index.jsx
). 一切正常,除了eslint抛出错误
import/no-unresolved
和import/extensions
,它不知道,除了index
,现在它也应该解析Index
文件( import Index from ./components
,在./components
有文件Index.jsx
)。 My settings below. 我的设置如下。
// .eslintrc { "extends": "airbnb", "env": { "browser": true }, "rules": { "no-restricted-syntax": "off", "no-continue": "off", "no-plusplus": "off", "react/prop-types": "off", "no-underscore-dangle": "off", "no-param-reassign": "off", "class-methods-use-this": "off" } } // package.json // ... "devDependencies": { // ... "eslint": "^4.19.1", "eslint-config-airbnb": "^16.1.0", "eslint-plugin-import": "^2.10.0", "eslint-plugin-jsx-a11y": "^6.0.3", "eslint-plugin-react": "^7.7.0", // ... } // ...
Try installing eslint-import-resolver-webpack
and adding this to your .eslintrc: 尝试安装
eslint-import-resolver-webpack
并将其添加到.eslintrc:
"settings": {
"import/resolver": "webpack"
}
Or adding the source folder from which it will resolve the dependencies; 或者添加它将解析依赖关系的源文件夹; something like this:
这样的事情:
settings: {
'import/resolver': {
node: {
paths: [path.resolve(__dirname, 'src')],
},
},
}
Resolver documentation: https://github.com/benmosher/eslint-plugin-import/blob/master/README.md#resolvers 解析器文档: https : //github.com/benmosher/eslint-plugin-import/blob/master/README.md#resolvers
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.