进入项目根目录
一、安装eslint-plugin-react-hooks:
cnpm i -D eslint-plugin-react-hooks
二、配置ESLint:
1.打开项目根目录的package.json
2.把
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
改为
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
],
"plugins": [
"react-hooks"
],
"rules": {
"react-hooks/rules-of-hooks": "error"
}
},
3.重启项目
安装并使用eslint-plugin-react-hooks
原文:https://www.cnblogs.com/starlog/p/14671315.html