由于 ESLint 错误,我的 React 构建无法编译。当我运行npx eslint src
检查我的代码时,没有报告任何错误,但是,构建失败并出现以下错误:
Line 30:30: Must use destructuring props assignment react/destructuring-assignment
我的 ESLint 配置:
{
"env": {
"node": true,
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:jest/recommended",
"airbnb"
],
"parser": "@babel/eslint-parser",
"parserOptions": {
"requireConfigFile": false,
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module",
"babelOptions": {
"presets": ["@babel/preset-react"]
}
},
"plugins": [
"react",
"jest"
],
"rules": {
}
}
我的开发依赖:
"devDependencies": {
"@babel/eslint-parser": "^7.15.4",
"@babel/preset-react": "^7.16.0",
"babel-jest": "^27.4.2",
"eslint": "^8.4.1",
"eslint-config-airbnb": "^19.0.2",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-jest": "^25.2.2",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.27.1",
"eslint-plugin-react-hooks": "^4.3.0"
}
为什么 ESLint 没有显示这些错误?据我所知,这些规则默认启用,因此它们应该被捕获。