簡體   English   中英

Eslint 插件“反應”在 eslintrc.json >> eslint-config-airbnb 之間發生沖突

[英]Eslint Plugin "react"was conflicted between .eslintrc.json >> eslint-config-airbnb

當我使用 yarn start 啟動應用程序時,我在終端中收到以下評論。 我猜這是 airbnb 插件,當我在 eslintrc.json 中將其注釋掉時,它會造成一些混亂,應用程序會編譯,我可以在其中工作。 我應該刪除 airbnb 插件還是有其他解決方案來修復它? 我已經遇到了這樣的錯誤,但實際上沒有一個對我有用,這就是我特意詢問的原因。

[eslint] 插件“react”在“.eslintrc.json » eslint-config-airbnb » C:\Users\marci\OneDrive\Pulpit\300B\bdb\bdb-front\node_modules\eslint-config-airbnb\rules 之間發生沖突[eslint] 插件“反應”中的 \reacERROR 在“.eslintrc.json » eslint-config-airbnb » C:\Users\marci\OneDrive\Pulpit\300B\bdb\bdb-front\node_modules\eslint-config- 之間發生沖突airbnb\rules\react-a11y.js”和“BaseConfig » C:\Users\marci\OneDrive\Pulpit\300B\BDB\bdb-front\node_modules\eslint-config-react-app\base.js”。

這是 my.eslintrc.json 的樣子:

{
  "env": {
    "browser": true,
    "es2021": true,
    "node": true
  },
  "globals": {
    "JSX": "readonly"
  },
  "extends": [
    "plugin:@typescript-eslint/recommended",
    "plugin:react-hooks/recommended",
    "plugin:react/recommended",
    "plugin:import/errors",
    "plugin:import/warnings",
    "plugin:import/typescript",
    "airbnb",
    "plugin:prettier/recommended",
    "prettier"
  ],
  "parser": "@typescript-eslint/parser",
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true,
      "tsx": true
    },
    "ecmaVersion": "latest",
    "sourceType": "module"
  },
  "plugins": [ "@typescript-eslint", "prettier"],
  "settings": {
    "import/resolver": {
      "node": {
        "extensions": [".js", ".jsx", ".ts", ".tsx"]
      }
    }
  },
  "ignorePatterns": ["src/serviceWorkerRegistration.ts", "src/service-worker.ts"],
  "rules": {
    "prefer-regex-literals": "off",
    "global-require": "off",
    "import/no-dynamic-require": "off",
    "no-shadow": "off",
    "@typescript-eslint/no-shadow": ["error"],
    "@typescript-eslint/no-var-requires": "off",
    "@typescript-eslint/no-empty-function": "off",
    "react-hooks/exhaustive-deps": "off",
    "@typescript-eslint/no-unused-vars": "error",
    "@typescript-eslint/no-empty-interface": "off",
    "import/prefer-default-export": "off",
    "react/react-in-jsx-scope": "off",
    "react/jsx-props-no-spreading": "off",
    "no-new-func": "off",
    "jsx-a11y/media-has-caption": "off",
    "jsx-a11y/label-has-associated-control": [
      "error",
      {
        "required": {
          "some": ["nesting", "id"]
        }
      }
    ],
    "jsx-a11y/label-has-for": [
      "error",
      {
        "required": {
          "some": ["nesting", "id"]
        }
      }
    ],
    "react/function-component-definition": "off",
    "no-unused-vars": "off",
    "no-use-before-define": "warn",
    "no-nested-ternary": "off",
    "no-param-reassign": "warn",
    "import/extensions": [
      "error",
      "ignorePackages",
      {
        "js": "never",
        "jsx": "never",
        "ts": "never",
        "tsx": "never"
      }
    ],
    "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx", ".ts", ".tsx", ".*"] }],
    "prettier/prettier": [
      "error",
      {
        "endOfLine": "auto"
      }
    ]
  }
}

感謝和問候

好的,我認為您的問題出在 plugin:react/recommended 和 airbnb 上,您需要刪除其中一個。 我建議保留 pluhin:react/recommended。

{
    "env": {
        "browser": true,
        "es2021": true,
        "jest":true
    },
    "extends": [
        "eslint:recommended",
        "plugin:react/recommended",
        "plugin:@typescript-eslint/recommended",
        "prettier"
    ],
    "overrides": [],
    "parser": "@typescript-eslint/parser",
    "parserOptions": {
        "ecmaFeatures": {
            "jsx": true
        },
        "ecmaVersion": "latest",
        "sourceType": "module"
    },
    "plugins": [
        "react",
        "react-hooks",
        "@typescript-eslint",
        "prettier"
    ],
    "rules": {
        "react/react-in-jsx-scope": "off",
        "camelcase": "error",
        "spaced-comment": "error",
        "quotes": ["error", "double"],
        "no-duplicate-imports": "error",
        "no-console": "warn",
        "react/prop-types": "off"
    },
    "settings": {
        "import/resolver": {
          "typescript": {}
        }
    },
    "ignorePatterns": ["build/*"]
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM