所以我在我的 webpack 配置中使用了别名,并且我有关于 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"
如果这不起作用,请尝试绝对路径并从那里开始。
基本上,根目录/当前工作目录,并不是你想的那个...
关于javascript - ESLint - 别名设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45857679/