feat: 🎸 Enable react-hooks lint rules and fix all stale-closure - #208
Merged
Merged
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enable
react-hookslint rules repo-wide; fix all stale-closure findings; adduseEventCallbackeslint-plugin-react-hookswas installed but none of its rules were enabled — the class of bugs behind the recent Slider and Calendar stale closures was invisible to CI.rules-of-hooksandexhaustive-depsnow run as errors (withrules-of-hooksoff for Storybook CSFrenderfunctions, which are false positives).@vega-ui/hooksexport:useEventCallback— a stable-identity wrapper that always calls the latest handler (the industry "latest ref" pattern à la MUI/Radix/Floating UI), throws in development if called during renderuseScrollSnap:onSnapChanging/onSnapChange/getSnapPointgo throughuseEventCallback, so inline consumer callbacks no longer resubscribe thescrollendlistener and observers on every render; the remaining deps are honestCalendar:onSelectDayno longer freezes the firstonChange— it reads the latest callback throughuseEventCallbackwhile keeping a stable identity (regression-tested by swappingonChangebetween renders)NumberField:decrementno longer clamps against a stalemax; the native non-passivewheellistener is attached only whilechangeOnWheelis enabled and no longer resubscribes whenmin/max/stepor the value changeuseSelection: a consumer-providedresolveRangeno longer cascades identity changes intoselect/expand/toggleCollapsible:onChangeHiddenfires only whenhiddenactually changes — an inline callback no longer re-triggers the notification effect on every parent renderuseMutationObserverper-field options deps,createContextshallow-by-value memoization,SnapScrollerContentunmount-only unregistration)