[英]Plugin "react" was conflicted between ".eslintrc.js" and "BaseConfig
After I set up ESLint, I got this error Plugin "react" was conflicted between ".eslintrc.js" and "BaseConfig » /frontend/node_modules/react-scripts/node_modules/eslint-config-react-app/base.js".设置 ESLint 后,出现此错误Plugin "react" was conflicted between ".eslintrc.js" and "BaseConfig » /frontend/node_modules/react-scripts/node_modules/eslint-config-react-app/base.js" .
my.eslintrc.js is like my.eslintrc.js 就像
module.exports = {
env: {
browser: true,
es2021: true,
},
extends: [
'plugin:react/recommended',
'airbnb',
'airbnb/hooks',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'prettier',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: true,
},
ecmaVersion: 'latest',
sourceType: 'module',
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},
plugins: [
'react',
'@typescript-eslint',
],
ignorePatterns: [
".eslintrc.js"
],
rules: {
'no-use-before-define': "off",
"@typescript-eslint/no-use-before-define": "off",
'import/prefer-default-export': "off",
'import/extensions': [
'error',
{
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
},
],
'react/jsx-filename-extension': [
'error',
{
extensions: ['.jsx', '.tsx'],
},
],
'react/react-in-jsx-scope': 'off',
'no-void': [
'error',
{
allowAsStatement: true,
},
],
"react/function-component-definition": [
2,
{ "namedComponents": "arrow-function" }
]
},
settings: {
'import/resolver': {
node: {
paths: ['src'],
extensions: ['.js', '.jsx', '.ts', '.tsx']
},
},
},
};
What I have done is我所做的是
How can I remove this error?我怎样才能消除这个错误?
您可能需要在您的锁定文件中对 eslint-plugin-react 进行重复数据删除。
You have to disable eslint while react-scripts start
.你必须在
react-scripts start
时禁用 eslint。
As of react-scripts
v4.0.2, you can now opt out of ESLint with an environment variable.从
react-scripts
v4.0.2 开始,您现在可以使用环境变量选择退出 ESLint。 You can do this by adding it to your .env
file, or by prefixing your scripts in your package.json file.您可以通过将其添加到您的
.env
文件,或在您的 package.json 文件中添加脚本前缀来实现。
For example in .env
:例如在
.env
中:
DISABLE_ESLINT_PLUGIN=true
I fixed the issue by closing and reopening the project folder with code.我通过使用代码关闭并重新打开项目文件夹来解决此问题。 There must have been a problem with the path name.
路径名一定有问题。
Hope this helps:)希望这可以帮助:)
I fixed this problem in this way: if you are using npm remove the package-lock.json file.我以这种方式解决了这个问题:如果您使用的是 npm,请删除 package-lock.json 文件。 if you are using the yarn remove the yarn.lock file.
如果您使用纱线,请删除 yarn.lock 文件。
and then remove the node_module folder and install all of the dependencies again.然后删除 node_module 文件夹并再次安装所有依赖项。
yarn remove eslint-config-react-app yarn add eslint-config-react-app@6
yarn remove eslint-config-react-app yarn add eslint-config-react-app@6
yarn run eslint --initc
纱线运行 eslint --initc
//Reinicia la configuracion de eslist y permite que //automaticamente coloque los paquetes q falten//Reinicia la configuracion de eslist y permite que //automaticamente coloque los paquetes q falten
// quita los errores automaticamente con . //quita los errores automaticamente con . y --fix
y --修复
npx eslint .
npx eslint 。 --fix
- 使固定
Been there too, and finding the exact answer to this issue is hard to find.也去过那里,很难找到这个问题的确切答案。
The best solution for now is to remove eslintrc.json
.目前最好的解决方案是删除
eslintrc.json
。
I faced the same error.我遇到了同样的错误。 After trying every solution I found on the inte.net, removing eslintrc.js actually helped.
在尝试了我在 inte.net 上找到的所有解决方案后,删除 eslintrc.js 实际上有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.