-
-
Notifications
You must be signed in to change notification settings - Fork 523
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(useExhaustiveDependencies): add option to disable errors for une…
…cessary dependencies (#4135)
- Loading branch information
1 parent
fc9c4cf
commit 10a1371
Showing
8 changed files
with
143 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...nalyze/tests/specs/correctness/useExhaustiveDependencies/reportUnnecessaryDependencies.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import {useEffect} from "react"; | ||
|
||
// should not report errors for the unused `b` when the reportUnnecessaryDependencies option is false | ||
function ReportUnnecessaryDependencies() { | ||
const [b] = useState("hello") | ||
const [a] = useState("world"); | ||
|
||
useEffect(() => { | ||
console.log(a); | ||
}, [a, b]); | ||
|
||
return a; | ||
} |
21 changes: 21 additions & 0 deletions
21
...e/tests/specs/correctness/useExhaustiveDependencies/reportUnnecessaryDependencies.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
source: crates/biome_js_analyze/tests/spec_tests.rs | ||
expression: reportUnnecessaryDependencies.js | ||
--- | ||
# Input | ||
```jsx | ||
import {useEffect} from "react"; | ||
|
||
// should not report errors for the unused `b` when the reportUnnecessaryDependencies option is false | ||
function ReportUnnecessaryDependencies() { | ||
const [b] = useState("hello") | ||
const [a] = useState("world"); | ||
|
||
useEffect(() => { | ||
console.log(a); | ||
}, [a, b]); | ||
|
||
return a; | ||
} | ||
|
||
``` |
15 changes: 15 additions & 0 deletions
15
...ts/specs/correctness/useExhaustiveDependencies/reportUnnecessaryDependencies.options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"$schema": "../../../../../../packages/@biomejs/biome/configuration_schema.json", | ||
"linter": { | ||
"rules": { | ||
"correctness": { | ||
"useExhaustiveDependencies": { | ||
"level": "error", | ||
"options": { | ||
"reportUnnecessaryDependencies": false | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,5 @@ hooks_incorrect_options.json:9:7 deserialize ━━━━━━━━━━━ | |
|
||
i Known keys: | ||
|
||
- reportUnnecessaryDependencies | ||
- hooks | ||
|
||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.