Skip to content

Commit

Permalink
update eslint
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard-Cao committed Aug 2, 2016
1 parent c3c3ccd commit 5e6d461
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 40 deletions.
9 changes: 7 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@
"comma-dangle": 0,
"react/prop-types": 0,
"no-use-before-define": 0,
"radix": ["error", "as-needed"],
"react/prefer-stateless-function": 0,
"no-param-reassign": 0
"radix": ["error", "as-needed"],
"no-param-reassign": 0,
"react/jsx-filename-extension": 0,
"object-property-newline": 0,
"no-mixed-operators": 0,
"import/prefer-default-export": 0,
"import/no-extraneous-dependencies": 0
}
}
6 changes: 2 additions & 4 deletions app/components/ReadingToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@ const ReadingToolbar = ({
const handleIconClicked = () => {
if (onIconClicked) {
onIconClicked();
} else {
if (navigator) {
naviGoBack(navigator);
}
} else if (navigator) {
naviGoBack(navigator);
}
};

Expand Down
9 changes: 3 additions & 6 deletions app/containers/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import {
View
} from 'react-native';

import Splash from '../pages/Splash';
import { registerApp } from 'react-native-wechat';
import Splash from '../pages/Splash';
import { naviGoBack } from '../utils/CommonUtil';

let tempNavigator;
Expand Down Expand Up @@ -54,10 +54,8 @@ class App extends React.Component {
if (route.name === 'WebViewPage') {
BackAndroid.removeEventListener('hardwareBackPress', this.goBack);
isRemoved = true;
} else {
if (isRemoved) {
BackAndroid.addEventListener('hardwareBackPress', this.goBack);
}
} else if (isRemoved) {
BackAndroid.addEventListener('hardwareBackPress', this.goBack);
}
return (
<Component navigator={navigator} route={route} />
Expand All @@ -72,7 +70,6 @@ class App extends React.Component {
barStyle="default"
/>
<Navigator
ref="navigator"
style={styles.navigator}
configureScene={this.configureScene}
renderScene={this.renderScene}
Expand Down
2 changes: 1 addition & 1 deletion app/pages/About.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ import {
View
} from 'react-native';

import DeviceInfo from 'react-native-device-info';
import ReadingToolbar from '../components/ReadingToolbar';
import Button from '../components/Button';
import DeviceInfo from 'react-native-device-info';

let API_STORE = 'http://apistore.baidu.com/';
let READING_REPO = 'https://github.com/attentiveness/reading';
Expand Down
1 change: 1 addition & 0 deletions app/pages/Category.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { toastShort } from '../utils/ToastUtil';
import { CATEGORIES } from '../constants/Alias';

const checkIno = require('../img/check.png');

let toolbarActions = [
{ title: '提交', icon: checkIno, show: 'always' }
];
Expand Down
3 changes: 2 additions & 1 deletion app/pages/Feedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ import {
View
} from 'react-native';

import ReadingToolbar from '../components/ReadingToolbar';
import AV from 'leancloud-storage';
import DeviceInfo from 'react-native-device-info';
import ReadingToolbar from '../components/ReadingToolbar';
import { toastShort } from '../utils/ToastUtil';

const checkIco = require('../img/check.png');

let toolbarActions = [
{ title: '提交', icon: checkIco, show: 'always' }
];
Expand Down
25 changes: 14 additions & 11 deletions app/pages/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ import {
View,
DeviceEventEmitter
} from 'react-native';
import LoadingView from '../components/LoadingView';

import DrawerLayout from 'react-native-drawer-layout';
import { fetchArticles } from '../actions/read';
import ReadingToolbar from '../components/ReadingToolbar';
import TimeAgo from 'react-native-timeago';
import ScrollableTabView, { DefaultTabBar } from 'react-native-scrollable-tab-view';
import * as readAction from '../actions/read';
import LoadingView from '../components/LoadingView';
import ReadingToolbar from '../components/ReadingToolbar';
import About from '../pages/About';
import Feedback from '../pages/Feedback';
import CategoryContainer from '../containers/CategoryContainer';
Expand All @@ -45,14 +47,15 @@ import Storage from '../utils/Storage';
import { CATEGORIES } from '../constants/Alias';
import WebViewPage from '../pages/WebViewPage';
import { formatStringWithHtml } from '../utils/FormatUtil';
import TimeAgo from 'react-native-timeago';

require('moment/locale/zh-cn');

const homeImg = require('../img/home.png');
const categoryImg = require('../img/category.png');
const inspectionImg = require('../img/inspection.png');
const infoImg = require('../img/info.png');
const menuImg = require('../img/menu.png');

const propTypes = {
dispatch: PropTypes.func.isRequired,
read: PropTypes.object.isRequired
Expand Down Expand Up @@ -83,7 +86,7 @@ class Main extends React.Component {
const { dispatch } = this.props;
DeviceEventEmitter.addListener('changeCategory', (typeIds) => {
typeIds.forEach((typeId) => {
dispatch(fetchArticles(false, true, typeId));
dispatch(readAction.fetchArticles(false, true, typeId));
});
this.setState({
typeIds
Expand All @@ -96,7 +99,7 @@ class Main extends React.Component {
typeIds = [0, 12, 9, 2];
}
typeIds.forEach((typeId) => {
dispatch(fetchArticles(false, true, typeId));
dispatch(readAction.fetchArticles(false, true, typeId));
});
this.setState({
typeIds
Expand All @@ -121,7 +124,7 @@ class Main extends React.Component {
onRefresh(typeId) {
const { dispatch } = this.props;
canLoadMore = false;
dispatch(fetchArticles(true, false, typeId));
dispatch(readAction.fetchArticles(true, false, typeId));
}

onPress(article) {
Expand All @@ -135,7 +138,7 @@ class Main extends React.Component {

onPressDrawerItem(index) {
const { navigator } = this.props;
this.refs.drawer.closeDrawer();
this.drawer.closeDrawer();
switch (index) {
case 1:
navigator.push({
Expand All @@ -162,7 +165,7 @@ class Main extends React.Component {
}

onIconClicked() {
this.refs.drawer.openDrawer();
this.drawer.openDrawer();
}

onScroll() {
Expand All @@ -176,7 +179,7 @@ class Main extends React.Component {
if (canLoadMore && time - loadMoreTime > 1) {
page++;
const { dispatch } = this.props;
dispatch(fetchArticles(false, false, typeId, true, page));
dispatch(readAction.fetchArticles(false, false, typeId, true, page));
canLoadMore = false;
loadMoreTime = Date.parse(new Date()) / 1000;
}
Expand Down Expand Up @@ -352,7 +355,7 @@ class Main extends React.Component {
const { read, navigator } = this.props;
return (
<DrawerLayout
ref="drawer"
ref={(ref) => { this.drawer = ref; }}
drawerWidth={Dimensions.get('window').width / 5 * 3}
drawerPosition={Platform.OS === 'android' ? DrawerLayoutAndroid.positions.Left : 'left'}
renderNavigationView={this.renderNavigationView}
Expand Down
7 changes: 4 additions & 3 deletions app/pages/WebViewPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@ import {
Modal
} from 'react-native';

import * as WeChat from 'react-native-wechat';
import ReadingToolbar from '../components/ReadingToolbar';
import { toastShort } from '../utils/ToastUtil';
import LoadingView from '../components/LoadingView';
import { naviGoBack } from '../utils/CommonUtil';
import * as WeChat from 'react-native-wechat';

const shareImg = require('../img/share.png');
const shareIconWechat = require('../img/share_icon_wechat.png');
const shareIconMoments = require('../img/share_icon_moments.png');

let toolbarActions = [
{ title: '分享', icon: shareImg, show: 'always' }
];
Expand Down Expand Up @@ -79,7 +80,7 @@ class WebViewPage extends React.Component {
});
return true;
} else if (canGoBack) {
this.refs.webview.goBack();
this.webview.goBack();
return true;
}
return naviGoBack(this.props.navigator);
Expand Down Expand Up @@ -201,7 +202,7 @@ class WebViewPage extends React.Component {
{this.renderSpinner()}
</Modal>
<WebView
ref="webview"
ref={(ref) => { this.webview = ref; }}
automaticallyAdjustContentInsets={false}
style={{ flex: 1 }}
source={{ uri: route.article.url }}
Expand Down
14 changes: 5 additions & 9 deletions app/root.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,10 @@ import App from './containers/app';

const store = configureStore();

class Root extends React.Component {
render() {
return (
<Provider store={store}>
<App />
</Provider>
);
}
}
const Root = () => (
<Provider store={store}>
<App />
</Provider>
);

export default Root;
5 changes: 2 additions & 3 deletions app/utils/Storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
*
*/
import React from 'react-native';
const {
AsyncStorage
} = React;

const { AsyncStorage } = React;

class DeviceStorage {
static get(key) {
Expand Down

0 comments on commit 5e6d461

Please sign in to comment.