Enable react-hooks/exhaustive-deps linter rule#3471
Conversation
Closes jaegertracing#3445 Signed-off-by: Taanvi Khevaria <[email protected]>
1e752f4 to
7f247d8
Compare
The component was incorrectly trying to use a navigate prop that does not exist. The withRouteProps HOC provides a history object with a push method Signed-off-by: Taanvi Khevaria <[email protected]>
57547e6 to
01cab1b
Compare
| viewModifiers: new Map(), | ||
| }, | ||
| navigate: jest.fn(), | ||
| history: { push: jest.fn() }, |
There was a problem hiding this comment.
how is this change related to the linter?
yurishkuro
left a comment
There was a problem hiding this comment.
there seem to be a lot of unrelated changes in this PR.
|
@yurishkuro The ~10k lines are from package-lock.json (adding the eslint-plugin-react-hooks dependency). I've removed the unrelated DeepDependencies changes. |
|
all commits must be signed |
There was a problem hiding this comment.
Pull request overview
This pull request enables the react-hooks/exhaustive-deps ESLint rule to catch missing dependencies in React hooks, improving code correctness and preventing potential bugs from stale closures.
Changes:
- Added
eslint-plugin-react-hooksdependency and configured bothrules-of-hooksandexhaustive-depsrules - Fixed 12 hook dependency violations across 6 files by adding missing dependencies to useEffect and useCallback hooks
- Added an eslint-disable comment for an intentional mount-only useEffect in SearchTracePage
Reviewed changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| package.json | Added eslint-plugin-react-hooks ^7.0.1 dependency; alphabetized ajv entry |
| package-lock.json | Installed eslint-plugin-react-hooks and its dependencies (hermes-parser, zod, etc.) |
| eslint.config.js | Configured react-hooks plugin and enabled rules-of-hooks and exhaustive-deps rules |
| packages/jaeger-ui/src/utils/documentTitle.ts | Fixed cleanup function to capture ref value in local variable before closure |
| packages/jaeger-ui/src/components/TracePage/TraceTimelineViewer/index.tsx | Destructured props and updated useCallback dependencies to include action functions and trace.spans |
| packages/jaeger-ui/src/components/TracePage/TraceTimelineViewer/SpanDetail/AccordionEvents.tsx | Added spanID to useEffect dependency array |
| packages/jaeger-ui/src/components/TracePage/ArchiveNotifier/index.tsx | Destructured props and added acknowledge to useEffect dependencies |
| packages/jaeger-ui/src/components/SearchTracePage/index.tsx | Added eslint-disable comment for intentional mount-only useEffect |
| packages/jaeger-ui/src/components/SearchTracePage/SearchResults/ScatterPlot.tsx | Added calculateContainerWidth to useEffect dependency array |
| packages/jaeger-ui/src/components/Monitor/ServicesView/index.tsx | Refactored to destructure props and updated useCallback/useEffect dependencies |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Taanvi Khevaria <[email protected]>
Signed-off-by: Taanvi Khevaria <[email protected]>
Signed-off-by: Taanvi Khevaria <[email protected]>
d468f72 to
5d39a76
Compare
|
@yurishkuro please review it now |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3471 +/- ##
==========================================
+ Coverage 88.26% 88.31% +0.05%
==========================================
Files 299 299
Lines 9485 9486 +1
Branches 2419 2509 +90
==========================================
+ Hits 8372 8378 +6
+ Misses 1109 1104 -5
Partials 4 4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Taanvi Khevaria <[email protected]>
| // This may require "eslint-disable-next-line react-hooks/exhaustive-deps" | ||
| // in the future if we enable this linter. | ||
| // https://github.com/jaegertracing/jaeger-ui/issues/3445 | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps |
There was a problem hiding this comment.
disabling linter must be done with a comment explaining why
yurishkuro
left a comment
There was a problem hiding this comment.
mostly LGTM, just two questions
Signed-off-by: Taanvi Khevaria <[email protected]>
Closes jaegertracing#3445 ## Which problem is this PR solving? - closes jaegertracing#3445 ## Description of the changes - Add eslint-plugin-react-hooks dependency - Fix 12 violations across 6 files by adding missing hook dependencies - Add eslint-disable comment for intentional mount-only useEffect in SearchTracePage ## How was this change tested? - npm run eslint passes with 0 errors - npm run test passes ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [x] I have added unit tests for the new functionality - [x] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `npm run lint` and `npm run test` --------- Signed-off-by: Taanvi Khevaria <[email protected]> Co-authored-by: Yuri Shkuro <[email protected]>
Closes #3445
Which problem is this PR solving?
Description of the changes
How was this change tested?
Checklist
jaeger:make lint testjaeger-ui:npm run lintandnpm run test