You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(linter/exhaustive-deps): ignore empty strings passed to additionalHooks option (#14464)
### Issue
Passing an empty string to **additionalHooks** in the
**react-hooks/exhaustive-deps** rule:
`"react-hooks/exhaustive-deps": ["error", { "additionalHooks": "" }],`
causes the linter to consider all functions to be additionalHooks.
### Behaviour in ESLint
Passing an empty string doesn't do anything.
Passing `"()"` causes the same problematic behaviour:
`"react-hooks/exhaustive-deps": ["warn", { additionalHooks: "()" }],`
The same is true for oxlint.
### Suggested fix
Check for empty string.
Since ESLint is able to take an empty string without breaking - so
should oxlint.
Ideally - handle the "()" case too, or leave it as is to match original
behaviour.
### How to test
Add:
`"react-hooks/exhaustive-deps": ["error", { "additionalHooks": "" }],`
to your .oxlintrc.json file
Lint the codebase.
Example:
```
function MyComponent(props) {
const foo = bar.add();
}
```
```
⚠ eslint-plugin-react-hooks(exhaustive-deps): React hook add requires an effect callback.
╭─[exhaustive_deps.tsx:2:23]
1 │ function MyComponent(props) {
2 │ const foo = bar.add();
· ─────────
3 │ }
╰────
help: Did you forget to pass a callback to the hook?
-------- rule config --------
[
{
"additionalHooks": ""
}
]
```
0 commit comments