首页 > 解决方案 > 如何为制表符而不是空格配置 ESLint?

问题描述

我的根目录中有一个 .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 }]}
}

我收到以下错误:

意外的制表符 eslint(无制表符)

所以我添加了这条规则:"allowIndentationTabs": true

但是,我仍然收到该错误。我还确保我的 VSCode 配置为制表符而不是空格。这有点让我发疯。我想,该规则会覆盖任何 airbnbs 规则,但我想不会。我勒个去?!

标签: javascripttabseslintspaces

解决方案


好像airbnb还有一条规则,所以我就改写了:

"no-tabs": 0


推荐阅读