Merge pull request #768 from esteemapp/eslint-fix

Eslint fix
This commit is contained in:
uğur erdal 2019-04-26 16:32:02 +03:00 committed by GitHub
commit bfffe0cebe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 193 additions and 205 deletions

View File

@ -38,7 +38,7 @@ class PostButtonView extends Component {
if (this.mode._value) {
const { routes, isCollapsePostButtonOpen } = this.props;
const nextRouteName = nextProps.routes[0].routes[nextProps.routes[0].routes.length - 1].routeName;
const routeName = routes[0].routes[routes[0].routes.length - 1].routeName;
const { routeName } = routes[0].routes[routes[0].routes.length - 1];
const { isCollapse } = this.state;
if (

View File

@ -35,7 +35,7 @@ class PostButtonsForAndroid extends Component {
// For closing sub buttons
const { routes, isCollapsePostButtonOpen } = this.props;
const nextRouteName = nextProps.routes[0].routes[nextProps.routes[0].routes.length - 1].routeName;
const routeName = routes[0].routes[routes[0].routes.length - 1].routeName;
const { routeName } = routes[0].routes[routes[0].routes.length - 1];
const { isCollapse } = this.state;
if (

View File

@ -32,7 +32,7 @@ class PostHeaderDescription extends PureComponent {
}
// Component Functions
_handleOnUserPress = username => {
_handleOnUserPress = (username) => {
const { navigation, profileOnPress, reputation } = this.props;
if (profileOnPress) {

View File

@ -189,7 +189,7 @@ export const updateUserData = userData => new Promise((resolve, reject) => {
export const removeUserData = username => new Promise((resolve, reject) => {
try {
const account = realm.objects(USER_SCHEMA).filtered('username = $0', username)
const account = realm.objects(USER_SCHEMA).filtered('username = $0', username);
if (Array.from(account).length > 0) {
realm.write(() => {
realm.delete(account);

View File

@ -42,7 +42,9 @@ class ApplicationScreen extends Component {
};
render() {
const { isConnected, isDarkTheme, locale, toastNotification } = this.props;
const {
isConnected, isDarkTheme, locale, toastNotification,
} = this.props;
const { isShowToastNotification } = this.state;
const barStyle = isDarkTheme ? 'light-content' : 'dark-content';
const barColor = isDarkTheme ? '#1e2835' : '#fff';

View File

@ -2,6 +2,7 @@ import React, { Component } from 'react';
import { injectIntl } from 'react-intl';
import { View, FlatList, Text } from 'react-native';
import ScrollableTabView from '@esteemapp/react-native-scrollable-tab-view';
import ActionSheet from 'react-native-actionsheet';
// Utils
import { getPostSummary } from '../../../utils/formatter';
@ -13,7 +14,6 @@ import { BasicHeader } from '../../../components/basicHeader';
import { PostListItem } from '../../../components/postListItem';
import { PostCardPlaceHolder } from '../../../components/basicUIElements';
import { TabBar } from '../../../components/tabBar';
import ActionSheet from 'react-native-actionsheet';
// Styles
import globalStyles from '../../../globalStyles';
@ -29,7 +29,7 @@ class DraftsScreen extends Component {
super(props);
this.state = {
selectedId: null,
}
};
}
// Component Life Cycles
@ -56,7 +56,7 @@ class DraftsScreen extends Component {
image={image ? { uri: catchDraftImage(item.body) } : null}
username={currentAccount.name}
reputation={currentAccount.reputation}
handleOnPressItem={() => isSchedules ? this.setState({selectedId: item._id}, () => this.ActionSheet.show()) : editDraft}
handleOnPressItem={() => (isSchedules ? this.setState({ selectedId: item._id }, () => this.ActionSheet.show()) : editDraft)}
handleOnRemoveItem={isSchedules ? removeSchedule : removeDraft}
id={item._id}
key={item._id}
@ -97,7 +97,9 @@ class DraftsScreen extends Component {
};
render() {
const { drafts, schedules, intl, moveScheduleToDraft } = this.props;
const {
drafts, schedules, intl, moveScheduleToDraft,
} = this.props;
const { selectedId } = this.state;
return (

View File

@ -287,7 +287,7 @@ class PinCodeContainer extends Component {
[
{ text: intl.formatMessage({ id: 'alert.clear' }), onPress: () => this._forgotPinCode() },
{ text: intl.formatMessage({ id: 'alert.cancel' }), style: 'destructive' },
]
],
);
};

View File

@ -88,7 +88,7 @@ export const makeJsonMetadata = (meta, tags) => Object.assign({}, meta, {
app: 'esteem/2.0.0-mobile',
format: 'markdown+html',
community: 'esteem.app',
});
});
export const extractMetadata = (body) => {
const urlReg = /(\b(https?|ftp):\/\/[A-Z0-9+&@#/%?=~_|!:,.;-]*[-A-Z0-9+&@#/%=~_|])/gim;

View File

@ -24,7 +24,7 @@ const imgTagRegex = /(<img[^>]*>)/g;
const iframeRegex = /(?:<iframe[^>]*)(?:(?:\/>)|(?:>.*?<\/iframe>))/g;
const hTagRegex = /(<h([1-6])>([^<]*)<\/h([1-6])>)/g;
export const markDown2Html = input => {
export const markDown2Html = (input) => {
if (!input) {
return '';
}
@ -95,25 +95,22 @@ export const markDown2Html = input => {
return output;
};
const replaceAuthorNames = input =>
input.replace(authorNameRegex, (match, preceeding1, preceeding2, user) => {
const replaceAuthorNames = input => input.replace(authorNameRegex, (match, preceeding1, preceeding2, user) => {
const userLower = user.toLowerCase();
const preceedings = (preceeding1 || '') + (preceeding2 || '');
return `${preceedings}<a class="markdown-author-link" href="${userLower}" data-author="${userLower}"> @${user}</a>`;
});
});
const replaceTags = input =>
input.replace(tagsRegex, tag => {
const replaceTags = input => input.replace(tagsRegex, (tag) => {
if (/#[\d]+$/.test(tag)) return tag;
const preceding = /^\s|>/.test(tag) ? tag[0] : '';
tag = tag.replace('>', '');
const tag2 = tag.trim().substring(1);
const tagLower = tag2.toLowerCase();
return `${preceding}<a class="markdown-tag-link" href="${tagLower}" data-tag="${tagLower}">${tag.trim()}</a>`;
});
});
const handleATag = input =>
input.replace(aTagRegex, link => {
const handleATag = input => input.replace(aTagRegex, (link) => {
if (dTubeRegex.test(link)) {
const dTubeMatch = link.match(dTubeRegex)[0];
const execLink = dTubeRegex.exec(dTubeMatch);
@ -136,12 +133,11 @@ const handleATag = input =>
}
return link;
});
});
const handleHTag = input => input.replace(hTagRegex, tag => `<div>${tag}</div>`);
const handleMarkdownLink = input =>
input.replace(copiedPostRegex, link => {
const handleMarkdownLink = input => input.replace(copiedPostRegex, (link) => {
const postMatch = link.match(copiedPostRegex);
if (postMatch) {
@ -151,25 +147,23 @@ const handleMarkdownLink = input =>
tag = 'busy';
}
const _permlink =
postMatch[3].indexOf(')') > 0 ? postMatch[3].replace(')', '') : postMatch[3];
const _permlink = postMatch[3].indexOf(')') > 0 ? postMatch[3].replace(')', '') : postMatch[3];
return `<a class="markdown-post-link" href="${_permlink}" data_tag={${tag.trim()}} data_author="${postMatch[2].replace(
'@',
'',
)}">/${_permlink}</a>`;
}
});
});
const handleLinks = input =>
input.replace(linkRegex, link => {
const handleLinks = input => input.replace(linkRegex, (link) => {
if (link) {
if (
link
.toLowerCase()
.trim()
.indexOf('https://steemitimages.com/0x0/') === 0 ||
imgRegex.test(link)
.indexOf('https://steemitimages.com/0x0/') === 0
|| imgRegex.test(link)
) {
const imageMatch = link.match(imgRegex);
@ -197,10 +191,9 @@ const handleLinks = input =>
}
return link;
});
});
const changeMarkdownImage = input =>
input.replace(markdownImageRegex, link => {
const changeMarkdownImage = input => input.replace(markdownImageRegex, (link) => {
const markdownMatch = link.match(markdownImageRegex);
if (markdownMatch[0]) {
const firstMarkdownMatch = markdownMatch[0];
@ -209,26 +202,23 @@ const changeMarkdownImage = input =>
return _link;
}
return link;
});
});
const centerStyling = input =>
input.replace(
const centerStyling = input => input.replace(
centerRegex,
() => '<center style="text-align: center; align-items: center; justify-content: center;">',
);
);
const steemitUrlHandle = input =>
input.replace(postRegex, link => {
const steemitUrlHandle = input => input.replace(postRegex, (link) => {
const postMatch = link.match(postRegex);
const tag = postMatch[2];
const author = postMatch[3].replace('@', '');
const permlink = postMatch[4];
return `<a class="markdown-post-link" href="${permlink}" data_tag={${tag}} data_author="${author}">/${permlink}</a>`;
});
});
const handleImageTag = input =>
input.replace(imgTagRegex, imgTag => {
const handleImageTag = input => input.replace(imgTagRegex, (imgTag) => {
const _imgTag = imgTag.trim();
const match = _imgTag.match(imgRegex);
@ -237,10 +227,9 @@ const handleImageTag = input =>
}
return imgTag;
});
});
const createYoutubeIframe = input =>
input.replace(youTubeRegex, link => {
const createYoutubeIframe = input => input.replace(youTubeRegex, (link) => {
if (link.indexOf(')') || link.indexOf('(')) {
return link;
}
@ -256,10 +245,9 @@ const createYoutubeIframe = input =>
}
return link;
});
});
const handleIframe = input =>
input.replace(iframeRegex, link => {
const handleIframe = input => input.replace(iframeRegex, (link) => {
const match = link.match(linkRegex);
if (match && match[0]) {
@ -267,20 +255,18 @@ const handleIframe = input =>
}
return link;
});
});
const createVimeoIframe = input =>
input.replace(vimeoRegex, link => {
const createVimeoIframe = input => input.replace(vimeoRegex, (link) => {
const execLink = vimeoRegex.exec(link);
const embedLink = `https://player.vimeo.com/video/${execLink[3]}`;
return iframeBody(embedLink);
});
});
const iframeBody = link => `<iframe frameborder='0' allowfullscreen src='${link}'></iframe>`;
const imageBody = link =>
`<center style="text-align: center; align-items: center; justify-content: center;"><img src="${`https://steemitimages.com/600x0/${link}`}" /></center>`;
const imageBody = link => `<center style="text-align: center; align-items: center; justify-content: center;"><img src="${`https://steemitimages.com/600x0/${link}`}" /></center>`;
const gifBody = link => `<img src="${`https://steemitimages.com/0x0/${link}`}" />`;
const handleImageLink = input => input.replace(imgRegex, link => imageBody(link));

View File

@ -3,8 +3,9 @@ import { markDown2Html } from './markdownToHtml';
import { getPostSummary } from './formatter';
import { getReputation } from './reputation';
export const parsePosts = (posts, currentUserName) =>
!posts ? null : posts.map(post => parsePost(post, currentUserName));
export const parsePosts = (posts, currentUserName) => (
!posts ? null : posts.map(post => parsePost(post, currentUserName))
);
export const parsePost = (post, currentUserName) => {
if (!post) {
@ -32,10 +33,9 @@ export const parsePost = (post, currentUserName) => {
post.is_voted = false;
}
const totalPayout =
parseFloat(post.pending_payout_value) +
parseFloat(post.total_payout_value) +
parseFloat(post.curator_payout_value);
const totalPayout = parseFloat(post.pending_payout_value)
+ parseFloat(post.total_payout_value)
+ parseFloat(post.curator_payout_value);
post.total_payout = totalPayout.toFixed(3);
@ -44,8 +44,7 @@ export const parsePost = (post, currentUserName) => {
if (post.active_votes && post.active_votes.length > 0) {
for (const i in post.active_votes) {
post.vote_perecent =
post.active_votes[i].voter === currentUserName ? post.active_votes[i].percent : null;
post.vote_perecent = post.active_votes[i].voter === currentUserName ? post.active_votes[i].percent : null;
post.active_votes[i].value = (post.active_votes[i].rshares * ratio).toFixed(3);
post.active_votes[i].reputation = getReputation(post.active_votes[i].reputation);
post.active_votes[i].percent = post.active_votes[i].percent / 100;
@ -59,8 +58,7 @@ export const parsePost = (post, currentUserName) => {
return post;
};
const isVoted = (activeVotes, currentUserName) =>
activeVotes.some(v => v.voter === currentUserName && v.percent > 0);
const isVoted = (activeVotes, currentUserName) => activeVotes.some(v => v.voter === currentUserName && v.percent > 0);
const postImage = (metaData, body) => {
const imgTagRegex = /(<img[^>]*>)/g;
@ -135,8 +133,8 @@ const postImage = (metaData, body) => {
// }
// };
export const parseComments = comments => {
comments.map(comment => {
export const parseComments = (comments) => {
comments.map((comment) => {
comment.pending_payout_value = parseFloat(comment.pending_payout_value).toFixed(3);
comment.vote_count = comment.active_votes.length;
comment.author_reputation = getReputation(comment.author_reputation);

View File

@ -1,7 +1,7 @@
import { Linking } from 'react-native';
import qs from 'qs';
export const sendEmail = async (to, subject, body, options = {}) => {
export const sendEmail = async (to, subject, body, options = {}) => {
const { cc, bcc } = options;
let url = `mailto:${to}`;