lint: Redirect react-redux imports through our type-wrapper module#5093
Merged
chrisbobbe merged 2 commits intozulip:mainfrom Nov 2, 2021
Merged
lint: Redirect react-redux imports through our type-wrapper module#5093chrisbobbe merged 2 commits intozulip:mainfrom
chrisbobbe merged 2 commits intozulip:mainfrom
Conversation
Now we have no direct imports of react-redux at all except the ones in this file itself. That'll make things cleaner for adding a lint rule that we don't make such imports.
This lets us catch bugs where, for example, a selector passed to `useSelector` doesn't return the type that the caller wants it to. Now that we have a distinction between `useSelector` and `useGlobalSelector`, it also lets us catch bugs where `useSelector` is mentioned but `useGlobalSelector` is what's actually wanted. For the moment these are both purely type-wrappers of the upstream `useSelector`, so such a bug would have no effect at runtime... but in the future a per-account state will be a different actual object from a global state, so one or both of them will not pass its selector the same state object as the upstream `useSelector` would, and then such a bug would likely cause a crash.
Contributor
|
Thanks, LGTM! Merged. |
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.
This lets us catch bugs where, for example, a selector passed to
useSelectordoesn't return the type that the caller wants it to.Now that we have a distinction between
useSelectoranduseGlobalSelector, it also lets us catch bugs whereuseSelectorismentioned but
useGlobalSelectoris what's actually wanted. For themoment these are both purely type-wrappers of the upstream
useSelector, so such a bug would have no effect at runtime... but inthe future a per-account state will be a different actual object from
a global state, so one or both of them will not pass its selector the
same state object as the upstream
useSelectorwould, and then such abug would likely cause a crash.