Commit c9575f6
committed
fix(linter): fix false positive in react/exhaustive deps (#10727)
Fix React exhaustive-deps rule to correctly handle useCallback references
This PR fixes the `exhaustive-deps` rule to no longer consider `useCallback` as a stable value, which was causing incorrect linting behavior. The change:
1. Removes `useCallback` from the stable value check, as it should not be treated like `useRef`
2. Updates tests to reflect this change by:
- Commenting out tests that would cause infinite loops at runtime
- Uncommenting a test case that should now pass
- Adding a test case for the specific issue reported in #9788
closes #9788
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
- **Bug Fixes**
- Improved handling of React hooks by updating which hooks are recognized as stable, specifically adjusting support for useCallback.
- **Tests**
- Updated test coverage: disabled tests for unsupported recursive useCallback cases, enabled a nested callback test, and added a new test case related to a known issue.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->1 parent 62843e6 commit c9575f6
File tree
2 files changed
+53
-23
lines changed- crates/oxc_linter/src
- rules/react
- snapshots
2 files changed
+53
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
893 | 893 | | |
894 | 894 | | |
895 | 895 | | |
896 | | - | |
| 896 | + | |
897 | 897 | | |
898 | 898 | | |
899 | 899 | | |
| |||
2009 | 2009 | | |
2010 | 2010 | | |
2011 | 2011 | | |
2012 | | - | |
2013 | | - | |
2014 | | - | |
2015 | | - | |
2016 | | - | |
2017 | | - | |
2018 | | - | |
2019 | | - | |
2020 | | - | |
2021 | | - | |
2022 | | - | |
2023 | | - | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
| 2016 | + | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
| 2022 | + | |
| 2023 | + | |
| 2024 | + | |
| 2025 | + | |
2024 | 2026 | | |
2025 | 2027 | | |
2026 | 2028 | | |
| |||
3324 | 3326 | | |
3325 | 3327 | | |
3326 | 3328 | | |
3327 | | - | |
| 3329 | + | |
3328 | 3330 | | |
3329 | 3331 | | |
3330 | 3332 | | |
3331 | 3333 | | |
3332 | 3334 | | |
3333 | | - | |
3334 | | - | |
3335 | | - | |
3336 | | - | |
3337 | | - | |
3338 | | - | |
3339 | | - | |
3340 | | - | |
3341 | | - | |
| 3335 | + | |
| 3336 | + | |
| 3337 | + | |
| 3338 | + | |
| 3339 | + | |
| 3340 | + | |
| 3341 | + | |
| 3342 | + | |
3342 | 3343 | | |
3343 | 3344 | | |
3344 | 3345 | | |
| |||
3563 | 3564 | | |
3564 | 3565 | | |
3565 | 3566 | | |
| 3567 | + | |
| 3568 | + | |
| 3569 | + | |
| 3570 | + | |
| 3571 | + | |
| 3572 | + | |
| 3573 | + | |
| 3574 | + | |
| 3575 | + | |
| 3576 | + | |
| 3577 | + | |
3566 | 3578 | | |
3567 | 3579 | | |
3568 | 3580 | | |
| |||
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1907 | 1907 | | |
1908 | 1908 | | |
1909 | 1909 | | |
| 1910 | + | |
| 1911 | + | |
| 1912 | + | |
| 1913 | + | |
| 1914 | + | |
| 1915 | + | |
| 1916 | + | |
| 1917 | + | |
| 1918 | + | |
1910 | 1919 | | |
1911 | 1920 | | |
1912 | 1921 | | |
| |||
2248 | 2257 | | |
2249 | 2258 | | |
2250 | 2259 | | |
| 2260 | + | |
| 2261 | + | |
| 2262 | + | |
| 2263 | + | |
| 2264 | + | |
| 2265 | + | |
| 2266 | + | |
| 2267 | + | |
| 2268 | + | |
0 commit comments