From 791fa2d83a615e58b1803c32b342f04c7312c734 Mon Sep 17 00:00:00 2001 From: nd-02110114 Date: Tue, 30 Oct 2018 14:29:54 -0700 Subject: [PATCH] Remove var in RNTester (#22016) 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/22016 Differential Revision: D12843122 Pulled By: TheSavior fbshipit-source-id: 7e207366c457f0bda707773e9de02fe5afdbb144 --- RNTester/js/RNTesterExampleContainer.js | 3 ++- RNTester/js/RNTesterTitle.js | 8 ++++---- RNTester/js/SafeAreaViewExample.js | 2 +- RNTester/js/ScrollViewSimpleExample.js | 18 +++++++++--------- RNTester/js/SegmentedControlIOSExample.js | 8 ++++---- RNTester/js/ShareExample.js | 8 ++++---- RNTester/js/SliderExample.js | 8 ++++---- RNTester/js/StatusBarExample.js | 2 +- RNTester/js/SwipeableFlatListExample.js | 2 +- RNTester/js/SwitchExample.js | 8 ++++---- RNTester/js/TVEventHandlerExample.js | 13 +++---------- RNTester/js/TabBarIOSBarStyleExample.js | 10 +++++----- RNTester/js/TabBarIOSExample.js | 10 +++++----- RNTester/js/TextExample.android.js | 14 +++++++------- RNTester/js/TextExample.ios.js | 6 +++--- 15 files changed, 57 insertions(+), 63 deletions(-) diff --git a/RNTester/js/RNTesterExampleContainer.js b/RNTester/js/RNTesterExampleContainer.js index 012923869..e1c66e333 100644 --- a/RNTester/js/RNTesterExampleContainer.js +++ b/RNTester/js/RNTesterExampleContainer.js @@ -17,7 +17,8 @@ const RNTesterPage = require('./RNTesterPage'); class RNTesterExampleContainer extends React.Component { renderExample(example, i) { // Filter platform-specific examples - var {title, description, platform} = example; + const {description, platform} = example; + let {title} = example; if (platform) { if (Platform.OS !== platform) { return null; diff --git a/RNTester/js/RNTesterTitle.js b/RNTester/js/RNTesterTitle.js index b9f5a77c8..0c9b8b696 100644 --- a/RNTester/js/RNTesterTitle.js +++ b/RNTester/js/RNTesterTitle.js @@ -10,9 +10,9 @@ 'use strict'; -var React = require('react'); -var ReactNative = require('react-native'); -var {StyleSheet, Text, View} = ReactNative; +const React = require('react'); +const ReactNative = require('react-native'); +const {StyleSheet, Text, View} = ReactNative; class RNTesterTitle extends React.Component<$FlowFixMeProps> { render() { @@ -24,7 +24,7 @@ class RNTesterTitle extends React.Component<$FlowFixMeProps> { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ container: { borderRadius: 4, borderWidth: 0.5, diff --git a/RNTester/js/SafeAreaViewExample.js b/RNTester/js/SafeAreaViewExample.js index ed66587d7..37a3910a7 100644 --- a/RNTester/js/SafeAreaViewExample.js +++ b/RNTester/js/SafeAreaViewExample.js @@ -118,7 +118,7 @@ exports.examples = [ }, ]; -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ modal: { flex: 1, }, diff --git a/RNTester/js/ScrollViewSimpleExample.js b/RNTester/js/ScrollViewSimpleExample.js index 2f157c215..e7393ec07 100644 --- a/RNTester/js/ScrollViewSimpleExample.js +++ b/RNTester/js/ScrollViewSimpleExample.js @@ -10,11 +10,11 @@ 'use strict'; -var React = require('react'); -var ReactNative = require('react-native'); -var {ScrollView, StyleSheet, Text, TouchableOpacity} = ReactNative; +const React = require('react'); +const ReactNative = require('react-native'); +const {ScrollView, StyleSheet, Text, TouchableOpacity} = ReactNative; -var NUM_ITEMS = 20; +const NUM_ITEMS = 20; class ScrollViewSimpleExample extends React.Component<{}> { static title = ''; @@ -22,8 +22,8 @@ class ScrollViewSimpleExample extends React.Component<{}> { 'Component that enables scrolling through child components.'; makeItems = (nItems: number, styles): Array => { - var items = []; - for (var i = 0; i < nItems; i++) { + const items = []; + for (let i = 0; i < nItems; i++) { items[i] = ( {'Item ' + i} @@ -35,7 +35,7 @@ class ScrollViewSimpleExample extends React.Component<{}> { render() { // One of the items is a horizontal scroll view - var items = this.makeItems(NUM_ITEMS, styles.itemWrapper); + const items = this.makeItems(NUM_ITEMS, styles.itemWrapper); items[4] = ( {this.makeItems(NUM_ITEMS, [ @@ -58,7 +58,7 @@ class ScrollViewSimpleExample extends React.Component<{}> { , ); - var verticalScrollView = ( + const verticalScrollView = ( {items} ); @@ -66,7 +66,7 @@ class ScrollViewSimpleExample extends React.Component<{}> { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ verticalScrollView: { margin: 10, }, diff --git a/RNTester/js/SegmentedControlIOSExample.js b/RNTester/js/SegmentedControlIOSExample.js index 9021a95b7..2b17f70cf 100644 --- a/RNTester/js/SegmentedControlIOSExample.js +++ b/RNTester/js/SegmentedControlIOSExample.js @@ -10,9 +10,9 @@ 'use strict'; -var React = require('react'); -var ReactNative = require('react-native'); -var {SegmentedControlIOS, Text, View, StyleSheet} = ReactNative; +const React = require('react'); +const ReactNative = require('react-native'); +const {SegmentedControlIOS, Text, View, StyleSheet} = ReactNative; class BasicSegmentedControlExample extends React.Component<{}> { render() { @@ -132,7 +132,7 @@ class EventSegmentedControlExample extends React.Component< }; } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ text: { fontSize: 14, textAlign: 'center', diff --git a/RNTester/js/ShareExample.js b/RNTester/js/ShareExample.js index 9f1a82436..30d18280f 100644 --- a/RNTester/js/ShareExample.js +++ b/RNTester/js/ShareExample.js @@ -10,9 +10,9 @@ 'use strict'; -var React = require('react'); -var ReactNative = require('react-native'); -var {StyleSheet, View, Text, TouchableHighlight, Share} = ReactNative; +const React = require('react'); +const ReactNative = require('react-native'); +const {StyleSheet, View, Text, TouchableHighlight, Share} = ReactNative; exports.framework = 'React'; exports.title = 'Share'; @@ -103,7 +103,7 @@ class ShareMessageExample extends React.Component<$FlowFixMeProps, any> { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ wrapper: { borderRadius: 5, marginBottom: 5, diff --git a/RNTester/js/SliderExample.js b/RNTester/js/SliderExample.js index f4129b2f3..22f0da2f0 100644 --- a/RNTester/js/SliderExample.js +++ b/RNTester/js/SliderExample.js @@ -10,9 +10,9 @@ 'use strict'; -var React = require('react'); -var ReactNative = require('react-native'); -var {Slider, Text, StyleSheet, View} = ReactNative; +const React = require('react'); +const ReactNative = require('react-native'); +const {Slider, Text, StyleSheet, View} = ReactNative; class SliderExample extends React.Component<$FlowFixMeProps, $FlowFixMeState> { static defaultProps = { @@ -68,7 +68,7 @@ class SlidingCompleteExample extends React.Component< } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ slider: { height: 10, margin: 10, diff --git a/RNTester/js/StatusBarExample.js b/RNTester/js/StatusBarExample.js index 77f51a424..58b87ab53 100644 --- a/RNTester/js/StatusBarExample.js +++ b/RNTester/js/StatusBarExample.js @@ -498,7 +498,7 @@ const examples = [ exports.examples = examples; -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', diff --git a/RNTester/js/SwipeableFlatListExample.js b/RNTester/js/SwipeableFlatListExample.js index 7f27b4dc2..7cf2a0810 100644 --- a/RNTester/js/SwipeableFlatListExample.js +++ b/RNTester/js/SwipeableFlatListExample.js @@ -103,7 +103,7 @@ class SwipeableFlatListExample extends React.Component { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ row: { flexDirection: 'row', justifyContent: 'center', diff --git a/RNTester/js/SwitchExample.js b/RNTester/js/SwitchExample.js index 22e224bb1..eeca71fa6 100644 --- a/RNTester/js/SwitchExample.js +++ b/RNTester/js/SwitchExample.js @@ -10,9 +10,9 @@ 'use strict'; -var React = require('react'); -var ReactNative = require('react-native'); -var {Platform, Switch, Text, View} = ReactNative; +const React = require('react'); +const ReactNative = require('react-native'); +const {Switch, Text, View} = ReactNative; class BasicSwitchExample extends React.Component<{}, $FlowFixMeState> { state = { @@ -125,7 +125,7 @@ class EventSwitchExample extends React.Component<{}, $FlowFixMeState> { } } -var examples = [ +const examples = [ { title: 'Switches can be set to true or false', render(): React.Element { diff --git a/RNTester/js/TVEventHandlerExample.js b/RNTester/js/TVEventHandlerExample.js index 1b71a1001..ed90ddeb2 100644 --- a/RNTester/js/TVEventHandlerExample.js +++ b/RNTester/js/TVEventHandlerExample.js @@ -10,17 +10,10 @@ 'use strict'; -var React = require('react'); -var ReactNative = require('react-native'); +const React = require('react'); +const ReactNative = require('react-native'); -var { - Platform, - StyleSheet, - View, - Text, - TouchableOpacity, - TVEventHandler, -} = ReactNative; +const {Platform, View, Text, TouchableOpacity, TVEventHandler} = ReactNative; exports.framework = 'React'; exports.title = 'TVEventHandler example'; diff --git a/RNTester/js/TabBarIOSBarStyleExample.js b/RNTester/js/TabBarIOSBarStyleExample.js index 0cf0df73b..a8dfd135c 100644 --- a/RNTester/js/TabBarIOSBarStyleExample.js +++ b/RNTester/js/TabBarIOSBarStyleExample.js @@ -22,11 +22,11 @@ 'use strict'; -var React = require('react'); -var ReactNative = require('react-native'); -var {StyleSheet, TabBarIOS, Text, View} = ReactNative; +const React = require('react'); +const ReactNative = require('react-native'); +const {StyleSheet, TabBarIOS, Text, View} = ReactNative; -var base64Icon = +const base64Icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAABLCAQAAACSR7JhAAADtUlEQVR4Ac3YA2Bj6QLH0XPT1Fzbtm29tW3btm3bfLZtv7e2ObZnms7d8Uw098tuetPzrxv8wiISrtVudrG2JXQZ4VOv+qUfmqCGGl1mqLhoA52oZlb0mrjsnhKpgeUNEs91Z0pd1kvihA3ULGVHiQO2narKSHKkEMulm9VgUyE60s1aWoMQUbpZOWE+kaqs4eLEjdIlZTcFZB0ndc1+lhB1lZrIuk5P2aib1NBpZaL+JaOGIt0ls47SKzLC7CqrlGF6RZ09HGoNy1lYl2aRSWL5GuzqWU1KafRdoRp0iOQEiDzgZPnG6DbldcomadViflnl/cL93tOoVbsOLVM2jylvdWjXolWX1hmfZbGR/wjypDjFLSZIRov09BgYmtUqPQPlQrPapecLgTIy0jMgPKtTeob2zWtrGH3xvjUkPCtNg/tm1rjwrMa+mdUkPd3hWbH0jArPGiU9ufCsNNWFZ40wpwn+62/66R2RUtoso1OB34tnLOcy7YB1fUdc9e0q3yru8PGM773vXsuZ5YIZX+5xmHwHGVvlrGPN6ZSiP1smOsMMde40wKv2VmwPPVXNut4sVpUreZiLBHi0qln/VQeI/LTMYXpsJtFiclUN+5HVZazim+Ky+7sAvxWnvjXrJFneVtLWLyPJu9K3cXLWeOlbMTlrIelbMDlrLenrjEQOtIF+fuI9xRp9ZBFp6+b6WT8RrxEpdK64BuvHgDk+vUy+b5hYk6zfyfs051gRoNO1usU12WWRWL73/MMEy9pMi9qIrR4ZpV16Rrvduxazmy1FSvuFXRkqTnE7m2kdb5U8xGjLw/spRr1uTov4uOgQE+0N/DvFrG/Jt7i/FzwxbA9kDanhf2w+t4V97G8lrT7wc08aA2QNUkuTfW/KimT01wdlfK4yEw030VfT0RtZbzjeMprNq8m8tnSTASrTLti64oBNdpmMQm0eEwvfPwRbUBywG5TzjPCsdwk3IeAXjQblLCoXnDVeoAz6SfJNk5TTzytCNZk/POtTSV40NwOFWzw86wNJRpubpXsn60NJFlHeqlYRbslqZm2jnEZ3qcSKgm0kTli3zZVS7y/iivZTweYXJ26Y+RTbV1zh3hYkgyFGSTKPfRVbRqWWVReaxYeSLarYv1Qqsmh1s95S7G+eEWK0f3jYKTbV6bOwepjfhtafsvUsqrQvrGC8YhmnO9cSCk3yuY984F1vesdHYhWJ5FvASlacshUsajFt2mUM9pqzvKGcyNJW0arTKN1GGGzQlH0tXwLDgQTurS8eIQAAAABJRU5ErkJggg=='; class TabBarIOSBarStyleExample extends React.Component<{}> { @@ -47,7 +47,7 @@ class TabBarIOSBarStyleExample extends React.Component<{}> { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ tabContent: { flex: 1, alignItems: 'center', diff --git a/RNTester/js/TabBarIOSExample.js b/RNTester/js/TabBarIOSExample.js index 9dafdf3b3..6fc9015ce 100644 --- a/RNTester/js/TabBarIOSExample.js +++ b/RNTester/js/TabBarIOSExample.js @@ -10,11 +10,11 @@ 'use strict'; -var React = require('react'); -var ReactNative = require('react-native'); -var {StyleSheet, TabBarIOS, Text, View} = ReactNative; +const React = require('react'); +const ReactNative = require('react-native'); +const {StyleSheet, TabBarIOS, Text, View} = ReactNative; -var base64Icon = +const base64Icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEsAAABLCAQAAACSR7JhAAADtUlEQVR4Ac3YA2Bj6QLH0XPT1Fzbtm29tW3btm3bfLZtv7e2ObZnms7d8Uw098tuetPzrxv8wiISrtVudrG2JXQZ4VOv+qUfmqCGGl1mqLhoA52oZlb0mrjsnhKpgeUNEs91Z0pd1kvihA3ULGVHiQO2narKSHKkEMulm9VgUyE60s1aWoMQUbpZOWE+kaqs4eLEjdIlZTcFZB0ndc1+lhB1lZrIuk5P2aib1NBpZaL+JaOGIt0ls47SKzLC7CqrlGF6RZ09HGoNy1lYl2aRSWL5GuzqWU1KafRdoRp0iOQEiDzgZPnG6DbldcomadViflnl/cL93tOoVbsOLVM2jylvdWjXolWX1hmfZbGR/wjypDjFLSZIRov09BgYmtUqPQPlQrPapecLgTIy0jMgPKtTeob2zWtrGH3xvjUkPCtNg/tm1rjwrMa+mdUkPd3hWbH0jArPGiU9ufCsNNWFZ40wpwn+62/66R2RUtoso1OB34tnLOcy7YB1fUdc9e0q3yru8PGM773vXsuZ5YIZX+5xmHwHGVvlrGPN6ZSiP1smOsMMde40wKv2VmwPPVXNut4sVpUreZiLBHi0qln/VQeI/LTMYXpsJtFiclUN+5HVZazim+Ky+7sAvxWnvjXrJFneVtLWLyPJu9K3cXLWeOlbMTlrIelbMDlrLenrjEQOtIF+fuI9xRp9ZBFp6+b6WT8RrxEpdK64BuvHgDk+vUy+b5hYk6zfyfs051gRoNO1usU12WWRWL73/MMEy9pMi9qIrR4ZpV16Rrvduxazmy1FSvuFXRkqTnE7m2kdb5U8xGjLw/spRr1uTov4uOgQE+0N/DvFrG/Jt7i/FzwxbA9kDanhf2w+t4V97G8lrT7wc08aA2QNUkuTfW/KimT01wdlfK4yEw030VfT0RtZbzjeMprNq8m8tnSTASrTLti64oBNdpmMQm0eEwvfPwRbUBywG5TzjPCsdwk3IeAXjQblLCoXnDVeoAz6SfJNk5TTzytCNZk/POtTSV40NwOFWzw86wNJRpubpXsn60NJFlHeqlYRbslqZm2jnEZ3qcSKgm0kTli3zZVS7y/iivZTweYXJ26Y+RTbV1zh3hYkgyFGSTKPfRVbRqWWVReaxYeSLarYv1Qqsmh1s95S7G+eEWK0f3jYKTbV6bOwepjfhtafsvUsqrQvrGC8YhmnO9cSCk3yuY984F1vesdHYhWJ5FvASlacshUsajFt2mUM9pqzvKGcyNJW0arTKN1GGGzQlH0tXwLDgQTurS8eIQAAAABJRU5ErkJggg=='; class TabBarExample extends React.Component<{}, $FlowFixMeState> { @@ -89,7 +89,7 @@ class TabBarExample extends React.Component<{}, $FlowFixMeState> { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ tabContent: { flex: 1, alignItems: 'center', diff --git a/RNTester/js/TextExample.android.js b/RNTester/js/TextExample.android.js index 283d5f25f..a8b23ad87 100644 --- a/RNTester/js/TextExample.android.js +++ b/RNTester/js/TextExample.android.js @@ -10,11 +10,11 @@ 'use strict'; -var React = require('react'); -var ReactNative = require('react-native'); -var {Image, StyleSheet, Text, View} = ReactNative; -var RNTesterBlock = require('./RNTesterBlock'); -var RNTesterPage = require('./RNTesterPage'); +const React = require('react'); +const ReactNative = require('react-native'); +const {Image, StyleSheet, Text, View} = ReactNative; +const RNTesterBlock = require('./RNTesterBlock'); +const RNTesterPage = require('./RNTesterPage'); const TextLegend = require('./Shared/TextLegend'); class Entity extends React.Component<$FlowFixMeProps> { @@ -43,7 +43,7 @@ class AttributeToggler extends React.Component<{}, $FlowFixMeState> { }; render() { - var curStyle = { + const curStyle = { fontWeight: this.state.fontWeight, fontSize: this.state.fontSize, }; @@ -590,7 +590,7 @@ class TextExample extends React.Component<{}> { } } -var styles = StyleSheet.create({ +const styles = StyleSheet.create({ backgroundColorText: { left: 5, backgroundColor: 'rgba(100, 100, 100, 0.3)', diff --git a/RNTester/js/TextExample.ios.js b/RNTester/js/TextExample.ios.js index 760d450fa..439c9c714 100644 --- a/RNTester/js/TextExample.ios.js +++ b/RNTester/js/TextExample.ios.js @@ -91,7 +91,7 @@ class AttributeToggler extends React.Component<{}, $FlowFixMeState> { }; render() { - var curStyle = { + const curStyle = { fontWeight: this.state.fontWeight, fontSize: this.state.fontSize, }; @@ -239,8 +239,8 @@ class AdjustingFontSize extends React.Component< class TextBaseLineLayoutExample extends React.Component<*, *> { render() { - var texts = []; - for (var i = 9; i >= 0; i--) { + const texts = []; + for (let i = 9; i >= 0; i--) { texts.push( {i}