【问题标题】:How to use the create-react-app 3.1.0 eslint customisation?如何使用 create-react-app 3.1.0 eslint 定制?
【发布时间】:2019-12-17 19:03:58
【问题描述】:

编辑:这是 3.1.0 中的错误 - 升级到 3.1.1+ 以获得此功能的工作版本。


create-react-app 3.1.0 应该支持自定义 eslint 警告,根据:https://github.com/facebook/create-react-app/pull/7036

文档在这里:https://facebook.github.io/create-react-app/docs/setting-up-your-editor#experimental-extending-the-eslint-config

我相信我在 package.json 中的规则设置是正确的,因为 IDEA 会选择它并且不再在编辑器中显示点位置警告。

npm start 仍然抱怨:

./src/Auth/AuthenticationProvider.tsx
  Line 135:  Expected dot to be on same line as property  dot-location

我的package.json 符合文档要求,我已将EXTEND_ESLINT 变量添加到.env 文件中。

我的package.json 配置:

"eslintConfig": {
  "extends": [
    "react-app"
  ],
  "rules": {
    "dot-location": "off"
  }
},

环境变量在我的.env文件中设置。

示例失败的源代码如下所示:

   props.auth0Client.loginWithRedirect().
      catch((e)=>{errorHandler(e)});

我做错了什么?

我是否误解了 eslint 配置的工作原理,或者我对 create-react-app 的这个新功能实际上应该做什么有误?

请注意:我不想在我的代码中到处添加注释来禁用警告 - 问题是关于自定义 eslint 配置。

【问题讨论】:

    标签: create-react-app eslint


    【解决方案1】:

    看来您没有做错任何事情,并且 create-react-app 3.1.0 中存在错误。如果您想跟踪进度,an issue has been filed in GitHub.

    【讨论】:

      猜你喜欢
      • 2019-01-06
      • 2020-04-25
      • 2016-12-09
      • 2019-09-13
      • 2018-08-10
      • 1970-01-01
      • 2022-01-19
      • 2018-06-13
      • 2021-05-15
      相关资源
      最近更新 更多