ESLint "Unexpected tab character" when "indent" rule set to "tab"
Asked Answered
H

2

45

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.

Hexapody answered 30/11, 2016 at 16:34 Comment(2)
Is there a stack trace that accompanies that error? It doesn't look to be a normal linter error, though it could be coming from the parser.Lautrec
The error was being showed by atom, yes, it said something about no-tabs rule ;)Hexapody
H
111

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
    }
}
Hexapody answered 4/12, 2016 at 20:17 Comment(2)
FYI, it happens for standard ones as well and not just airbnb and no-tab rule works. thanksInfestation
thanks! I had my indent rule set to tab but didn't know that I had to specifically disable airbnb's "no-tabs". It works, thanks!Prelatism
P
2

"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 }]
    ...
}
...
Periosteum answered 23/12, 2021 at 13:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.