Permalink
Browse files

chore(linting): linting all

  • Loading branch information...
xcarpentier committed Dec 18, 2017
1 parent 1518e21 commit 28cb4675285c80b70a0f042bddde0e43ece47a0a
Showing with 774 additions and 710 deletions.
  1. +1 βˆ’0 .eslintignore
  2. +14 βˆ’9 .eslintrc
  3. +1 βˆ’0 .gitignore
  4. +30 βˆ’34 src/Actions.js
  5. +51 βˆ’21 src/Avatar.js
  6. +73 βˆ’44 src/Bubble.js
  7. +14 βˆ’0 src/Colors.js
  8. +19 βˆ’23 src/Composer.js
  9. +10 βˆ’0 src/Constants.js
  10. +26 βˆ’35 src/Day.js
  11. +30 βˆ’47 src/GiftedAvatar.js
  12. +224 βˆ’214 src/GiftedChat.js
  13. +9 βˆ’4 src/GiftedChatInteractionManager.js
  14. +25 βˆ’29 src/InputToolbar.js
  15. +12 βˆ’19 src/LoadEarlier.js
  16. +22 βˆ’19 src/Message.js
  17. +66 βˆ’63 src/MessageContainer.js
  18. +23 βˆ’27 src/MessageImage.js
  19. +51 βˆ’39 src/MessageText.js
  20. +24 βˆ’33 src/Send.js
  21. +19 βˆ’22 src/SystemMessage.js
  22. +19 βˆ’17 src/Time.js
  23. +11 βˆ’11 src/utils.js
