簡體   English   中英

我如何更改eslint解決設置

[英]How I can change eslint resolve settings

我有項目,我使用webpack,eslint。 通過webpack.config我設置解析indexIndex文件。 一切正常,除了eslint拋出錯誤import/no-unresolvedimport/extensions ,它不知道,除了index ,現在它也應該解析Index文件( import Index from ./components ,在./components有文件Index.jsx )。 我的設置如下。

 // .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", // ... } // ... 

嘗試安裝eslint-import-resolver-webpack並將其添加到.eslintrc:

"settings": {
  "import/resolver": "webpack"
}

或者添加它將解析依賴關系的源文件夾; 這樣的事情:

settings: {
    'import/resolver': {
        node: {
            paths: [path.resolve(__dirname, 'src')],
        },
    },
}

解析器文檔: https//github.com/benmosher/eslint-plugin-import/blob/master/README.md#resolvers

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM