[英]ESLint - alias setup
所以我在我的 webpack 配置中使用了別名,並且我有關於no-extraneous-dependencies
eslint
no-extraneous-dependencies
等的eslint
警告。
所以我安裝了eslint-plugin-import
和eslint-import-resolver-alias
並像這樣配置了我的.eslintrc
文件:
{
"parser": "babel-eslint",
"extends": "airbnb",
"env": {
"browser": true,
"es6": true,
"node": true,
"jest": true
},
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"defaultParams": true
}
},
"rules": {
"react/jsx-filename-extension": 0,
"react/sort-comp": 0,
"linebreak-style": 0,
"prefer-arrow-callback": 0,
"consistent-return": 0,
"func-names": 0,
},
"settings": {
"import/resolver": {
"alias": [
// I have my actions folder in ./shared/actions
["Actions", "./shared/actions"]
]
}
}
}
我的 linter 無法使用此settings
選項。 我錯過了什么?
問題必須出在你的相對路徑上
"./shared/actions"
嘗試將其更改為
"../shared/actions"
如果這不起作用,請嘗試使用絕對路徑並從那里獲取它。
基本上,根目錄/當前工作目錄,不是你認為的那個......
我的 Es lint 配置在根目錄中。 檢查代碼從root/.github
運行
因此,當我從./...
更改為../...
別名時,控制台檢查正在工作,但隨后 VSC 無法正常工作。
什么可能是同時滿足控制台和 VS 代碼的解決方案?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.