当我使用yarn start启动应用程序时,我在终端中收到以下评论。我猜这是airbnb插件,当我在eslintrc.json中注释掉它时,应用程序会编译并且我可以在其中工作,这会造成一些混乱。我应该删除爱彼迎插件还是有其他解决方案来修复它? 我已经遇到了此类错误的问题,但实际上它们都不适合我,这就是我特别询问的原因。
[eslint] 插件“react”与“.eslintrc.json » eslint-config-airbnb » C:\Users\marci\OneDrive\Pulpit�B db db-front 之间发生冲突 ode_modules slint-config-airbnb 乌勒斯 [eslint] 插件“react”中的 eacERROR 在“.eslintrc.json » eslint-config-airbnb » C:\Users\marci\OneDrive\Pulpit�B db db-front 之间发生冲突 ode_modules slint-config-airbnb 乌勒斯 eact-a11y.js”和“BaseConfig » C:\Users\marci\OneDrive\Pulpit�B\BDB db-front ode_modules slint-config-react-app ase.js”。
这就是我的 .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"
}
]
}
}
谢谢和问候
好吧,我认为您的问题出在插件: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/*"]
}
这是改写的答案:
选项1:
node_modules
文件夹和 yarn.lock
或 npm-lock
文件。yarn install
或 npm install
重新安装依赖项。yarn start
、npm start
、yarn build
或npm run build
启动或构建项目。选项2:
yarn remove eslint-plugin-react
yarn add -D eslint-plugin-react
选项 2 解决了我的问题。