Skip to content

Commit

Permalink
Merge pull request #2750 from GeekyAnts/feat/eslint-fixes
Browse files Browse the repository at this point in the history
fix(): eslint fixes
  • Loading branch information
sankhadeeproy007 authored Jul 8, 2019
2 parents 19fdc8c + de81ef2 commit 1ca2d20
Show file tree
Hide file tree
Showing 121 changed files with 887 additions and 956 deletions.
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
vendor/
Components/Styles/
dist/
dist/
src/basic/Tabs/
src/basic/SwipeRow.js
13 changes: 12 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
{
"extends": ["airbnb", "prettier"],
"parser": "babel-eslint",
"rules": {
"indent": ["warn", 2]
"indent": ["error", 2],
"react/require-extension": "off",
"import/order": ["error", { "newlines-between": "always" }],
"func-names": "off",
"import/prefer-default-export": "off",
"no-prototype-builtins": "off",
"no-nested-ternary": "warn",
"no-underscore-dangle": "off",
"no-unused-expressions": "off",
"react/jsx-filename-extension": "off",
"react/prop-types": "off"
},
"plugins": ["react", "jsx-a11y", "import", "react-native"]
}
53 changes: 7 additions & 46 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
"blueimp-md5": "^2.5.0",
"clamp": "^1.0.1",
"color": "~1.0.3",
"create-react-class": "^15.6.3",
"eslint-config-prettier": "^6.0.0",
"fs-extra": "^2.0.0",
"jest-react-native": "^18.0.0",
"lodash": "4.17.11",
Expand Down
25 changes: 16 additions & 9 deletions src/basic/Accordion.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import React, { Component } from 'react';
/* eslint-disable react/no-multi-comp */
/* eslint-disable react/prefer-stateless-function */
import React from 'react';
import {
Animated,
TouchableWithoutFeedback,
FlatList,
StyleSheet,
View
} from 'react-native';

import variable from '../theme/variables/platform';

import { Text } from './Text';
import { Icon } from './Icon';
import variable from '../theme/variables/platform';

class DefaultHeader extends React.Component {
render() {
Expand All @@ -18,6 +22,7 @@ class DefaultHeader extends React.Component {
return (
<View
style={[
// eslint-disable-next-line no-use-before-define
styles.defaultHeader,
this.props.headerStyle
? this.props.headerStyle
Expand Down Expand Up @@ -83,7 +88,7 @@ class AccordionSubItem extends React.Component {
}).start();
}
render() {
let { fadeAnim } = this.state;
const { fadeAnim } = this.state;
return (
<Animated.View style={{ ...this.props.style, opacity: fadeAnim }}>
{this.props.children}
Expand Down Expand Up @@ -133,7 +138,13 @@ class AccordionItem extends React.Component {
}

export class Accordion extends React.Component {
state = { selected: undefined };
constructor(props) {
super(props);
this.state = {
selected: props.expanded
};
}

setSelected(index) {
if (this.state.selected === index) {
this.setState({ selected: undefined });
Expand All @@ -142,10 +153,6 @@ export class Accordion extends React.Component {
}
}

componentDidMount() {
this.setState({ selected: this.props.expanded });
}

render() {
const variables = this.context.theme
? this.context.theme['@@shoutem.theme/themeStyle'].variables
Expand All @@ -168,7 +175,7 @@ export class Accordion extends React.Component {
item={item}
expanded={this.state.selected === index}
index={index}
setSelected={this.setSelected.bind(this)}
setSelected={i => this.setSelected(i)}
headerStyle={this.props.headerStyle}
contentStyle={this.props.contentStyle}
renderHeader={this.props.renderHeader}
Expand Down
48 changes: 26 additions & 22 deletions src/basic/Actionsheet.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable radix */
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import {
View,
Modal,
Platform,
ActionSheetIOS,
Expand All @@ -11,40 +11,49 @@ import {
Dimensions
} from 'react-native';
import { connectStyle } from 'native-base-shoutem-theme';

import mapPropsToStyleNames from '../utils/mapPropsToStyleNames';

import { Text } from './Text';
import { Button } from './Button';
import { ViewNB } from './View';
import { Icon } from './Icon';
import { Left } from './Left';
import { Right } from './Right';
import { Body } from './Body';
import { ListItem } from './ListItem';
import mapPropsToStyleNames from '../utils/mapPropsToStyleNames';

class ActionSheetContainer extends Component {
static actionsheetInstance;
static show(config, callback) {
this.actionsheetInstance._root.showActionSheet(config, callback);
}
static hide() {
this.actionsheetInstance._root.hideActionSheet();
}

constructor(props) {
super(props);
this.state = {
modalVisible: false,
items: []
};
}
static actionsheetInstance;
static show(config, callback) {
this.actionsheetInstance._root.showActionSheet(config, callback);
}
static hide() {
this.actionsheetInstance._root.hideActionSheet();

componentDidMount() {
if (!this.props.autoHide && this.props.duration) {
console.warn(`It's not recommended to set autoHide false with duration`);
}
}

showActionSheet(config, callback) {
if (Platform.OS === 'ios') {
if (typeof config.options[0] == 'object') {
let options = config.options;
let filtered = options.map(item => {
if (typeof config.options[0] === 'object') {
const options = config.options;
const filtered = options.map(item => {
return item.text;
});
config.options = filtered;
ActionSheetIOS.showActionSheetWithOptions(config, callback);

const filteredConfig = { ...config, options: filtered };
ActionSheetIOS.showActionSheetWithOptions(filteredConfig, callback);
} else {
ActionSheetIOS.showActionSheetWithOptions(config, callback);
}
Expand All @@ -56,7 +65,7 @@ class ActionSheetContainer extends Component {
destructiveButtonIndex: config.destructiveButtonIndex,
cancelButtonIndex: config.cancelButtonIndex,
modalVisible: true,
callback: callback
callback
});
}
}
Expand All @@ -65,16 +74,11 @@ class ActionSheetContainer extends Component {
this.setState({ modalVisible: false });
}

componentDidMount() {
if (!this.props.autoHide && this.props.duration) {
console.warn(`It's not recommended to set autoHide false with duration`);
}
}
render() {
return (
<Modal
animationType={'fade'}
transparent={true}
transparent
visible={this.state.modalVisible}
onRequestClose={() => {
this.state.callback(this.state.cancelButtonIndex);
Expand Down
Loading

0 comments on commit 1ca2d20

Please sign in to comment.