3

我正在开发一个具有 eslintrc 文件的项目,当我在 Intellij 项目中运行 npm run test 时。我收到一个错误

Expected indentation of 1 tab character but found 0 

我尝试选中启用 ESlint 搜索 .eslintrc 文件的框 > 其他设置 > 默认设置 > 语言和框架 > javascript > 代码质量工具 > ESLint

{
  "parser": "babel-eslint",
  "extends": [
    "airbnb",
    "plugin:import/errors",
    "plugin:import/warnings"
  ],
  "plugins": [
    "react",
    "flow-vars"
  ],
  "settings": {
    "import/ignore": [
      "node_modules",
      "\\.(html|json|properties)$",
      "DevTools"
    ],
    "import/resolver": {
      "webpack": {
        "config": "./src/js/webpack/webpack.base.config.js"
      }
    }
  },
  "rules": {
    "eqeqeq": [2, "allow-null"],
    "flow-vars/define-flow-type": 1,
    "flow-vars/use-flow-type": 1,
    "func-names": 0,
    "import/no-named-as-default": 0,
    "indent": [2, "tab", {"SwitchCase": 1}],
    "new-cap": 0,
    "no-multi-spaces": [2, {"exceptions": {"VariableDeclarator": true}}],
    "no-param-reassign": [2, {"props": false}],
    "no-script-url": 0,
    "no-unused-vars": [2, {"args": "after-used", "argsIgnorePattern": "^_"}],
    "no-use-before-define": [2, "nofunc"],
    "quote-props": [2, "consistent-as-needed"],
    "react/jsx-indent-props": [2, "tab"],
    "react/jsx-no-bind": [2, {
      "ignoreRefs": false,
      "allowArrowFunctions": false,
      "allowBind": false
    }],
    "space-before-function-paren": 0,
    "spaced-comment": 0
  },
  "globals": {
    "__ENV__": false,
    "__DEV__": false,
    "__TEST__": false
  }
}

我什至尝试在设置中将选项卡编号从 4 更改为 2,但出现错误。任何帮助表示赞赏。

4

2 回答 2

1

对于遇到此问题的任何人,我可以解决的唯一方法是取消选中 intellij 中的启用 EditorConfig 支持选项。

preferences >  Code Style > EditorConfig
于 2017-12-10T02:28:52.173 回答
0

通常,linting 错误应指示其来源的文件和行号。

在这种情况下,您可以尝试运行以下命令:eslint --fix& 允许 eslint 为您修复该缩进错误。

于 2017-12-08T03:24:35.680 回答