首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Eslint插件“react”在.eslintrc.json >> eslint-config-airbnb之间存在冲突。

Eslint插件“react”在.eslintrc.json >> eslint-config-airbnb之间存在冲突。
EN

Stack Overflow用户
提问于 2022-10-06 20:48:29
回答 1查看 274关注 0票数 0

当我开始使用纱线启动应用程序时,我会在终端中看到下面的评论。我想是airbnb插件造成了一些混乱,因为当我在eslintrc.json中评论它时,应用程序会编译,我可以在其中工作。我应该删除airbnb插件还是有另一个解决方案来修复它?我已经有这样的错误,但实际上没有一个对我有用,这就是为什么我特别要求。

eslint插件“and”在“eslint airbnb”C:\Users\marci\OneDrive\Pulpit\300B\bdb\bdb-front\node_modules\eslint-config-airbnb\rules\reacERROR与".eslintrc.json“eslint airbnb C:\Users\marci\OneDrive\Pulpit\300B\bdb\bdb-front\node_modules\eslint-config-airbnb\rules\react-a11y.js”和"BaseConfig C:\BaseConfig\marci“之间存在冲突。\OneDrive\Pulpit\300B\BDB\bdb-front\node_modules\eslint-config-react-app\base.js".

这就是我的.eslintrc.json的样子:

代码语言:javascript
复制
{
  "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"
      }
    ]
  }
}

谢谢和问候

EN

回答 1

Stack Overflow用户

发布于 2022-10-07 17:06:35

好的,我认为您的问题是插件:react/推荐的,而airbnb则需要删除其中的一个插件。我建议保留pluhin:react/推荐的。

代码语言:javascript
复制
{
    "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/*"]
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73979874

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档