From a21b8b736054ebfd80bd9d0497b04f296174fe65 Mon Sep 17 00:00:00 2001 From: nd-02110114 Date: Tue, 30 Oct 2018 14:03:18 -0700 Subject: [PATCH] Remove var in RNTester (#22019) Summary: I removed `var` in RNTester. - [x] npm run prettier - [x] npm run flow-check-ios - [x] npm run flow-check-android [GENERAL] [ENHANCEMENT] [RNTester] - remove `var` Pull Request resolved: https://github.com/facebook/react-native/pull/22019 Differential Revision: D12843071 Pulled By: TheSavior fbshipit-source-id: 3652ea91b3ab92c367332cbe2ff7de0343508dad --- RNTester/js/ARTExample.js | 8 ++++---- .../js/AccessibilityAndroidExample.android.js | 14 +++++++------- RNTester/js/AccessibilityIOSExample.js | 6 +++--- RNTester/js/ActionSheetIOSExample.js | 18 +++++++++--------- RNTester/js/AlertExample.js | 12 ++++++------ RNTester/js/AlertIOSExample.js | 10 +++++----- RNTester/js/AnimatedExample.js | 12 ++++++------ RNTester/js/AppStateExample.js | 2 +- RNTester/js/AssetScaledImageExample.js | 10 +++++----- RNTester/js/AsyncStorageExample.js | 16 ++++++++-------- 10 files changed, 54 insertions(+), 54 deletions(-) diff --git a/RNTester/js/ARTExample.js b/RNTester/js/ARTExample.js index 06d483a5b..e78b19e5d 100644 --- a/RNTester/js/ARTExample.js +++ b/RNTester/js/ARTExample.js @@ -10,13 +10,13 @@ 'use strict'; -var React = require('react'); -var ReactNative = require('react-native'); -var {ART, Platform, View} = ReactNative; +const React = require('react'); +const ReactNative = require('react-native'); +const {ART, Platform, View} = ReactNative; const {Surface, Path, Group, Transform, Shape} = ART; -var scale = Platform.isTV ? 4 : 1; +const scale = Platform.isTV ? 4 : 1; class ARTExample extends React.Component<{}> { render() { diff --git a/RNTester/js/AccessibilityAndroidExample.android.js b/RNTester/js/AccessibilityAndroidExample.android.js index 9e42a1e57..0989f9f62 100644 --- a/RNTester/js/AccessibilityAndroidExample.android.js +++ b/RNTester/js/AccessibilityAndroidExample.android.js @@ -9,9 +9,9 @@ 'use strict'; -var React = require('react'); -var ReactNative = require('react-native'); -var { +const React = require('react'); +const ReactNative = require('react-native'); +const { AccessibilityInfo, StyleSheet, Text, @@ -20,10 +20,10 @@ var { TouchableWithoutFeedback, } = ReactNative; -var RNTesterBlock = require('./RNTesterBlock'); -var RNTesterPage = require('./RNTesterPage'); +const RNTesterBlock = require('./RNTesterBlock'); +const RNTesterPage = require('./RNTesterPage'); -var importantForAccessibilityValues = [ +const importantForAccessibilityValues = [ 'auto', 'yes', 'no', @@ -293,7 +293,7 @@ class AccessibilityAndroidExample extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ embedded: { backgroundColor: 'yellow', padding: 10, diff --git a/RNTester/js/AccessibilityIOSExample.js b/RNTester/js/AccessibilityIOSExample.js index 76a05adb0..fcae42844 100644 --- a/RNTester/js/AccessibilityIOSExample.js +++ b/RNTester/js/AccessibilityIOSExample.js @@ -10,9 +10,9 @@ 'use strict'; -var React = require('react'); -var ReactNative = require('react-native'); -var {AccessibilityInfo, Text, View, TouchableOpacity} = ReactNative; +const React = require('react'); +const ReactNative = require('react-native'); +const {AccessibilityInfo, Text, View, TouchableOpacity} = ReactNative; class AccessibilityIOSExample extends React.Component<{}> { render() { diff --git a/RNTester/js/ActionSheetIOSExample.js b/RNTester/js/ActionSheetIOSExample.js index e0850aced..36e3d9e81 100644 --- a/RNTester/js/ActionSheetIOSExample.js +++ b/RNTester/js/ActionSheetIOSExample.js @@ -10,13 +10,13 @@ 'use strict'; -var React = require('react'); -var ReactNative = require('react-native'); -var {ActionSheetIOS, StyleSheet, takeSnapshot, Text, View} = ReactNative; +const React = require('react'); +const ReactNative = require('react-native'); +const {ActionSheetIOS, StyleSheet, takeSnapshot, Text, View} = ReactNative; -var BUTTONS = ['Option 0', 'Option 1', 'Option 2', 'Delete', 'Cancel']; -var DESTRUCTIVE_INDEX = 3; -var CANCEL_INDEX = 4; +const BUTTONS = ['Option 0', 'Option 1', 'Option 2', 'Delete', 'Cancel']; +const DESTRUCTIVE_INDEX = 3; +const CANCEL_INDEX = 4; class ActionSheetExample extends React.Component<{}, $FlowFixMeState> { state = { @@ -108,7 +108,7 @@ class ShareActionSheetExample extends React.Component< }, error => alert(error), (completed, method) => { - var text; + let text; if (completed) { text = `Shared via ${method}`; } else { @@ -148,7 +148,7 @@ class ShareScreenshotExample extends React.Component<{}, $FlowFixMeState> { }, error => alert(error), (completed, method) => { - var text; + let text; if (completed) { text = `Shared via ${method}`; } else { @@ -162,7 +162,7 @@ class ShareScreenshotExample extends React.Component<{}, $FlowFixMeState> { }; } -var style = StyleSheet.create({ +const style = StyleSheet.create({ button: { marginBottom: 10, fontWeight: '500', diff --git a/RNTester/js/AlertExample.js b/RNTester/js/AlertExample.js index 3f399d671..fd888a73a 100644 --- a/RNTester/js/AlertExample.js +++ b/RNTester/js/AlertExample.js @@ -9,14 +9,14 @@ 'use strict'; -var React = require('react'); -var ReactNative = require('react-native'); -var {Alert, StyleSheet, Text, TouchableHighlight, View} = ReactNative; +const React = require('react'); +const ReactNative = require('react-native'); +const {Alert, StyleSheet, Text, TouchableHighlight, View} = ReactNative; -var RNTesterBlock = require('./RNTesterBlock'); +const RNTesterBlock = require('./RNTesterBlock'); // corporate ipsum > lorem ipsum -var alertMessage = +const alertMessage = 'Credibly reintermediate next-generation potentialities after goal-oriented ' + 'catalysts for change. Dynamically revolutionize.'; @@ -134,7 +134,7 @@ class AlertExample extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ wrapper: { borderRadius: 5, marginBottom: 5, diff --git a/RNTester/js/AlertIOSExample.js b/RNTester/js/AlertIOSExample.js index 03777a8b7..87f9e2f6f 100644 --- a/RNTester/js/AlertIOSExample.js +++ b/RNTester/js/AlertIOSExample.js @@ -10,11 +10,11 @@ 'use strict'; -var React = require('react'); -var ReactNative = require('react-native'); -var {StyleSheet, View, Text, TouchableHighlight, AlertIOS} = ReactNative; +const React = require('react'); +const ReactNative = require('react-native'); +const {StyleSheet, View, Text, TouchableHighlight, AlertIOS} = ReactNative; -var {SimpleAlertExampleBlock} = require('./AlertExample'); +const {SimpleAlertExampleBlock} = require('./AlertExample'); exports.framework = 'React'; exports.title = 'AlertIOS'; @@ -180,7 +180,7 @@ class PromptOptions extends React.Component<$FlowFixMeProps, any> { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ wrapper: { borderRadius: 5, marginBottom: 5, diff --git a/RNTester/js/AnimatedExample.js b/RNTester/js/AnimatedExample.js index 0510efe7a..5012ff7df 100644 --- a/RNTester/js/AnimatedExample.js +++ b/RNTester/js/AnimatedExample.js @@ -10,10 +10,10 @@ 'use strict'; -var React = require('react'); -var ReactNative = require('react-native'); -var {Animated, Easing, StyleSheet, Text, View} = ReactNative; -var RNTesterButton = require('./RNTesterButton'); +const React = require('react'); +const ReactNative = require('react-native'); +const {Animated, Easing, StyleSheet, Text, View} = ReactNative; +const RNTesterButton = require('./RNTesterButton'); exports.framework = 'React'; exports.title = 'Animated - Examples'; @@ -158,7 +158,7 @@ exports.examples = [ { - var timing = Animated.timing; + const timing = Animated.timing; Animated.sequence([ // One after the other timing(this.anims[0], { @@ -285,7 +285,7 @@ exports.examples = [ }, ]; -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ content: { backgroundColor: 'deepskyblue', borderWidth: 1, diff --git a/RNTester/js/AppStateExample.js b/RNTester/js/AppStateExample.js index 8309aac32..4ea4949d5 100644 --- a/RNTester/js/AppStateExample.js +++ b/RNTester/js/AppStateExample.js @@ -39,7 +39,7 @@ class AppStateSubscription extends React.Component< }; _handleAppStateChange = appState => { - var previousAppStates = this.state.previousAppStates.slice(); + const previousAppStates = this.state.previousAppStates.slice(); previousAppStates.push(this.state.appState); this.setState({ appState, diff --git a/RNTester/js/AssetScaledImageExample.js b/RNTester/js/AssetScaledImageExample.js index ae74d599c..8a70b61c6 100644 --- a/RNTester/js/AssetScaledImageExample.js +++ b/RNTester/js/AssetScaledImageExample.js @@ -10,9 +10,9 @@ 'use strict'; -var React = require('react'); -var ReactNative = require('react-native'); -var {Image, StyleSheet, View, ScrollView} = ReactNative; +const React = require('react'); +const ReactNative = require('react-native'); +const {Image, StyleSheet, View, ScrollView} = ReactNative; import type {PhotoIdentifier} from 'CameraRoll'; @@ -30,7 +30,7 @@ class AssetScaledImageExample extends React.Component { }; render() { - var image = this.state.asset.node.image; + const image = this.state.asset.node.image; return ( @@ -50,7 +50,7 @@ class AssetScaledImageExample extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ row: { padding: 5, flex: 1, diff --git a/RNTester/js/AsyncStorageExample.js b/RNTester/js/AsyncStorageExample.js index 27ba9d87f..9e43cdc61 100644 --- a/RNTester/js/AsyncStorageExample.js +++ b/RNTester/js/AsyncStorageExample.js @@ -10,13 +10,13 @@ 'use strict'; -var React = require('react'); -var ReactNative = require('react-native'); -var {AsyncStorage, PickerIOS, Text, View} = ReactNative; -var PickerItemIOS = PickerIOS.Item; +const React = require('react'); +const ReactNative = require('react-native'); +const {AsyncStorage, PickerIOS, Text, View} = ReactNative; +const PickerItemIOS = PickerIOS.Item; -var STORAGE_KEY = '@AsyncStorageExample:key'; -var COLORS = ['red', 'orange', 'yellow', 'green', 'blue']; +const STORAGE_KEY = '@AsyncStorageExample:key'; +const COLORS = ['red', 'orange', 'yellow', 'green', 'blue']; class BasicStorageExample extends React.Component<{}, $FlowFixMeState> { state = { @@ -30,7 +30,7 @@ class BasicStorageExample extends React.Component<{}, $FlowFixMeState> { _loadInitialState = async () => { try { - var value = await AsyncStorage.getItem(STORAGE_KEY); + const value = await AsyncStorage.getItem(STORAGE_KEY); if (value !== null) { this.setState({selectedValue: value}); this._appendMessage('Recovered selection from disk: ' + value); @@ -43,7 +43,7 @@ class BasicStorageExample extends React.Component<{}, $FlowFixMeState> { }; render() { - var color = this.state.selectedValue; + const color = this.state.selectedValue; return (