.eslintrc:规则 "import/extensions" 的配置无效:

.eslintrc: Configuration for rule "import/extensions" is invalid:

首先,我有一些基础知识,但我根本不认为自己是开发人员 :p 这是我的问题:我克隆了一个 repo ( this one ) 以处理 b运行d 新投资组合并测试整个辣酱玉米饼馅,但我 运行 遇到了一些错误,因为我完全不熟悉 eslint 设置。

克隆 repo 后,我尝试开发 gatsby,然后 运行 出现了一些错误消息,如下所示:


Generating development JavaScript bundle failed


/home/asus/code/chrisnopa/gatsby-projects/portf-boilerplate/src/hoc/withProvider.js
  4:25  error  Missing file extension for "store/createStore"  import/extensions

✖ 1 problem (1 error, 0 warnings)


File: src/hoc/withProvider.js

这是我的 .eslintrc 文件的内容:

  "parser": "babel-eslint",
  "env": {
    "browser": true,
    "jest": true,
    "es6": true,
    "node": true
  },
  "extends": [
    "airbnb",
    "prettier"
  ],
  "plugins": [
    "prettier"
  ],
  "globals": {
    "graphql": true
  },
  "rules": {
    "react/jsx-filename-extension": 0,
    "react/require-default-props": 0,
    "react/jsx-one-expression-per-line": 0,
    "arrow-body-style": 0,
    "import/no-unresolved": 0,
    "prettier/prettier": ["error", {
      "semi": true,
      "singleQuote": true,
      "trailingComma": "es5"
    }]
  }
}

我将此行添加到 "Rules" 部分:"import/extensions": [".js", ".jsx", ".json", ".ts", ".tsx"] 它修复了除一个错误之外的所有问题。这是我的控制台中的消息:


Generating development JavaScript bundle failed

.eslintrc:
    Configuration for rule "import/extensions" is invalid:
    Severity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '".js"').


File: src/pages/index.js

failed Building development bundle - 4.029s

任何关于我在这里做错了什么以及如何解决这个问题的想法都将不胜感激!

已将 eslint-plugin-import 更新至 v2.11.0(或更高版本)