Red*_*ron 6 reactjs eslint react-hooks
我有一个.eslintrc
包含以下规则的文件:
"rules": {
"prettier/prettier": "error",
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "error",
"no-console": "warn"
},
Run Code Online (Sandbox Code Playgroud)
我已经安装了:eslint-plugin-prettier
和eslint-config-prettier
eslint-plugin-react-hooks
"eslint.validate": [ "javascript", "javascriptreact", "html", "typescriptreact" ],
我已经在 vscode 的 settings.json 中启用
但是当我删除 a 中所需的依赖项时useEffect
,它没有显示我希望的错误
我还需要做什么?
小智 6
我使用react 18.2.0,react-scripts 5.0.1和react-app-rewired 2.2.1。您必须在.eslintrc
.
{
"plugins": [
// ...
"react-hooks" // for activate eslint checking react hooks
],
"rules": {
// ...
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "error"
}
}
Run Code Online (Sandbox Code Playgroud)
在 中.eslintrc
,除了添加之外,您还必须在列表中rules
添加react-hooks
plugins
{
"plugins": [
// ...
"react-hooks"
],
"rules": {
// ...
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "error"
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5253 次 |
最近记录: |