首页 > 解决方案 > 覆盖 CRA 基本 linting 规则

问题描述

我有一个使用 create-react-app 创建的应用程序。我需要从默认的 CRA Lint 规则中禁用一条规则:

"react-hooks/exhaustive-deps": 0

在检查了有关该主题的所有资源后,我仍然无法禁用该规则。我制作了一个 .env 文件,EXTEND_ESLINT=true 并在根目录的 .eslintrc 中包含以下内容

{
    "eslintConfig": {
        "extends": ["react-app"],
        "overrides": [
            {
                "rules": {
                    "react-hooks/exhaustive-deps": 0
                }
            }
        ]
    }
}

根据评论建议进行编辑:

此外,将内容移动.eslintrcpackage.json也不起作用。

包.json

"eslintConfig": {
    "extends": [
      "react-app",
      "shared-config"
    ],
    "rules": {
      "react-hooks/exhaustive-deps": 0
    }
  },

我错过了什么吗?可能的话请指教:)

标签: create-react-applinter

解决方案


推荐阅读