-
-
Notifications
You must be signed in to change notification settings - Fork 654
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
flow [nfc]: Mark specific rules that are being suppressed. #4433
flow [nfc]: Mark specific rules that are being suppressed. #4433
Conversation
7397e21
to
e5379a2
Compare
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.
Thanks! Will be glad to start using this feature. Comments below.
src/compose/ComposeMenu.js
Outdated
// Upstream API is unclear. | ||
// $FlowFixMe[sketchy-null-bool] | ||
const error: string | null = response.error || null; |
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.
Let's try to keep the explanatory text after the $FlowFixMe, so between the $FlowFixMe and the code it's about. That helps keep it clear what text is there to explain the fixme, and what's there to explain something else about the code.
In particular that will help us delete the explanatory text when we delete the fixme, because of either a Flow upgrade or an improvement in the types. Otherwise it'd be easy to pretty often leave it behind because the person deleting the fixme didn't fully understand the comment at that moment, and then there'd be a puzzling comment lingering there to confuse people.
When it's too long for one line, we can use a /* … */
comment, like in a few of our existing comments and in the docs at https://flow.org/en/docs/errors/ .
src/boot/store.js
Outdated
// Store data through our own wrapper for AsyncStorage, in particular | ||
// to get compression. | ||
// $FlowFixMe: https://github.com/rt2zz/redux-persist/issues/823 | ||
// https://github.com/rt2zz/redux-persist/issues/823 | ||
// $FlowFixMe[incompatible-variance] | ||
storage: ZulipAsyncStorage, |
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.
This is another nice illustration of how it's helpful to keep the text explaining the fixme explicitly attached to the fixme. As is, it looks like this issue link is probably there to add more context on the "Store data through … compression" comment, rather than to explain the fixme.
src/webview/html/template.js
Outdated
@@ -14,7 +14,7 @@ import escape from 'lodash.escape'; | |||
* template`Hello $\!${&<world}` -> 'Hello $!&<world' | |||
*/ | |||
export default (strings: string[], ...values: Array<string | number>) => { | |||
// $FlowFixMe github.com/facebook/flow/issues/2616 | |||
// $FlowFixMe[prop-missing] github.com/facebook/flow/issues/2616 |
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.
Separately: this change in Flow called my attention to a feature/convention that's long existed, and would be handy to use here!
$FlowIssue
: for a type error that you suspect is an issue with Flow
https://flow.org/en/docs/errors/
No rush to do this at the same time as adding the error codes, but probably we should use $FlowIssue
for at least the cases where we actually link to an issue in the Flow tracker 🙂
Thanks for the review! Revision pushed. |
e5379a2
to
d2d8630
Compare
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.
Thanks for the revision! Small comments below -- otherwise looks good.
src/compose/ComposeBox.js
Outdated
{/* | ||
`MentionWarnings` should use a type-checked `connect` | ||
$FlowFixMe[incompatible-use] | ||
*/} |
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.
Here's one remaining comment that gets out of order.
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.
Ah, indeed, thanks (and for the other one too).
/* realm_ is URL | void, but complains of out-of-bounds access | ||
$FlowFixMe[invalid-tuple-index] */ |
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.
Here's another (I think the only other.)
// Flow bug: https://github.com/facebook/flow/issues/6110 | ||
case (ZulipVersion.prototype: $FlowFixMe): | ||
case (ZulipVersion.prototype: $FlowIssue): |
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.
nit in commit message:
flow [nfc]: Better indicate flow bugs in a few suppressions.
Should read "Flow bugs".
When we start using Flow v0.137+, along with React Native v0.64 (that's issue zulip#4426), we'll be asked to specify what rule(s) we're suppressing with each suppression comment. Conveniently, the warnings will tell us the applicable rule(s) we need to write down. So, having peeked ahead at the warnings seen in the RN 0.64.0-rc.2 world, get a head start on doing so. There will probably be more of these (we haven't yet started enforcing the requirement now, so some unmarked `$FlowFixMe`s will naturally accumulate), but we might as well get this chunk out of the way.
d2d8630
to
c0ffc37
Compare
Thanks for the review! Merged, after fixing those nits. |
Like with the other Flow upgrades in this series, we're departing from our usual practice of only upgrading Flow along with React Native. But we seem to get away with this one -- it doesn't flag any new errors in node_modules/react-native! One highlight of this version in the changelog is "Standardized error suppression syntax, added ability to suppress errors based on error codes" [1]. We couldn't have taken this upgrade without first removing our use of the `suppress_comment` option in our .flowconfig [2]. One slightly annoying feature of the standardized syntax (still present in v0.146, the latest) is that, when you put more than one error-code-specific suppression in a multi-line comment, Flow will ignore some of them. Neither the doc [3] nor the suppression-syntax tests [4] suggest that multiple suppressions in one multi-line comment is supported. We'd been using multi-line comments to keep a suppression's explanatory text (when it's too long for one line) between the suppression and the code that it's about [5]. So, to keep doing that: work around by using single-line suppression comments for all but the last error-code-specific suppression (chosen arbitrarily), and use a multi-line comment for that last one, squeezing the explanatory text in there. Apparently this Flow version finds more to complain about at some of our existing suppressions, so this workaround gets a good bit of exercise, especially in src/boot/store.js. [1] https://github.com/facebook/flow/blob/master/Changelog.md#01270 [2] https://flow.org/en/docs/config/options/#toc-suppress-comment-regex [3] https://flow.org/en/docs/errors/ [4] https://github.com/facebook/flow/blob/v0.146.0/tests/error_codes/test.js [5] zulip#4433 (comment)
Like with the other Flow upgrades in this series, we're departing from our usual practice of only upgrading Flow along with React Native. But we seem to get away with this one -- it doesn't flag any new errors in node_modules/react-native! One highlight of this version in the changelog is "Standardized error suppression syntax, added ability to suppress errors based on error codes" [1]. We couldn't have taken this upgrade without first removing our use of the `suppress_comment` option in our .flowconfig [2]. One slightly annoying feature of the standardized syntax (still present in v0.146, the latest) is that, when you put more than one error-code-specific suppression in a multi-line comment, Flow will ignore some of them. Neither the doc [3] nor the suppression-syntax tests [4] suggest that multiple suppressions in one multi-line comment is supported. We'd been using multi-line comments to keep a suppression's explanatory text (when it's too long for one line) between the suppression and the code that it's about [5]. So, to keep doing that: work around by using single-line suppression comments for all but the last error-code-specific suppression (chosen arbitrarily), and use a multi-line comment for that last one, squeezing the explanatory text in there. Apparently this Flow version finds more to complain about at some of our existing suppressions, so this workaround gets a good bit of exercise, especially in src/boot/store.js. [1] https://github.com/facebook/flow/blob/master/Changelog.md#01270 [2] https://flow.org/en/docs/config/options/#toc-suppress-comment-regex [3] https://flow.org/en/docs/errors/ [4] https://github.com/facebook/flow/blob/v0.146.0/tests/error_codes/test.js [5] zulip#4433 (comment)
This is another round in the spirit of zulip#4433, to prepare for Flow v0.132 and later; there's this in the changelog entry [1]: > Added warnings against suppressions without error codes As we noted there, we still haven't enforced that suppressions have error codes, but at least we can clean up these ones that have crept in. [1] https://github.com/facebook/flow/blob/master/Changelog.md#01320
This is another round in the spirit of zulip#4433, to prepare for Flow v0.132 and later; there's this in the changelog entry [1]: > Added warnings against suppressions without error codes As we noted there, we still haven't enforced that suppressions have error codes, but at least we can clean up these ones that have crept in. [1] https://github.com/facebook/flow/blob/master/Changelog.md#01320
When we start using Flow v0.137+, along with React Native v0.64
(that's issue #4426), we'll be asked to specify what rule(s) we're
suppressing with each suppression comment. Conveniently, the
warnings will tell us the applicable rule(s) we need to write down.
So, having peeked ahead at the warnings seen in the RN 0.64.0-rc.2
world, get a head start on doing so. There will probably be more of
these (we haven't yet started enforcing the requirement now, so some
unmarked
$FlowFixMe
s will naturally accumulate), but we might aswell get this chunk out of the way.