From 5fc7fe247e9e112502f690e0bd412ac32ce45d3a Mon Sep 17 00:00:00 2001 From: Diego Sampaio Date: Mon, 21 Aug 2017 22:24:41 -0300 Subject: [PATCH] Fix lint --- .eslintrc | 3 +- .gitignore | 2 + app/animations/fade.js | 9 +- app/components/MessageBox.js | 9 +- app/components/RoomItem.js | 7 +- app/components/banner.js | 7 + app/components/message/card.js | 3 +- app/index.js | 8 +- app/lib/createStore.js | 1 - app/lib/realm.js | 1 - app/lib/rocketchat.js | 1 - app/sagas/messages.js | 2 +- app/views/login.js | 3 +- app/views/room.js | 4 +- app/views/roomsList.js | 3 +- app/views/serverList.js | 1 + package-lock.json | 1090 ++++++-------------------------- 17 files changed, 221 insertions(+), 933 deletions(-) diff --git a/.eslintrc b/.eslintrc index 0c700ae4e..95bccaf46 100644 --- a/.eslintrc +++ b/.eslintrc @@ -113,7 +113,8 @@ "semi": [2, "always"], "prefer-const": 2, "object-shorthand": 2, - "consistent-return": 0 + "consistent-return": 0, + "global-require": "off" }, "globals": { "__DEV__": true diff --git a/.gitignore b/.gitignore index 10be19751..2b0cf23ea 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,8 @@ node_modules/ npm-debug.log yarn-error.log +coverage/ + # BUCK buck-out/ \.buckd/ diff --git a/app/animations/fade.js b/app/animations/fade.js index 725ccbaaf..29de4e6cc 100644 --- a/app/animations/fade.js +++ b/app/animations/fade.js @@ -1,7 +1,14 @@ +import PropTypes from 'prop-types'; import React from 'react'; import { Animated, Text } from 'react-native'; export default class Fade extends React.Component { + static propTypes = { + visible: PropTypes.bool.isRequired, + style: PropTypes.object, + children: PropTypes.object + } + constructor(props) { super(props); this.state = { @@ -26,7 +33,7 @@ export default class Fade extends React.Component { } render() { - const { visible, style, children, ...rest } = this.props; + const { style, children, ...rest } = this.props; const containerStyle = { opacity: this._visibility.interpolate({ diff --git a/app/components/MessageBox.js b/app/components/MessageBox.js index 438375bc8..263b1b992 100644 --- a/app/components/MessageBox.js +++ b/app/components/MessageBox.js @@ -36,18 +36,15 @@ export default class MessageBox extends React.PureComponent { rid: PropTypes.string.isRequired } - constructor(props) { - super(props); - // this._textInput.setNativeProps({ text: '' }); - } - submit(message) { // console.log(this.state); const text = message; if (text.trim() === '') { return; } - this.component && this.component.setNativeProps({ text: '' }); + if (this.component) { + this.component.setNativeProps({ text: '' }); + } this.props.onSubmit(text); } diff --git a/app/components/RoomItem.js b/app/components/RoomItem.js index 8013f061e..7737e03f3 100644 --- a/app/components/RoomItem.js +++ b/app/components/RoomItem.js @@ -62,7 +62,8 @@ export default class RoomItem extends React.PureComponent { type: PropTypes.string.isRequired, name: PropTypes.string.isRequired, unread: PropTypes.number, - baseUrl: PropTypes.string + baseUrl: PropTypes.string, + onPress: PropTypes.func } get icon() { @@ -115,9 +116,9 @@ export default class RoomItem extends React.PureComponent { } render() { - const { unread, name, _id } = this.props; + const { unread, name } = this.props; return ( - + {this.icon} { name } {this.renderNumber(unread)} diff --git a/app/components/banner.js b/app/components/banner.js index eb159c496..1192500bc 100644 --- a/app/components/banner.js +++ b/app/components/banner.js @@ -1,4 +1,5 @@ import { StyleSheet, View, Text } from 'react-native'; +import PropTypes from 'prop-types'; import React from 'react'; import { connect } from 'react-redux'; @@ -24,6 +25,12 @@ const styles = StyleSheet.create({ })) export default class Banner extends React.PureComponent { + static propTypes = { + connecting: PropTypes.bool, + authenticating: PropTypes.bool, + offline: PropTypes.bool + } + render() { const { connecting, authenticating, offline } = this.props; if (connecting) { diff --git a/app/components/message/card.js b/app/components/message/card.js index f9793511d..c039c26d8 100644 --- a/app/components/message/card.js +++ b/app/components/message/card.js @@ -37,7 +37,8 @@ Navigation.registerComponent('CustomButton', () => CustomButton); export default class Cards extends React.PureComponent { static propTypes = { - data: PropTypes.object.isRequired + data: PropTypes.object.isRequired, + base: PropTypes.string } constructor() { super(); diff --git a/app/index.js b/app/index.js index 89795d768..be8956c72 100644 --- a/app/index.js +++ b/app/index.js @@ -1,3 +1,4 @@ +import PropTypes from 'prop-types'; import React from 'react'; import { connect } from 'react-redux'; import { Text } from 'react-native'; @@ -61,13 +62,18 @@ export class PrivateScreen extends React.PureComponent { return (); } } -@connect(state => ({ +@connect(() => ({ // logged: state.login.isAuthenticated }), dispatch => ({ // navigate: routeName => dispatch(NavigationActions.navigate({ routeName })), setNavigator: navigator => dispatch(setNavigator(navigator)) })) export const HomeScreen = class extends React.PureComponent { + static propTypes = { + setNavigator: PropTypes.fun.isRequired, + navigator: PropTypes.object.isRequired + } + componentWillMount() { this.props.setNavigator(this.props.navigator); this.props.navigator.resetTo({ diff --git a/app/lib/createStore.js b/app/lib/createStore.js index d187127f2..2f1220570 100644 --- a/app/lib/createStore.js +++ b/app/lib/createStore.js @@ -3,7 +3,6 @@ import 'regenerator-runtime/runtime'; import { createStore, applyMiddleware } from 'redux'; import createSagaMiddleware from 'redux-saga'; -import logger from 'redux-logger'; import reducers from '../reducers'; import sagas from '../sagas'; diff --git a/app/lib/realm.js b/app/lib/realm.js index c58b4a75a..2ab94a14f 100644 --- a/app/lib/realm.js +++ b/app/lib/realm.js @@ -1,5 +1,4 @@ import Realm from 'realm'; -import { AsyncStorage } from 'react-native'; const serversSchema = { name: 'servers', diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js index a776eebe5..1bed464f1 100644 --- a/app/lib/rocketchat.js +++ b/app/lib/rocketchat.js @@ -9,7 +9,6 @@ import settingsType from '../constants/settings'; import realm from './realm'; import * as actions from '../actions'; import { disconnect, connectSuccess } from '../actions/connect'; -import { loginSuccess } from '../actions/login'; export { Accounts } from 'react-native-meteor'; diff --git a/app/sagas/messages.js b/app/sagas/messages.js index e379398f5..94d4ad4d8 100644 --- a/app/sagas/messages.js +++ b/app/sagas/messages.js @@ -1,4 +1,4 @@ -import { takeEvery, takeLatest, select, take, put } from 'redux-saga/effects'; +import { takeLatest, select, take, put } from 'redux-saga/effects'; import { MESSAGES, LOGIN } from '../actions/actionsTypes'; import { messagesSuccess, messagesFailure } from '../actions/messages'; import RocketChat from '../lib/rocketchat'; diff --git a/app/views/login.js b/app/views/login.js index 7f37a7de0..dcb5cf98c 100644 --- a/app/views/login.js +++ b/app/views/login.js @@ -75,7 +75,8 @@ class LoginView extends React.Component { loginSubmit: PropTypes.func.isRequired, server: PropTypes.string.isRequired, Accounts_EmailOrUsernamePlaceholder: PropTypes.string, - Accounts_PasswordPlaceholder: PropTypes.string + Accounts_PasswordPlaceholder: PropTypes.string, + login: PropTypes.object } static navigationOptions = () => ({ diff --git a/app/views/room.js b/app/views/room.js index 243954184..2f0e0a29a 100644 --- a/app/views/room.js +++ b/app/views/room.js @@ -57,12 +57,14 @@ const styles = StyleSheet.create({ export default class RoomView extends React.Component { static propTypes = { navigator: PropTypes.object.isRequired, + getMessages: PropTypes.func.isRequired, rid: PropTypes.string, sid: PropTypes.string, name: PropTypes.string, server: PropTypes.string, Site_Url: PropTypes.string, - Message_TimeFormat: PropTypes.string + Message_TimeFormat: PropTypes.string, + loading: PropTypes.bool } constructor(props) { diff --git a/app/views/roomsList.js b/app/views/roomsList.js index 6c79cfd34..7026de2c5 100644 --- a/app/views/roomsList.js +++ b/app/views/roomsList.js @@ -67,6 +67,7 @@ const ds = new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2 }); export default class RoomsListView extends React.Component { static propTypes = { navigator: PropTypes.object.isRequired, + Site_Url: PropTypes.string.isRequired, server: PropTypes.string } @@ -236,7 +237,7 @@ export default class RoomsListView extends React.Component { renderItem = item => (