View
@@ -1,3 +1,4 @@
node_modules
android
ios
example
View
@@ -1,12 +1,17 @@
{
"extends": "cooperka/react-native",
"extends": "cooperka/react-native",
"env": {
"browser": true,
"jest": true
},
// Any rules here will override those from
// https://github.com/cooperka/eslint-config-cooperka.
"rules": {}
"env": {
"browser": true,
"jest": true
},
"rules": {
"no-underscore-dangle": 0,
"import/no-unresolved": [2, { "ignore": ["react", "react-native"] }],
"import/no-extraneous-dependencies": 0,
"import/extensions": 0,
"react/no-unused-prop-types": 0,
"comma-dangle": 0,
"arrow-parens": 0
}
}
View
@@ -4,3 +4,4 @@ npm-debug.log
TODO.md
.idea
.vscode
View
@@ -1,12 +1,9 @@
/* eslint no-use-before-define: ["error", { "variables": false }] */
import PropTypes from 'prop-types';
import React from 'react';
import {
StyleSheet,
Text,
TouchableOpacity,
View,
ViewPropTypes,
} from 'react-native';
import { StyleSheet, Text, TouchableOpacity, View, ViewPropTypes } from 'react-native';
import Colors from './Colors';
export default class Actions extends React.Component {
constructor(props) {
@@ -17,38 +14,34 @@ export default class Actions extends React.Component {
onActionsPress() {
const options = Object.keys(this.props.options);
const cancelButtonIndex = Object.keys(this.props.options).length - 1;
this.context.actionSheet().showActionSheetWithOptions({
options,
cancelButtonIndex,
tintColor: this.props.optionTintColor
},
(buttonIndex) => {
let i = 0;
for (let key in this.props.options) {
if (this.props.options.hasOwnProperty(key)) {
if (buttonIndex === i) {
this.props.options[key](this.props);
return;
this.context.actionSheet().showActionSheetWithOptions(
{
options,
cancelButtonIndex,
tintColor: this.props.optionTintColor,
},
buttonIndex => {
let i = 0;
Object.keys(this.props.options).forEach(key => {
if (this.props.options[key]) {
if (buttonIndex === i) {
this.props.options[key](this.props);
return;
}
i += 1;
}
i++;
}
});
}
});
);
}
renderIcon() {
if (this.props.icon) {
return this.props.icon();
}
return (
<View
style={[styles.wrapper, this.props.wrapperStyle]}
>
<Text
style={[styles.iconText, this.props.iconTextStyle]}
>
+
</Text>
<View style={[styles.wrapper, this.props.wrapperStyle]}>
<Text style={[styles.iconText, this.props.iconTextStyle]}>+</Text>
</View>
);
}
@@ -74,15 +67,15 @@ const styles = StyleSheet.create({
},
wrapper: {
borderRadius: 13,
borderColor: '#b2b2b2',
borderColor: Colors.defaultColor,
borderWidth: 2,
flex: 1,
},
iconText: {
color: '#b2b2b2',
color: Colors.defaultColor,
fontWeight: 'bold',
fontSize: 16,
backgroundColor: 'transparent',
backgroundColor: Colors.backgroundTransparent,
textAlign: 'center',
},
});
@@ -94,10 +87,12 @@ Actions.contextTypes = {
Actions.defaultProps = {
onSend: () => {},
options: {},
optionTintColor: '#007AFF',
optionTintColor: Colors.optionTintColor,
icon: null,
containerStyle: {},
iconTextStyle: {},
wrapperStyle: {},
onPressActionButton: () => {},
};
Actions.propTypes = {
@@ -106,6 +101,7 @@ Actions.propTypes = {
optionTintColor: PropTypes.string,
icon: PropTypes.func,
onPressActionButton: PropTypes.func,
wrapperStyle: ViewPropTypes.style,
containerStyle: ViewPropTypes.style,
iconTextStyle: Text.propTypes.style,
};
View
@@ -1,46 +1,71 @@
/* eslint no-use-before-define: ["error", { "variables": false }] */
import PropTypes from 'prop-types';
import React from "react";
import {Image, StyleSheet, View, ViewPropTypes} from "react-native";
import GiftedAvatar from "./GiftedAvatar";
import {isSameUser, isSameDay, warnDeprecated} from "./utils";
import React from 'react';
import { StyleSheet, View, ViewPropTypes } from 'react-native';
import GiftedAvatar from './GiftedAvatar';
import { isSameUser, isSameDay, warnDeprecated } from './utils';
export default class Avatar extends React.Component {
renderAvatar() {
if (this.props.renderAvatar) {
const {renderAvatar, ...avatarProps} = this.props;
const { renderAvatar, ...avatarProps } = this.props;
return this.props.renderAvatar(avatarProps);
}
return (
<GiftedAvatar
avatarStyle={StyleSheet.flatten([styles[this.props.position].image, this.props.imageStyle[this.props.position]])}
avatarStyle={StyleSheet.flatten([
styles[this.props.position].image,
this.props.imageStyle[this.props.position],
])}
user={this.props.currentMessage.user}
onPress={() => this.props.onPressAvatar && this.props.onPressAvatar(this.props.currentMessage.user)}
onPress={() =>
this.props.onPressAvatar && this.props.onPressAvatar(this.props.currentMessage.user)
}
/>
);
}
render() {
const renderAvatarOnTop = this.props.renderAvatarOnTop;
const messageToCompare = renderAvatarOnTop ? this.props.previousMessage : this.props.nextMessage;
const computedStyle = renderAvatarOnTop ? "onTop" : "onBottom"
const messageToCompare = renderAvatarOnTop
? this.props.previousMessage
: this.props.nextMessage;
const computedStyle = renderAvatarOnTop ? 'onTop' : 'onBottom';
if (this.props.renderAvatar === null) {
return null
return null;
}
if (isSameUser(this.props.currentMessage, messageToCompare) && isSameDay(this.props.currentMessage, messageToCompare)) {
if (
isSameUser(this.props.currentMessage, messageToCompare) &&
isSameDay(this.props.currentMessage, messageToCompare)
) {
return (
<View style={[styles[this.props.position].container, this.props.containerStyle[this.props.position]]}>
<View
style={[
styles[this.props.position].container,
this.props.containerStyle[this.props.position],
]}
>
<GiftedAvatar
avatarStyle={StyleSheet.flatten([styles[this.props.position].image, this.props.imageStyle[this.props.position]])}
avatarStyle={StyleSheet.flatten([
styles[this.props.position].image,
this.props.imageStyle[this.props.position],
])}
/>
</View>
);
}
return (
<View
style={[styles[this.props.position].container, styles[this.props.position][computedStyle], this.props.containerStyle[this.props.position]]}>
style={[
styles[this.props.position].container,
styles[this.props.position][computedStyle],
this.props.containerStyle[this.props.position],
]}
>
{this.renderAvatar()}
</View>
);
@@ -50,10 +75,10 @@ export default class Avatar extends React.Component {
const styles = {
left: StyleSheet.create({
container: {
marginRight: 8
marginRight: 8,
},
onTop: {
alignSelf: "flex-start"
alignSelf: 'flex-start',
},
onBottom: {},
image: {
@@ -67,7 +92,7 @@ const styles = {
marginLeft: 8,
},
onTop: {
alignSelf: "flex-start"
alignSelf: 'flex-start',
},
onBottom: {},
image: {
@@ -80,24 +105,29 @@ const styles = {
Avatar.defaultProps = {
renderAvatarOnTop: false,
renderAvatar: null,
position: 'left',
currentMessage: {
user: null,
},
previousMessage: {},
nextMessage: {},
containerStyle: {},
imageStyle: {},
//TODO: remove in next major release
onPressAvatar: () => {},
// TODO: remove in next major release
isSameDay: warnDeprecated(isSameDay),
isSameUser: warnDeprecated(isSameUser)
isSameUser: warnDeprecated(isSameUser),
};
Avatar.propTypes = {
renderAvatarOnTop: PropTypes.bool,
position: PropTypes.oneOf(['left', 'right']),
currentMessage: PropTypes.object,
previousMessage: PropTypes.object,
nextMessage: PropTypes.object,
onPressAvatar: PropTypes.func,
renderAvatar: PropTypes.func,
containerStyle: PropTypes.shape({
left: ViewPropTypes.style,
right: ViewPropTypes.style,
@@ -106,7 +136,7 @@ Avatar.propTypes = {
left: ViewPropTypes.style,
right: ViewPropTypes.style,
}),
//TODO: remove in next major release
// TODO: remove in next major release
isSameDay: PropTypes.func,
isSameUser: PropTypes.func
isSameUser: PropTypes.func,
};
Oops, something went wrong.

0 comments on commit 28cb467

Please sign in to comment.