如何为制表符而不是空格配置ESLint?

时间:2019-01-05 03:16:43

标签: javascript tabs eslint spaces

我的根目录中有一个.eslintrc文件:

{
    "extends": "airbnb",
    "env": {
        "browser": true,
        "node": true,
        "jquery": true
},

    "rules": {
    "no-unused-vars": [0,{"argsIgnorePartern": "res|next|~err"}],
    "arrow-body-style": ["error", "as-needed"],
    "no-param-reassign": 0,
    "eqeqeq": [
        "error",
        "smart"
    ],
    "no-shadow": "off",
    "allowIndentationTabs": true,
    "import/newline-after-import": ["error", { "count": 0 }],
    "no-console": 0,
    "import": 0,
    "func-names": 0,
    "space-before-function-paren": 0,
    "comma-dangle": 0,
    "max-len": 0,
    "no-underscore-dangle": 0,
    "react/prefer-es6-class": 0,
    "radix": 0,
    "indent": [1, "tab"],
    "react/jsx-indent": ["error", 4],
    "arrow-parens": [2, "as-needed"],
    "function-paren-newline": ["error", "consistent"],
    "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
    "react/prefer-stateless-function": "off",
    "no-use-before-define": ["error",{ "functions": false, "variables": false }],
    "no-plusplus": ["error", { "allowForLoopAfterthoughts": true }]}
}

我遇到以下错误:

  

意外的制表符尾随(无制表符)

因此我添加了以下规则:"allowIndentationTabs": true

但是,我仍然遇到该错误。我还确保将VSCode配置为使用制表符而不是空格。这有点让我发疯。我认为,该规则将覆盖任何airbnbs规则,但我想不会。什么鬼?!

1 个答案:

答案 0 :(得分:0)

看起来像airbnb还有另一条规则,所以我改写了它:

"no-tabs": 0