Commit 9965676
authored
fix(linter/exhaustive-deps): ignore empty strings passed to
### 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": ""
}
]
```additionalHooks option (#14464)1 parent a8d542b commit 9965676
1 file changed
+14
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
277 | 277 | | |
278 | 278 | | |
279 | 279 | | |
| 280 | + | |
280 | 281 | | |
281 | 282 | | |
282 | 283 | | |
| |||
4128 | 4129 | | |
4129 | 4130 | | |
4130 | 4131 | | |
| 4132 | + | |
| 4133 | + | |
| 4134 | + | |
| 4135 | + | |
| 4136 | + | |
| 4137 | + | |
| 4138 | + | |
| 4139 | + | |
4131 | 4140 | | |
4132 | 4141 | | |
4133 | 4142 | | |
| |||
4269 | 4278 | | |
4270 | 4279 | | |
4271 | 4280 | | |
4272 | | - | |
| 4281 | + | |
| 4282 | + | |
| 4283 | + | |
| 4284 | + | |
| 4285 | + | |
4273 | 4286 | | |
4274 | 4287 | | |
4275 | 4288 | | |
| |||
0 commit comments