@10stars/oxlint-plugin-react-hooks
v1.2.0
Published
Downloads
1,256
Readme
@10stars/oxlint-plugin-react-hooks
Oxlint JS plugin for React hooks exhaustive-deps rule with enhanced configuration options.
Fork of eslint-plugin-react-hooks & eslint-plugin-react-hooks-configurable adapted for oxlint's JS plugin system.
Installation
bun add @10stars/oxlint-plugin-react-hooksOxlint Configuration
{
"jsPlugins": ["@10stars/oxlint-plugin-react-hooks"],
"rules": {
"react/exhaustive-deps": "off",
"@10stars/react-hooks/exhaustive-deps": "warn"
}
}Built-in Defaults
The rule ships with opinionated defaults so you don't have to repeat them in every config:
ignoreThisDependency:"always"additionalHooks:(useUpdateEffect|useIsomorphicLayoutEffect|useDeepCompareEffect|useShallowCompareEffect|useCustomCompareEffect)additionalStableHooks:{ "useToggle": [false, true], "useToggleOnce": [false, true], "useRefCallback": [false, true], "useIsMounted": true }hookNamespaces:["React", "hooks"]
Any option you pass is merged on top of these defaults and takes precedence. Built-in entries can be overridden per key (e.g. set useToggle to false) but cannot be removed.
Rule Options
ignoreThisDependency
Control how this references (like props.doSomething()) are handled in dependency arrays.
Valid options: "never", "props", "always" (default: "always")
{
"@10stars/react-hooks/exhaustive-deps": [
"warn",
{
"ignoreThisDependency": "always"
}
]
}additionalHooks
Validate dependencies of custom hooks. Supports position configuration for where the callback argument is located.
{
"additionalHooks": {
"(useMyCustomHook|useMyOtherCustomHook)": 0,
"useMyImperativeHandle": 1
}
}additionalStableHooks
Mark custom hooks as returning stable values (fully or partially).
{
"additionalStableHooks": {
"use.+Ref": true,
"useMyCustomUseState": [false, true],
"useMyQuery": { "data": false, "refetch": true }
}
}hookNamespaces
Namespaces a hook may be called through, so hooks.useUpdateEffect() is treated the same as
useUpdateEffect(). Without a matching entry the callee is a member expression, which every
name-based lookup rejects: the hook is then neither dep-checked nor recognised as returning stable
values, and it fails silently rather than warning.
Your list is added to the defaults, never replaces them, so React cannot be lost.
{
"hookNamespaces": ["React", "hooks", "sharedHooks"]
}