[英]Eslint Plugin "react"was conflicted between .eslintrc.json >> eslint-config-airbnb
When I start the app with yarn start I get below comment in terminal.当我使用 yarn start 启动应用程序时,我在终端中收到以下评论。 I guess it's airbnb plug-in which makes some mess as when I comment it out in eslintrc.json the app compiles and I can work in it.
我猜这是 airbnb 插件,当我在 eslintrc.json 中将其注释掉时,它会造成一些混乱,应用程序会编译,我可以在其中工作。 Shall I remove airbnb plug-in or there is another solution to fix it?
我应该删除 airbnb 插件还是有其他解决方案来修复它? I was already issues with such error but actually none of them worked for me, that's why I ask specifically.
我已经遇到了这样的错误,但实际上没有一个对我有用,这就是我特意询问的原因。
[eslint] Plugin "react" was conflicted between ".eslintrc.json » eslint-config-airbnb » C:\Users\marci\OneDrive\Pulpit\300B\bdb\bdb-front\node_modules\eslint-config-airbnb\rules\reacERROR in [eslint] Plugin "react" was conflicted between ".eslintrc.json » eslint-config-airbnb » C:\Users\marci\OneDrive\Pulpit\300B\bdb\bdb-front\node_modules\eslint-config-airbnb\rules\react-a11y.js" and "BaseConfig » C:\Users\marci\OneDrive\Pulpit\300B\BDB\bdb-front\node_modules\eslint-config-react-app\base.js". [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”。
this is how my.eslintrc.json looks like:这是 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"
}
]
}
}
thanks & regards感谢和问候
Ok, I think your issue is with the plugin:react/recommended and the airbnb you will need to remove one of those.好的,我认为您的问题出在 plugin:react/recommended 和 airbnb 上,您需要删除其中一个。 I suggest keeping the pluhin:react/recommended.
我建议保留 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.