
Security News
Bun 1.2.19 Adds Isolated Installs for Better Monorepo Support
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
@seiyab/eslint-plugin-react-hooks
Advanced tools
@seiyab/eslint-plugin-react-hooks
This is alternative to eslint-plugin-react-hooks because of https://github.com/facebook/react/issues/16265
Assuming you already have ESLint installed, run:
# npm
npm install @seiyab/eslint-plugin-react-hooks --save-dev
# yarn
yarn add @seiyab/eslint-plugin-react-hooks --dev
Then extend the recommended eslint config:
{
"extends": [
// ...
"plugin:@seiyab/react-hooks/recommended"
]
}
If you want more fine-grained configuration, you can instead add a snippet like this to your ESLint configuration file:
{
"plugins": [
// ...
"@seiyab/eslint-plugin-react-hooks"
],
"rules": {
// ...
"@seiyab/react-hooks/rules-of-hooks": "error",
"@seiyab/react-hooks/exhaustive-deps": "warn"
}
}
exhaustive-deps
can be configured to validate dependencies of custom Hooks with the additionalHooks
option.
This option accepts a regex to match the names of custom Hooks that have dependencies.
{
"rules": {
// ...
"@seiyab/react-hooks/exhaustive-deps": ["warn", {
"additionalHooks": "(useMyCustomHook|useMyOtherCustomHook)"
}]
}
}
We suggest to use this option very sparingly, if at all. Generally saying, we recommend most custom Hooks to not use the dependencies argument, and instead provide a higher-level API that is more focused around a specific use case.
You may find exhaustive-deps
requires entire props
if you use something like props.doSomething()
in hooks.
This is intended behavior because props
is referred as this
by doSomething
.
You can resolve it by destructuring as exhaustive-deps
suggests.
However, in some cases, you may want to avoid destructuring because of your coding style or conflict with no-shadow
.
In the case, ignoreThisDependency
may help.
{
"rules": {
// ...
"@seiyab/react-hooks/exhaustive-deps": ["warn", {
"ignoreThisDependency": "props"
}]
}
}
Valid options are never
(default behavior), props
, always
.
Please refer to the Rules of Hooks documentation and the Hooks FAQ to learn more about this rule.
MIT
FAQs
ESLint rules for React Hooks
The npm package @seiyab/eslint-plugin-react-hooks receives a total of 2,369 weekly downloads. As such, @seiyab/eslint-plugin-react-hooks popularity was classified as popular.
We found that @seiyab/eslint-plugin-react-hooks demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2.19 introduces isolated installs for smoother monorepo workflows, along with performance boosts, new tooling, and key compatibility fixes.
Security News
Popular npm packages like eslint-config-prettier were compromised after a phishing attack stole a maintainer’s token, spreading malicious updates.
Security News
/Research
A phishing attack targeted developers using a typosquatted npm domain (npnjs.com) to steal credentials via fake login pages - watch out for similar scams.