From 4a4bf82480d166f72f95b5f5638da7aedbc4fa8e Mon Sep 17 00:00:00 2001 From: Ray Kraesig Date: Thu, 7 Nov 2019 12:32:51 -0800 Subject: [PATCH] lint: make Props types readonly (step 3 of 3) Make the last few Props types [1] readonly. This is done manually. The few remaining Props types fall largely into two categories: - types defined using `$Diff`; and - nonempty exact types defined inline. The former have been manually wrapped with `$ReadOnly`. The latter have had their entries prefixed with `+`, which for exact types has essentially the same effect. (See, e.g., the Flow documentation [2] and the original PR [3].) [1] Or at least, the last few Props types detected by `eslint-plugin-flowtype`. [2] https://flow.org/en/docs/types/interfaces/#toc-covariant-read-only-properties-on-interfaces [3] https://github.com/gajus/eslint-plugin-flowtype/pull/400 --- src/account-info/ProfileCard.js | 6 +++--- src/boot/TranslationProvider.js | 2 +- src/common/InputWithClearButton.js | 2 +- src/common/PasswordInput.js | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/account-info/ProfileCard.js b/src/account-info/ProfileCard.js index 3772fa887b4..e2298cbd161 100644 --- a/src/account-info/ProfileCard.js +++ b/src/account-info/ProfileCard.js @@ -26,7 +26,7 @@ const styles = StyleSheet.create({ }, }); -class SetStatusButton extends PureComponent<{| dispatch: Dispatch |}> { +class SetStatusButton extends PureComponent<{| +dispatch: Dispatch |}> { onPress = () => { const { dispatch } = this.props; dispatch(navigateToUserStatus()); @@ -39,7 +39,7 @@ class SetStatusButton extends PureComponent<{| dispatch: Dispatch |}> { } } -class SwitchAccountButton extends PureComponent<{| dispatch: Dispatch |}> { +class SwitchAccountButton extends PureComponent<{| +dispatch: Dispatch |}> { onPress = () => { this.props.dispatch(navigateToAccountPicker()); }; @@ -51,7 +51,7 @@ class SwitchAccountButton extends PureComponent<{| dispatch: Dispatch |}> { } } -class LogoutButton extends PureComponent<{| dispatch: Dispatch |}> { +class LogoutButton extends PureComponent<{| +dispatch: Dispatch |}> { onPress = () => { const { dispatch } = this.props; dispatch(tryStopNotifications()); diff --git a/src/boot/TranslationProvider.js b/src/boot/TranslationProvider.js index d86896c8d99..22a9fc207ca 100644 --- a/src/boot/TranslationProvider.js +++ b/src/boot/TranslationProvider.js @@ -54,7 +54,7 @@ const makeGetText = (intl: IntlShape): GetText => { * vs. https://reactjs.org/docs/legacy-context.html . */ class TranslationContextTranslator extends PureComponent<{ - children: React$Node, + +children: React$Node, }> { context: { intl: IntlShape }; diff --git a/src/common/InputWithClearButton.js b/src/common/InputWithClearButton.js index 939096f870a..1afbb2b4cb4 100644 --- a/src/common/InputWithClearButton.js +++ b/src/common/InputWithClearButton.js @@ -14,7 +14,7 @@ const componentStyles = StyleSheet.create({ }, }); -type Props = $Diff; +type Props = $ReadOnly<$Diff>; type State = {| canBeCleared: boolean, diff --git a/src/common/PasswordInput.js b/src/common/PasswordInput.js index 3d9e624c354..918015829cc 100644 --- a/src/common/PasswordInput.js +++ b/src/common/PasswordInput.js @@ -24,10 +24,10 @@ const styles = StyleSheet.create({ // Prettier wants a ", >" here, which is silly. // prettier-ignore -type Props = $Diff; + { secureTextEntry: mixed, autoCorrect: mixed, autoCapitalize: mixed }>>; type State = {| isHidden: boolean,