简体   繁体   中英

ESLint "Unexpected tab character" when "indent" rule set to "tab"

I'm using ESLint with the Airbnb plugin ( eslint-config-airbnb ) and Babel parser. I've just added the extra rule of using Tab characters for indentation instead of spaces.

Here is my .eslintrc :

{
    "parser": "babel-eslint",
    "extends": "airbnb",
    "plugins": [
        "react",
        "jsx-a11y",
        "import"
    ],
    "rules":{
        "indent": [2, "tab"]
    }
}

Now I get this error at every indentation:

Error: Unexpected tab character

Just in case it helps, I'm using Atom IDE with the autolinter plugins linter and linter-eslint .

I answer myself, it was because Airbnb has set the rule no-tabs to 2 or error, I just disabled it.

{
    "parser": "babel-eslint",
    "extends": "airbnb",
    "plugins": [
        "react",
        "jsx-a11y",
        "import"
    ],
    "rules":{
        "indent": [2, "tab"],
        "no-tabs": 0
    }
}

"no-tabs" rule looks for tabs anywhere inside a file: code, comments or anything else. It may be a another answer.

...
"rules": {
    ...
    "no-tabs": ["error", { "allowIndentationTabs": true }]
    ...
}
...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM