Permalink
Browse files

🚨 add eslint

  • Loading branch information...
Vanessa
Vanessa committed Jun 14, 2017
1 parent 5722cfc commit f8505e7c7a4ce4914da8ae33373bae0723941873
View
@@ -0,0 +1,2 @@
__tests__/
js/
View
@@ -0,0 +1,36 @@
{
"parser": "babel-eslint",
"extends": "airbnb-base",
"env": {
"jest": true
},
"plugins": [
"react",
"react-native"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
"react/jsx-uses-vars": 2,
"react/jsx-uses-react": 2,
"comma-dangle": [
"error",
{
"arrays": "never",
"objects": "never"
}
],
"no-underscore-dangle": [
"error",
{
"allowAfterThis": true
}
]
},
"globals": {
"fetch": true
}
}
View
@@ -51,3 +51,6 @@ buck-out/
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
# Demo
js
@@ -1,10 +1,11 @@
import 'react-native';
import React from 'react';
import Index from '../index.android.js';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
import Index from '../index.android.js';
it('renders correctly', () => {
const tree = renderer.create(
<Index />
View
@@ -1,10 +1,10 @@
import 'react-native';
import React from 'react';
import Index from '../index.ios.js';
// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
import Index from '../index.ios.js';
it('renders correctly', () => {
const tree = renderer.create(
<Index />
View
@@ -1,30 +1,28 @@
import React from 'react';
import { TabNavigator } from 'react-navigation';
import {TabNavigator} from "react-navigation";
import IndexScreen from './screens/Index'
import SettingScreen from './screens/Setting'
import NotificationScreen from './screens/Notification'
import variablels from './styles/variablels'
import common from './styles/common'
import IndexScreen from './screens/Index';
import SettingScreen from './screens/Setting';
import NotificationScreen from './screens/Notification';
import variablels from './styles/variablels';
import common from './styles/common';
const SymApp = TabNavigator({
Index: {screen: IndexScreen},
Notification: {screen: NotificationScreen},
Setting: {screen: SettingScreen},
Index: { screen: IndexScreen },
Notification: { screen: NotificationScreen },
Setting: { screen: SettingScreen }
}, {
lazy: true,
tabBarPosition: 'bottom',
tabBarOptions: {
showIcon: true,
showLabel: false,
activeTintColor: '#fff',
inactiveTintColor: variablels.COLOR.fade,
style: {
backgroundColor: variablels.THEME.primary,
},
iconStyle: common.navgation
tabBarPosition: 'bottom',
tabBarOptions: {
showIcon: true,
showLabel: false,
activeTintColor: '#fff',
inactiveTintColor: variablels.COLOR.fade,
style: {
backgroundColor: variablels.THEME.primary
},
iconStyle: common.navgation
}
});
export default SymApp
export default SymApp;
View
@@ -1,13 +1,11 @@
import ArticlesService from '../services/ArticlesService';
const getList = (currentPage) => ArticlesService.getList(currentPage)
.then((response) => {
return Promise.resolve(response)
})
.catch((error) => {
console.error(error);
});
const getList = currentPage => ArticlesService.getList(currentPage)
.then(response => Promise.resolve(response))
.catch((error) => {
console.error(error);
});
export default {
getList
}
getList
};
@@ -1,33 +1,32 @@
import React, { Component } from 'react';
import {
View,
Text,
StyleSheet,
View,
Text,
StyleSheet
} from 'react-native';
const styles = StyleSheet.create({
footer: {
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
height: 40
},
footerTitle: {
marginLeft: 10,
fontSize: 15,
color: 'gray'
}
});
class LoadMoreFooter extends Component {
constructor(props) {
super(props);
}
render() {
return (
<View style={styles.footer}>
<Text style={styles.footerTitle}>{this.props.isLoadAll ? '已加载全部' : '正在加载更多……'}</Text>
</View>
)
}
render() {
return (
<View style={styles.footer}>
<Text style={styles.footerTitle}>{this.props.isLoadAll ? '已加载全部' : '正在加载更多……'}</Text>
</View>
);
}
}
const styles = StyleSheet.create({
footer: {
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
height: 40,
},
footerTitle: {
marginLeft: 10,
fontSize: 15,
color: 'gray'
}
})
export default LoadMoreFooter
export default LoadMoreFooter;
View
@@ -1,5 +1,5 @@
const api = 'https://hacpai.com/api/v2/';
export default {
api
}
api
};
View
@@ -1,34 +1,34 @@
import React, { Component } from 'react';
import {
Text,
View,
Button
Text,
View,
Button
} from 'react-native';
class DetailScreen extends Component {
static navigationOptions = ({ navigation }) => {
const {state, setParams} = navigation;
const isInfo = state.params.mode === 'info';
const {user} = state.params;
return {
title: isInfo ? `${user}'s Contact Info` : `Chat with ${state.params.user}`,
tabBarVisible: false,
headerRight: (
<Button
title={isInfo ? 'Done' : `${user}'s info`}
onPress={() => setParams({ mode: isInfo ? 'none' : 'info'})}
/>
),
};
const { state, setParams } = navigation;
const isInfo = state.params.mode === 'info';
const { user } = state.params;
return {
title: isInfo ? `${user}'s Contact Info` : `Chat with ${state.params.user}`,
tabBarVisible: false,
headerRight: (
<Button
title={isInfo ? 'Done' : `${user}'s info`}
onPress={() => setParams({ mode: isInfo ? 'none' : 'info' })}
/>
)
};
};
render() {
const { params } = this.props.navigation.state;
return (
<View>
<Text>Chat with {params.user}</Text>
</View>
);
}
const { params } = this.props.navigation.state;
return (
<View>
<Text>Chat with {params.user}</Text>
</View>
);
}
}
export default DetailScreen;
export default DetailScreen;
View
@@ -1,26 +1,27 @@
import React from 'react';
import {
Image
Image
} from 'react-native';
import { StackNavigator } from 'react-navigation';
import ListScreen from './List';
import DetailScreen from './Detail';
import common from '../styles/common';
import articlePng from '../images/article.png';
const IndexScreen = StackNavigator({
List: { screen: ListScreen },
Detail: { screen: DetailScreen },
List: { screen: ListScreen },
Detail: { screen: DetailScreen }
});
IndexScreen.navigationOptions = {
tabBarIcon: ({ tintColor }) => (
<Image
source={require('../images/article.png')}
style={[{tintColor: tintColor}, common.navgation]}
/>
)
}
tabBarIcon: ({ tintColor }) => (
<Image
source={articlePng}
style={[{ tintColor }, common.navgation]}
/>
)
};
export default IndexScreen;
export default IndexScreen;
Oops, something went wrong.

0 comments on commit f8505e7

Please sign in to comment.