我正在使用 VScode 和最新版本的 Eslint。这是我第一次使用 linter。
使用制表符作为缩进时,我不断收到此 linting 错误:
严重性:“错误”
message: '预期缩进 1 个制表符,但发现有 4 个空格。 (缩进)'
在:'4,5'
来源:'eslint'
这是我的配置文件
{
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"rules": {
"indent": [
"error",
"tab"
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
]
}
}
我不明白为什么当我指示缩进选项卡时会引发此错误。它显然将我的 1 个制表符计算为 4 个间距,但我不明白为什么当我按制表符进行缩进时它会这样做。
update: The reason is because in VScode using ctrl + shift + i to beautify code will actually use spaces and not tabs. That is the reason.