-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[security_solution] enable react-hooks/exhaustive-deps #68470
[security_solution] enable react-hooks/exhaustive-deps #68470
Conversation
* Enable `react-hooks/exhaustive-deps` rule for security_solution * Disable it anywhere that it would catch an issue
@@ -46,7 +46,7 @@ export const useRules = ({ | |||
let isSubscribed = true; | |||
const abortCtrl = new AbortController(); | |||
|
|||
async function fetchData(forceReload: boolean = false) { | |||
async function fetchData() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removing unused parameters
@@ -80,7 +80,7 @@ export const useRules = ({ | |||
|
|||
fetchData(); | |||
reFetchRules.current = (refreshPrePackagedRule: boolean = false) => { | |||
fetchData(true); | |||
fetchData(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removing unused parameters
}, [ | ||
pagination.page, | ||
pagination.perPage, | ||
filterOptions.filter, | ||
filterOptions.sortField, | ||
filterOptions.sortOrder, | ||
// eslint-disable-next-line react-hooks/exhaustive-deps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing a sort
on every render is not generally advisable. Even if it happened to be harmless here, when reading this code I feel the urge to confirm that filterOptions.tags
is of a constant size.
Might be worth scheduling work to improve. We could probably just wrap it in a useMemo
if nothing else.
@@ -91,8 +91,10 @@ export const Create = React.memo(() => { | |||
const onSubmit = useCallback(async () => { | |||
const { isValid, data } = await form.submit(); | |||
if (isValid) { | |||
// `postCase`'s type is incorrect, it actually returns a promise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment correct? I think we could update the type.
@@ -50,7 +50,7 @@ const FlyoutPaneComponent: React.FC<FlyoutPaneComponentProps> = ({ | |||
const dispatch = useDispatch(); | |||
|
|||
const onResizeStop: ResizeCallback = useCallback( | |||
(e, direction, ref, delta) => { | |||
(_e, _direction, _ref, delta) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tell tsserver/tsc to ignore the fact that these are unused
await deleteTimelines(timelineIds); | ||
}, | ||
[deleteTimelines] | ||
); | ||
|
||
/** Invoked when the user clicks the action to delete the selected timelines */ | ||
const onDeleteSelected: OnDeleteSelected = useCallback(async () => { | ||
// The type for `deleteTimelines` is incorrect, it returns a Promise |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this comment right? We could probably fix the type.
influencersOrCriteriaToString(criteriaFields), | ||
startDate, | ||
endDate, | ||
skip, | ||
userPermissions, | ||
// eslint-disable-next-line react-hooks/exhaustive-deps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth improving this, as sorting something each render could hinder performance.
@@ -46,6 +46,7 @@ export const GroupsFilterPopoverComponent = ({ | |||
|
|||
useEffect(() => { | |||
onSelectedGroupsChanged(selectedGroups); | |||
// eslint-disable-next-line react-hooks/exhaustive-deps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another instance of sorting in render. Thoughts on these?
}, [ | ||
featureIndex, | ||
// eslint-disable-next-line react-hooks/exhaustive-deps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another sort in render
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
* Enable `react-hooks/exhaustive-deps` rule for security_solution * Disable it anywhere that it would catch an issue # Conflicts: # x-pack/plugins/security_solution/public/common/components/exceptions/viewer/exception_entries.tsx
* master: [ML] DFAnalytics results: ensure ml result fields are shown in data grid (elastic#68305) [security_solution] enable react-hooks/exhaustive-deps (elastic#68470) Closes elastic#66867 by adding missing, requried API params (elastic#68465) [Telemetry] collect number of visualization saved in the past 7, 30 and 90 days (elastic#67865) [Logs UI] View in context tweaks (elastic#67777) Kibana developer examples landing page (elastic#67049) Bump decompress package version (elastic#68386) fix elastic#66185 (elastic#66186) Bump pdfmake package version (elastic#68395) Unskip embeddables/adding_children suite (elastic#68111) Add embed mode options in the Share UI (elastic#58435) Adding key to avoid react warning (elastic#68491)
* Enable `react-hooks/exhaustive-deps` rule for security_solution * Disable it anywhere that it would catch an issue # Conflicts: # x-pack/plugins/security_solution/public/common/components/exceptions/viewer/exception_entries.tsx
Pinging @elastic/siem (Team:SIEM) |
Pinging @elastic/security-solution (Team: SecuritySolution) |
Summary
react-hooks/exhaustive-deps
rule for security_solutionChecklist
Delete any items that are not applicable to this PR.
For maintainers