[英]ESLint - alias setup
So I am using aliases in my webpack configuration and I have those eslint
warnings about no-extraneous-dependencies
etc.所以我在我的 webpack 配置中使用了别名,并且我有关于
no-extraneous-dependencies
eslint
no-extraneous-dependencies
等的eslint
警告。
So I installed eslint-plugin-import
along with eslint-import-resolver-alias
and configured my .eslintrc
files like this:所以我安装了
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"]
]
}
}
}
My linter is not working with this settings
options.我的 linter 无法使用此
settings
选项。 What am I missing?我错过了什么?
The problem has to be with your relative path问题必须出在你的相对路径上
"./shared/actions"
Try changing it to尝试将其更改为
"../shared/actions"
If that does not work, try an absolute path and take it from there.如果这不起作用,请尝试使用绝对路径并从那里获取它。
Basically, the root directory / current working directory, is not the one you think it is...基本上,根目录/当前工作目录,不是你认为的那个......
My Es lint configuration is in the root directory.我的 Es lint 配置在根目录中。 Code for checking is running from
root/.github
检查代码从
root/.github
运行
So, when I'm changing from ./...
to ../...
aliases, console check is working but then VSC is not working properly.因此,当我从
./...
更改为../...
别名时,控制台检查正在工作,但随后 VSC 无法正常工作。
What might be a solution to satisfy both - console and VS code as well?什么可能是同时满足控制台和 VS 代码的解决方案?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.