react/memo-dependencies Suspicious
功能
验证 useMemo() 和 useCallback() 是否声明了完整的依赖列表,且不包含多余值。
由 React Compiler 提供支持,它会为每个文件运行一次,并与其他 React Compiler 规则共享。移植自 react-hooks/memo-dependencies。
为什么这是个问题?
缺少依赖项会产生过时的记忆化值;多余的依赖项会导致不必要的重新计算。
如何使用
To enable this rule using the config file or in the CLI, you can use:
json
{
"plugins": ["react"],
"rules": {
"react/memo-dependencies": "error"
}
}ts
import { defineConfig } from "oxlint";
export default defineConfig({
plugins: ["react"],
rules: {
"react/memo-dependencies": "error",
},
});bash
oxlint --deny react/memo-dependencies --react-plugin版本
此规则在 vnext 中添加。
