![](/img/trans.png)
[英]Do I have to use and 'extend' eslint-plugin-react in eslintrc.js config while using and extending 'eslint-config-airbnb' already
[英]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.