.eslintrc:规则“导入/扩展”的配置无效:

时间:2019-12-18 10:30:18

标签: eslint gatsby eslintrc

首先,我有一些基础知识,但我根本不认为自己是开发人员:p 这是我的问题:我克隆了一个仓库(this one以便处理一个全新的产品组合并测试整个辣酱玉米饼馅,但是由于我对eslint设置完全不熟悉,我遇到了一些错误。

克隆存储库后,我尝试进行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"
    }]
  }
}

我将此行添加到“规则”部分:"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

任何关于我在这里做错了什么以及如何解决此问题的主意,将不胜感激!

0 个答案:

没有答案