Utk*_*pta 28 javascript reactjs eslint standardjs react-hooks
添加// eslint-disable-next-line react-hooks/exhaustive-deps我的代码后,我收到以下 eslint 错误。
8:14 未找到规则“react-hooks/exhaustive-deps”的错误定义
我参考了这篇文章来解决这个问题,但提到的解决方案在我的情况下不起作用。任何线索如何抑制这个eslint错误?
PS我结合使用standardjs。
Eri*_*ärd 54
这通常是因为插件配置中react-hooks缺少.eslintrc插件。确保您已react-hooks按以下示例添加:
"plugins": ["react", "react-hooks",],
Run Code Online (Sandbox Code Playgroud)
小智 6
确保像这样在 extends 和 plugins 数组中定义你的 react-hooks
"extends": [
"react-hooks",
],
"plugins": [
"react-hooks"
],
Run Code Online (Sandbox Code Playgroud)
小智 5
确保您已将规则rules放入.eslintrc. 仅安装插件不足以让规则开始工作
"react-hooks/exhaustive-deps": "warn",
Run Code Online (Sandbox Code Playgroud)
我假设您已经将react-hooks插件添加到了plugins数组中.eslintrc
不是一个完美的解决方案,但正在改变:
// eslint-disable-next-line react-hooks/exhaustive-deps
Run Code Online (Sandbox Code Playgroud)
到:
// eslint-disable-next-line
Run Code Online (Sandbox Code Playgroud)
抑制了该错误。
| 归档时间: |
|
| 查看次数: |
13362 次 |
| 最近记录: |