Skip to content

Commit

Permalink
fix(lint): don't report missing dependency on incomplete statement (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
arendjr authored Jan 9, 2025
1 parent 846e4a4 commit 016046e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ fn capture_needs_to_be_in_the_dependency_list(
| AnyJsBindingDeclaration::JsArrayBindingPatternRestElement(_)
| AnyJsBindingDeclaration::JsObjectBindingPatternProperty(_)
| AnyJsBindingDeclaration::JsObjectBindingPatternRest(_)
| AnyJsBindingDeclaration::JsObjectBindingPatternShorthandProperty(_) => true,
| AnyJsBindingDeclaration::JsObjectBindingPatternShorthandProperty(_) => false,

// This should be unreachable because of the test if the capture is imported
AnyJsBindingDeclaration::JsShorthandNamedImportSpecifier(_)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import {useCallback,utte } from"react";
function{
const [width,(dh] = useCallback(() =>{ width) }, [w
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
source: crates/biome_js_analyze/tests/spec_tests.rs
expression: issue4567.js
---
# Input
```js
import {useCallback,utte } from"react";
function{
const [width,(dh] = useCallback(() =>{ width) }, [w

```
# Diagnostics
```
issue4567.js:3:24 lint/correctness/useExhaustiveDependencies ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

! This hook specifies more dependencies than necessary: w

1import {useCallback,utte } from"react";
2function{
> 3 │ const [width,(dh] = useCallback(() =>{ width) }, [w
^^^^^^^^^^^
4

i This dependency can be removed from the list.

1import {useCallback,utte } from"react";
2function{
> 3 │ const [width,(dh] = useCallback(() =>{ width) }, [w
^
4


```

0 comments on commit 016046e

Please sign in to comment.