【问题标题】:eslint error Expected indentation of 1 tab character but found 0eslint 错误预期缩进 1 个制表符,但发现 0
【发布时间】:2018-05-22 04:58:45
【问题描述】:

我正在开发一个包含 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,但出现错误。任何帮助表示赞赏。

【问题讨论】:

    标签: intellij-idea eslint eslintrc


    【解决方案1】:

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

    preferences >  Code Style > EditorConfig
    

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

      • 我应该把 eslint --fix 放在 intellij 哪里
      • 我对 Intellij 不是很熟悉,你能通过终端访问你的项目文件夹并运行命令吗?
      猜你喜欢
      • 2020-08-17
      • 2022-01-21
      • 1970-01-01
      • 2020-07-11
      • 1970-01-01
      • 1970-01-01
      • 2021-07-29
      • 2021-08-22
      • 2019-08-28
      相关资源
      最近更新 更多