Skip to content

Commit

Permalink
Merge pull request fbsamples#188 from bl4ckm0r3/bugfix/remove-var
Browse files Browse the repository at this point in the history
removed var in favour of let/const
  • Loading branch information
oclbdk authored Dec 8, 2017
2 parents 522265d + d051ecf commit 8113e76
Show file tree
Hide file tree
Showing 74 changed files with 217 additions and 215 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"use-isnan": 1, // disallow comparisons with the value NaN
"valid-jsdoc": 0, // Ensure JSDoc comments are valid (off by default)
"valid-typeof": 1, // Ensure that the results of typeof are compared against a valid string
"no-var": 1, // discouraging the use of var and encouraging the use of const or let instead

// Best Practices
// These are rules designed to prevent you from making mistakes. They either prescribe a better way of doing something or help you avoid footguns.
Expand Down
2 changes: 1 addition & 1 deletion js/F8App.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class F8App extends React.Component {
}
}

var styles = StyleSheet.create({
const styles = StyleSheet.create({
container: {
flex: 1
}
Expand Down
4 changes: 2 additions & 2 deletions js/F8Navigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import { switchTab } from "./actions";
import F8MapView from "./tabs/maps/F8MapView";
import DemosCarousel from "./tabs/demos/DemosCarousel";

var F8Navigator = React.createClass({
const F8Navigator = React.createClass({
_handlers: ([]: Array<() => boolean>),

componentDidMount: function() {
Expand Down Expand Up @@ -158,7 +158,7 @@ F8Navigator.childContextTypes = {
removeBackButtonListener: React.PropTypes.func
};

var styles = StyleSheet.create({
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: F8Colors.bianca
Expand Down
2 changes: 1 addition & 1 deletion js/FacebookSDK.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async function loginWithFacebookSDK(
return _authResponse;
}

var FacebookSDK = {
const FacebookSDK = {
init() {
// This is needed by Parse
window.FB = FacebookSDK;
Expand Down
8 changes: 4 additions & 4 deletions js/Playground.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ class Playground extends React.Component {
const define = (name: string, render: Function) => {
content.push(<Example key={name} render={render} />);
};
// var Module = require('F8PageControl');
var Module = require("F8Header");
// var Module = require('./tabs/schedule/AddToScheduleButton');
// var Module = require('./rating/Header');
// const Module = require('F8PageControl');
const Module = require("F8Header");
// const Module = require('./tabs/schedule/AddToScheduleButton');
// const Module = require('./rating/Header');
// $FlowFixMe: doesn't understand static
Module.__cards__(define);
this.state = { content };
Expand Down
4 changes: 2 additions & 2 deletions js/common/F8BackgroundRepeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class F8BackgroundRepeat extends React.Component {
const numHorizontal = Math.ceil(width / img.width);
const numVertical = Math.ceil(height / img.height);

for (var i = 0; i < numVertical; i++) {
for (let i = 0; i < numVertical; i++) {
content.push(this.renderRow(numHorizontal, i));
}

Expand All @@ -62,7 +62,7 @@ class F8BackgroundRepeat extends React.Component {

renderRow(colsInRow, idx) {
const cols = [];
for (var i = 0; i < colsInRow; i++) {
for (let i = 0; i < colsInRow; i++) {
cols.push(this.renderImage(i));
}
return (
Expand Down
2 changes: 1 addition & 1 deletion js/common/F8Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ class ItemWrapperIOS extends React.Component {
/* StyleSheet
============================================================================= */

var styles = StyleSheet.create({
const styles = StyleSheet.create({
toolbar: {
android: {
// backgroundColor: F8Colors.background,
Expand Down
2 changes: 1 addition & 1 deletion js/common/F8Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class F8Modal extends React.Component {

/* StyleSheet
============================================================================= */
var styles = StyleSheet.create({
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: F8Colors.colorWithAlpha("tangaroa", 0.8),
Expand Down
18 changes: 9 additions & 9 deletions js/common/F8PageControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@
import React from "react";
import { StyleSheet, View } from "react-native";

var PropTypes = React.PropTypes;
const PropTypes = React.PropTypes;

var F8PageControl = React.createClass({
const F8PageControl = React.createClass({
propTypes: {
style: View.propTypes.style,
count: PropTypes.number.isRequired,
selectedIndex: PropTypes.number.isRequired
},

render: function() {
var images = [];
for (var i = 0; i < this.props.count; i++) {
var isSelected = this.props.selectedIndex === i;
const images = [];
for (let i = 0; i < this.props.count; i++) {
const isSelected = this.props.selectedIndex === i;
images.push(<Circle key={i} isSelected={isSelected} />);
}
return (
Expand All @@ -49,16 +49,16 @@ var F8PageControl = React.createClass({
}
});

var Circle = React.createClass({
const Circle = React.createClass({
render: function() {
var extraStyle = this.props.isSelected ? styles.full : styles.empty;
const extraStyle = this.props.isSelected ? styles.full : styles.empty;
return <View style={[styles.circle, extraStyle]} />;
}
});

var CIRCLE_SIZE = 4;
const CIRCLE_SIZE = 4;

var styles = StyleSheet.create({
const styles = StyleSheet.create({
container: {
alignItems: "center",
justifyContent: "center"
Expand Down
4 changes: 2 additions & 2 deletions js/common/F8SegmentedControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class F8SegmentedControl extends React.Component {
render() {
const { backgroundColor, borderColor, textColor } = this.props;

var segments = this.props.values.map((value, index) => (
const segments = this.props.values.map((value, index) => (
<Segment
key={value.title}
value={value.title}
Expand Down Expand Up @@ -121,7 +121,7 @@ class Segment extends React.Component {

/* StyleSheet =============================================================== */

var styles = StyleSheet.create({
const styles = StyleSheet.create({
container: {
flexDirection: "row",
paddingBottom: CONTAINER_PADDING_B,
Expand Down
6 changes: 3 additions & 3 deletions js/common/ItemsWithSeparator.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class ItemsWithSeparator extends React.Component {
};

render() {
var children = [];
var length = React.Children.count(this.props.children);
const children = [];
const length = React.Children.count(this.props.children);
React.Children.forEach(this.props.children, (child, ii) => {
children.push(child);
if (ii !== length - 1) {
Expand All @@ -51,7 +51,7 @@ class ItemsWithSeparator extends React.Component {
}
}

var styles = StyleSheet.create({
const styles = StyleSheet.create({
separator: {
backgroundColor: "#0322500A",
height: 1 / PixelRatio.get()
Expand Down
2 changes: 1 addition & 1 deletion js/common/LoginButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class LoginButton extends React.Component {
}
}

var styles = StyleSheet.create({
const styles = StyleSheet.create({
button: {
alignSelf: "center",
width: 284
Expand Down
2 changes: 1 addition & 1 deletion js/common/MapView.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ function urlForMap(map: ?Map): string {
/* StyleSheet
============================================================================= */

var styles = StyleSheet.create({
const styles = StyleSheet.create({
defaultMap: {
resizeMode: "contain"
}
Expand Down
2 changes: 1 addition & 1 deletion js/common/MessengerChatHead.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class MessengerChatHead extends React.Component {
/* StyleSheet
============================================================================= */

var styles = StyleSheet.create({
const styles = StyleSheet.create({
container: {
width: CONTAINER_WIDTH,
height: CONTAINER_HEIGHT
Expand Down
2 changes: 1 addition & 1 deletion js/common/MessengerModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class MessengerModal extends React.Component {

/* StyleSheet =============================================================== */

var styles = StyleSheet.create({
const styles = StyleSheet.create({
content: {
alignItems: "center",
paddingVertical: 45,
Expand Down
4 changes: 2 additions & 2 deletions js/common/ParallaxBackground.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ class ParallaxBackground extends React.Component {
}
}

var HEADER_HEIGHT = HEIGHT + 156;
const HEADER_HEIGHT = HEIGHT + 156;

var styles = StyleSheet.create({
const styles = StyleSheet.create({
container: {
position: "absolute",
left: 0,
Expand Down
8 changes: 4 additions & 4 deletions js/common/ViewPager.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ class ViewPager extends React.Component {
}

renderContent(): Array<ReactElement> {
var { width, height } = this.state;
var style = Platform.OS === "ios" && styles.card;
const { width, height } = this.state;
const style = Platform.OS === "ios" && styles.card;
return React.Children.map(this.props.children, (child, i) => (
<View style={[style, { width, height }]} key={"r_" + i}>
{child}
Expand All @@ -145,7 +145,7 @@ class ViewPager extends React.Component {
}

handleHorizontalScroll(e: any) {
var selectedIndex = e.nativeEvent.position;
let selectedIndex = e.nativeEvent.position;
if (selectedIndex === undefined) {
selectedIndex = Math.round(
e.nativeEvent.contentOffset.x / this.state.width
Expand Down Expand Up @@ -175,7 +175,7 @@ class ViewPager extends React.Component {
}
}

var styles = StyleSheet.create({
const styles = StyleSheet.create({
container: {
flex: 1
},
Expand Down
6 changes: 3 additions & 3 deletions js/filter/FilterScreen.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ class FilterScreen extends React.Component {
}

toggleTopic(topic: string, value: boolean) {
var selectedTopics = { ...this.state.selectedTopics };
var value = !selectedTopics[topic];
const selectedTopics = { ...this.state.selectedTopics };
let value = !selectedTopics[topic];
if (value) {
selectedTopics[topic] = true;
} else {
Expand Down Expand Up @@ -193,7 +193,7 @@ class FilterScreen extends React.Component {
}
}

var styles = StyleSheet.create({
const styles = StyleSheet.create({
contentWrapper: {
flex: 1,
alignItems: "flex-end"
Expand Down
6 changes: 3 additions & 3 deletions js/filter/FilterScreen.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ class FilterScreen extends React.Component {
}

toggleTopic(topic: string, value: boolean) {
var selectedTopics = { ...this.state.selectedTopics };
var value = !selectedTopics[topic];
const selectedTopics = { ...this.state.selectedTopics };
const value = !selectedTopics[topic];
if (value) {
selectedTopics[topic] = true;
} else {
Expand Down Expand Up @@ -191,7 +191,7 @@ class FilterScreen extends React.Component {
}
}

var styles = StyleSheet.create({
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: F8Colors.tangaroa
Expand Down
8 changes: 4 additions & 4 deletions js/filter/FriendsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"use strict";

import React from "react-native";
var { Image, StyleSheet, Text, TouchableOpacity, View } = React;
const { Image, StyleSheet, Text, TouchableOpacity, View } = React;

type Friend = {
id: string,
Expand Down Expand Up @@ -69,8 +69,8 @@ class UserPog extends React.Component {
};

render() {
var { id, name } = this.props.user;
var firstName = name.split(" ")[0]; // TODO: problems with i18n
const { id, name } = this.props.user;
const firstName = name.split(" ")[0]; // TODO: problems with i18n
return (
<TouchableOpacity style={styles.pog} onPress={this.props.onPress}>
<Image
Expand All @@ -85,7 +85,7 @@ class UserPog extends React.Component {

const SIZE = 50;

var styles = StyleSheet.create({
const styles = StyleSheet.create({
container: {
flexDirection: "row",
alignItems: "center",
Expand Down
6 changes: 3 additions & 3 deletions js/filter/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ class Header extends React.Component {
}
}

var STATUS_BAR_HEIGHT = 20;
var HEADER_HEIGHT = STATUS_BAR_HEIGHT + /* toolbar */ 44;
const STATUS_BAR_HEIGHT = 20;
const HEADER_HEIGHT = STATUS_BAR_HEIGHT + /* toolbar */ 44;

var styles = StyleSheet.create({
const styles = StyleSheet.create({
header: {
backgroundColor: "transparent",
paddingTop: STATUS_BAR_HEIGHT,
Expand Down
4 changes: 2 additions & 2 deletions js/filter/Section.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { Text } from "../common/F8Text";

class Section extends React.Component {
render() {
var { children, title } = this.props;
const { children, title } = this.props;
if (React.Children.count(children) === 0) {
return null;
}
Expand All @@ -43,7 +43,7 @@ class Section extends React.Component {
}
}

var styles = StyleSheet.create({
const styles = StyleSheet.create({
container: {
marginBottom: 50
},
Expand Down
2 changes: 1 addition & 1 deletion js/login/LoginScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class LoginScreen extends React.Component {
/* StyleSheet
============================================================================= */

var styles = StyleSheet.create({
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: F8Colors.bianca
Expand Down
2 changes: 1 addition & 1 deletion js/rating/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function Header({ session }: Props) {
);
}

var styles = StyleSheet.create({
const styles = StyleSheet.create({
container: {
alignItems: "center",
justifyContent: "center",
Expand Down
4 changes: 2 additions & 2 deletions js/reducers/scheduleTopics.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ type Action = { type: string, list: Array<any> };

function topics(state: State = [], action: Action): State {
if (action.type === "LOADED_SESSIONS") {
var topicsMap = Object.create(null);
const topicsMap = Object.create(null);
action.list.forEach(session => {
var tags = session.get("tags") || [];
const tags = session.get("tags") || [];
tags.forEach(tag => {
topicsMap[tag] = true;
});
Expand Down
2 changes: 1 addition & 1 deletion js/reducers/sessions.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export type Session = {
};

function fromParseSpeaker(speaker: Object): Speaker {
var pic = speaker.get("speakerPic");
const pic = speaker.get("speakerPic");
return {
id: speaker.id,
bio: speaker.get("speakerBio"),
Expand Down
Loading

0 comments on commit 8113e76

Please sign in to comment.