lint errors less than 80

This commit is contained in:
noumantahir 2023-11-02 18:34:39 +05:00
parent e0ca8fad7c
commit ed786f37fb
38 changed files with 121 additions and 134 deletions

View File

@ -40,7 +40,7 @@ const ScrollTopPopup = ({
{popupAvatars.map((url, index) => (
<FastImage
key={`image_bubble_${url}-${index}`}
key={`image_bubble_${url}`}
source={{ uri: url }}
style={[styles.popupImage, { zIndex: 10 - index }]}
/>

View File

@ -11,7 +11,6 @@ export interface TabItem {
}
interface StackedTabBarProps {
activeTab: boolean;
goToPage: (pageIndex) => void;
tabs: string[];
pageType?: 'main' | 'community' | 'profile' | 'ownProfile';

View File

@ -38,7 +38,7 @@ const Tooltip = ({ children, text, walkthroughIndex }: TooltipProps, ref) => {
},
}));
const _findAnchor = (e) => {
const _findAnchor = () => {
if (touchableRef.current) {
NativeModules.UIManager.measure(touchableRef.current, (x0, y0, width, height, x, y) => {
setPopoverAnchor({ x, y, width, height });

View File

@ -71,8 +71,6 @@ export const UploadsGalleryModal = forwardRef(
const [isAddingToUploads, setIsAddingToUploads] = useState(false);
const isLoggedIn = useAppSelector((state) => state.application.isLoggedIn);
const pinCode = useAppSelector((state) => state.application.pin);
const currentAccount = useAppSelector((state) => state.account.currentAccount);
useImperativeHandle(ref, () => ({
toggleModal: (value: boolean) => {

View File

@ -10,7 +10,7 @@ import get from 'lodash/get';
// Services and Actions
import { Rect } from 'react-native-modal-popover/lib/PopoverGeometry';
import { View, TouchableOpacity, Text, Alert } from 'react-native';
import { View, TouchableOpacity, Text } from 'react-native';
import { Popover } from 'react-native-modal-popover';
import Slider from '@esteemapp/react-native-slider';
import { useIntl } from 'react-intl';
@ -51,7 +51,6 @@ import { CacheStatus } from '../../../redux/reducers/cacheReducer';
import showLoginAlert from '../../../utils/showLoginAlert';
import { delay } from '../../../utils/editor';
interface Props {}
interface PopoverOptions {
anchorRect: Rect;
content: any;
@ -66,7 +65,8 @@ interface PopoverOptions {
*
*/
const UpvotePopover = forwardRef(({}: Props, ref) => {
// eslint-disable-next-line no-empty-pattern
const UpvotePopover = forwardRef(({}, ref) => {
const intl = useIntl();
const dispatch = useAppDispatch();
@ -234,7 +234,7 @@ const UpvotePopover = forwardRef(({}: Props, ref) => {
// // when voting with same percent or other errors
let errMsg = '';
if (err.message && err.message.indexOf(':') > 0) {
errMsg = err.message.split(': ')[1];
[, errMsg] = err.message.split(': ');
} else {
errMsg = err.jse_shortmsg || err.error_description || err.message;
}

View File

@ -5,14 +5,12 @@ import { useAppDispatch, useAppSelector } from '../../hooks';
import { hideWebViewModal } from '../../redux/actions/uiAction';
import { hsOptions } from '../../constants/hsOptions';
import { Modal } from '..';
import styles from './webViewModalStyles';
interface QRModalProps {}
interface WebViewModalData {
uri: string;
}
export const WebViewModal = ({}: QRModalProps) => {
export const WebViewModal = () => {
const dispatch = useAppDispatch();
const intl = useIntl();
const isVisibleWebViewModal = useAppSelector((state) => state.ui.isVisibleWebViewModal);

View File

@ -85,7 +85,6 @@ class InAppPurchaseContainer extends Component {
_consumePurchase = async (purchase) => {
const {
currentAccount: { name },
intl,
fetchData,
username,
email,
@ -181,15 +180,7 @@ class InAppPurchaseContainer extends Component {
this.purchaseUpdateSubscription = IAP.purchaseUpdatedListener(this._consumePurchase);
this.purchaseErrorSubscription = IAP.purchaseErrorListener((error) => {
const {
currentAccount: { name },
intl,
fetchData,
username,
email,
handleOnPurchaseFailure,
handleOnPurchaseSuccess,
} = this.props;
const { intl, handleOnPurchaseFailure } = this.props;
bugsnagInstance.notify(error);
if (get(error, 'responseCode') === '3' && Platform.OS === 'android') {
@ -336,7 +327,7 @@ class InAppPurchaseContainer extends Component {
},
{
text: intl.formatMessage({ id: 'alert.confirm' }),
onPress: async () => await this._buyItem(productId),
onPress: async () => this._buyItem(productId),
},
],
headerContent: <UserAvatar username={username} size="xl" />,

View File

@ -119,7 +119,8 @@ class TransferContainer extends Component {
balance = tokenBalance.stake;
break;
default:
balance = tokenBalance.balance;
const { balance: _balance } = tokenBalance;
balance = _balance;
break;
}
}
@ -318,7 +319,7 @@ class TransferContainer extends Component {
}
if (!currentAccount.local) {
const realmData = await getUserDataWithUsername(currentAccount.name);
currentAccount.local = realmData[0];
[currentAccount.local] = realmData;
}
return func(currentAccount, pinCode, data)

View File

@ -3,7 +3,7 @@ import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import ROUTES from '../constants/routeNames';
import { BottomTabBar } from '../components';
import { Feed, Notification, Profile, Wallet } from '../screens';
import { Feed, Notification, Wallet } from '../screens';
import Waves from '../screens/waves';
const Tab = createBottomTabNavigator();

View File

@ -1,13 +1,6 @@
import { ASSET_IDS } from '../../constants/defaultAssets';
import { Referral } from '../../models';
import {
CommentHistoryItem,
LatestMarketPrices,
LatestQuotes,
QuoteItem,
ReferralStat,
Draft,
} from './ecency.types';
import { CommentHistoryItem, LatestQuotes, QuoteItem, ReferralStat, Draft } from './ecency.types';
export const convertReferral = (rawData: any) => {
return {

View File

@ -119,7 +119,7 @@ export const deleteDraft = async (draftId: string) => {
/**
* @param draft
*/
export const addDraft = async (draft: Object) => {
export const addDraft = async (draft: any) => {
const { title, body, tags, meta } = draft;
try {
const newDraft = { title, body, tags, meta };
@ -151,7 +151,7 @@ export const updateDraft = async (
title: string,
body: string,
tags: string,
meta: Object,
meta: any,
) => {
try {
const data = { id: draftId, title, body, tags, meta };

View File

@ -49,7 +49,7 @@ export interface Draft {
body: string;
tags_arr: string[];
tags: string;
meta: Object;
meta: any;
modified: string;
created: string;
timestamp: number;

View File

@ -57,7 +57,7 @@ export const fetchTokenBalances = (account: string): Promise<TokenBalance[]> =>
return ecencyApi
.post(PATH_ENGINE_CONTRACTS, data)
.then((r) => r.data.result)
.catch((e) => {
.catch(() => {
return [];
});
};
@ -79,7 +79,7 @@ export const fetchTokens = (tokens: string[]): Promise<Token[]> => {
return ecencyApi
.post(PATH_ENGINE_CONTRACTS, data)
.then((r) => r.data.result)
.catch((e) => {
.catch(() => {
return [];
});
};

View File

@ -140,7 +140,9 @@ export const broadcastPostingJSON = async (id, json, currentAccount, pinHash) =>
accessToken: token,
});
return api.customJson([], [username], id, JSON.stringify(json)).then((r) => r.result);
return api
.customJson([], [currentAccount.username], id, JSON.stringify(json))
.then((r) => r.result);
}
if (key) {

View File

@ -88,7 +88,7 @@ export const useMediaUploadMutation = () => {
async ({ media }) => {
console.log('uploading media', media);
const sign = await signImage(media, currentAccount, pinCode);
return await uploadImage(media, currentAccount.name, sign);
return uploadImage(media, currentAccount.name, sign);
},
{
retry: 3,

View File

@ -5,12 +5,8 @@ import QUERIES from '../queryKeys';
/** hook used to return user drafts */
export const useGetLeaderboardQuery = (duration: 'day' | 'week' | 'month') => {
const _getLeaderboard = async () => {
try {
const data = await getLeaderboard(duration);
return data || [];
} catch (err) {
throw err;
}
const data = await getLeaderboard(duration);
return data || [];
};
return useQuery([QUERIES.LEADERBOARD.GET, duration], _getLeaderboard);

View File

@ -168,24 +168,17 @@ export const useDiscussionQuery = (_author?: string, _permlink?: string) => {
return replies;
};
for (const key in commentsMap) {
if (commentsMap.hasOwnProperty(key)) {
const comment = commentsMap[key];
Object.keys(commentsMap).forEach((key) => {
const comment = commentsMap[key];
// prcoess first level comment
if (comment && comment.parent_author === author && comment.parent_permlink === permlink) {
comment.commentKey = key;
comment.level = 1;
comment.repliesThread = parseReplies(
commentsMap,
comment.replies,
key,
comment.level + 1,
);
comments.push(comment);
}
// prcoess first level comment
if (comment && comment.parent_author === author && comment.parent_permlink === permlink) {
comment.commentKey = key;
comment.level = 1;
comment.repliesThread = parseReplies(commentsMap, comment.replies, key, comment.level + 1);
comments.push(comment);
}
}
});
setSectionedData(comments);
};

View File

@ -55,7 +55,7 @@ export const useUnclaimedRewardsQuery = () => {
const _processCachedData = (rewardsCollection: RewardsCollection) => {
if (claimsCollection) {
const _curTime = new Date().getTime();
for (const key in claimsCollection) {
Object.keys(claimsCollection).forEach((key) => {
const _claimCache = claimsCollection[key];
const _rewardValue = rewardsCollection[key];
if (
@ -67,7 +67,7 @@ export const useUnclaimedRewardsQuery = () => {
) {
delete rewardsCollection[key];
}
}
});
}
return rewardsCollection;
@ -239,11 +239,11 @@ export const useClaimRewardsMutation = () => {
return isClaimingColl[assetId] || false;
}
for (const key in isClaimingColl) {
Object.keys(isClaimingColl).forEach((key) => {
if (isClaimingColl[key] === true) {
return true;
}
}
});
return false;
};

View File

@ -42,7 +42,7 @@ const initialState: AccountState = {
globalProps: null,
};
export default function (state = initialState, action) {
const accountReducer = (state = initialState, action) => {
switch (action.type) {
case FETCHING_ACCOUNT:
return {
@ -134,4 +134,6 @@ export default function (state = initialState, action) {
default:
return state;
}
}
};
export default accountReducer;

View File

@ -115,7 +115,7 @@ const initialState: State = {
isBiometricEnabled: false,
};
export default function (state = initialState, action): State {
const applicationReducer = (state = initialState, action): State => {
switch (action.type) {
case LOGIN:
return {
@ -302,4 +302,6 @@ export default function (state = initialState, action): State {
default:
return state;
}
}
};
export default applicationReducer;

View File

@ -111,7 +111,7 @@ const initialState: State = {
lastUpdate: null,
};
export default function (state = initialState, action) {
const cacheReducer = (state = initialState, action) => {
const { type, payload } = action;
switch (type) {
case UPDATE_VOTE_CACHE:
@ -252,47 +252,39 @@ export default function (state = initialState, action) {
const currentTime = new Date().getTime();
if (state.votesCollection) {
for (const key in state.votesCollection) {
if (state.votesCollection.hasOwnProperty(key)) {
const vote = state.votesCollection[key];
if (vote && (vote?.expiresAt || 0) < currentTime) {
delete state.votesCollection[key];
}
Object.keys(state.votesCollection).forEach((key) => {
const vote = state.votesCollection[key];
if (vote && (vote?.expiresAt || 0) < currentTime) {
delete state.votesCollection[key];
}
}
});
}
if (state.commentsCollection) {
for (const key in state.commentsCollection) {
if (state.commentsCollection.hasOwnProperty(key)) {
const comment = state.commentsCollection[key];
if (comment && (comment?.expiresAt || 0) < currentTime) {
delete state.commentsCollection[key];
}
Object.keys(state.commentsCollection).forEach((key) => {
const comment = state.commentsCollection[key];
if (comment && (comment?.expiresAt || 0) < currentTime) {
delete state.commentsCollection[key];
}
}
});
}
if (state.draftsCollection) {
for (const key in state.draftsCollection) {
if (state.draftsCollection.hasOwnProperty(key)) {
const draft = state.draftsCollection[key];
if (draft && ((draft?.expiresAt || 0) < currentTime || !draft.body)) {
delete state.draftsCollection[key];
}
Object.keys(state.draftsCollection).forEach((key) => {
const draft = state.draftsCollection[key];
if (draft && ((draft?.expiresAt || 0) < currentTime || !draft.body)) {
delete state.draftsCollection[key];
}
}
});
}
if (state.claimsCollection) {
for (const key in state.claimsCollection) {
if (state.claimsCollection.hasOwnProperty(key)) {
const claim = state.claimsCollection[key];
if (claim && (claim?.expiresAt || 0) < currentTime) {
delete state.claimsCollection[key];
}
Object.keys(state.claimsCollection).forEach((key) => {
const claim = state.claimsCollection[key];
if (claim && (claim?.expiresAt || 0) < currentTime) {
delete state.claimsCollection[key];
}
}
});
}
if (state.subscribedCommunities && state.subscribedCommunities.size) {
@ -309,4 +301,6 @@ export default function (state = initialState, action) {
default:
return state;
}
}
};
export default cacheReducer;

View File

@ -56,7 +56,7 @@ const initialState = {
},
};
export default function (state = initialState, action) {
const communitiesReducer = (state = initialState, action) => {
switch (action.type) {
case FETCH_COMMUNITIES:
return {
@ -460,4 +460,6 @@ export default function (state = initialState, action) {
default:
return state;
}
}
};
export default communitiesReducer;

View File

@ -25,7 +25,7 @@ const initialState: State = {
ownProfileTabs: DEFAULT_OWN_PROFILE_FILTERS,
};
export default function (state: State = initialState, action): State {
const customTabsReducer = (state: State = initialState, action): State => {
switch (action.type) {
case SET_MAIN_TABS:
return {
@ -54,4 +54,6 @@ export default function (state: State = initialState, action): State {
default:
return state;
}
}
};
export default customTabsReducer;

View File

@ -17,7 +17,7 @@ const initialState: State = {
beneficiariesMap: {},
};
export default function (state = initialState, action) {
const editorReducer = (state = initialState, action) => {
const { type, payload } = action;
switch (type) {
case SET_BENEFICIARIES:
@ -33,4 +33,6 @@ export default function (state = initialState, action) {
default:
return state;
}
}
};
export default editorReducer;

View File

@ -20,7 +20,7 @@ const initialState = {
feedScreenFilters: DEFAULT_FEED_FILTERS,
};
export default function (state = initialState, action) {
const postsReducer = (state = initialState, action) => {
switch (action.type) {
case SET_FEED_POSTS:
return {
@ -75,4 +75,6 @@ export default function (state = initialState, action) {
default:
return state;
}
}
};
export default postsReducer;

View File

@ -63,7 +63,7 @@ const initialState: UiState = {
isLogingOut: false,
};
export default function (state = initialState, action): UiState {
const uiReducer = (state = initialState, action): UiState => {
switch (action.type) {
case UPDATE_ACTIVE_BOTTOM_TAB:
return {
@ -179,4 +179,6 @@ export default function (state = initialState, action): UiState {
default:
return state;
}
}
};
export default uiReducer;

View File

@ -25,7 +25,7 @@ const initialState = {
},
};
export default function (state = initialState, action) {
const userReducer = (state = initialState, action) => {
switch (action.type) {
case FOLLOW_USER:
return {
@ -129,4 +129,6 @@ export default function (state = initialState, action) {
default:
return state;
}
}
};
export default userReducer;

View File

@ -11,7 +11,7 @@ interface State {
const initialState: State = {
walkthroughMap: new Map(),
};
export default function (state = initialState, action) {
const walkthroughReducer = (state = initialState, action) => {
// console.log('action : ', action);
const { type, payload } = action;
@ -28,4 +28,6 @@ export default function (state = initialState, action) {
default:
return state;
}
}
};
export default walkthroughReducer;

View File

@ -95,7 +95,7 @@ const initialState: State = {
updateTimestamp: 0,
};
export default function (state = initialState, action) {
const walletReducer = (state = initialState, action) => {
const { type, payload } = action;
switch (type) {
case RESET_WALLET_DATA: {
@ -148,7 +148,9 @@ export default function (state = initialState, action) {
default:
return state;
}
}
};
export default walletReducer;
const ONE_HOUR_MS = 60 * 60 * 1000;
const TEN_MIN_MS = 60 * 10 * 1000;

View File

@ -2,7 +2,7 @@ import { createStore, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';
import { createMigrate, createTransform, persistReducer, persistStore } from 'redux-persist';
import AsyncStorage from '@react-native-community/async-storage';
import AsyncStorage from '@react-native-async-storage/async-storage';
import Reactotron from '../../../reactotron-config';
import reducers from '../reducers';

View File

@ -3,7 +3,7 @@ import { View } from 'react-native';
import { RangeSelector } from '.';
import { SimpleChart } from '../../../components';
import { useAppSelector } from '../../../hooks';
import { ChartInterval, fetchMarketChart } from '../../../providers/coingecko/coingecko';
import { fetchMarketChart } from '../../../providers/coingecko/coingecko';
import { fetchEngineMarketData } from '../../../providers/hive-engine/hiveEngine';
import getWindowDimensions from '../../../utils/getWindowDimensions';
import styles, { CHART_NEGATIVE_MARGIN } from './children.styles';

View File

@ -25,6 +25,7 @@ interface DelegationItem {
timestamp: string;
}
// eslint-disable-next-line no-empty-pattern
export const DelegationsModal = forwardRef(({}, ref) => {
const intl = useIntl();
const navigation = useNavigation<StackNavigationProp<any>>();

View File

@ -15,7 +15,6 @@ import { DelegationsModal, MODES } from '../children/delegationsModal';
import TransferTypes from '../../../constants/transferTypes';
import { walletQueries } from '../../../providers/queries';
import parseToken from '../../../utils/parseToken';
import { log } from '../../../../reactotron-config';
export interface AssetDetailsScreenParams {
coinId: string;

View File

@ -55,8 +55,8 @@ const AssetsSelect = ({ navigation }) => {
useEffect(() => {
const data: CoinData[] = [];
for (const key in coinsData) {
if (coinsData.hasOwnProperty(key) && (coinsData[key].isEngine || coinsData[key].isSpk)) {
Object.keys(coinsData).forEach((key) => {
if (coinsData[key].isEngine || coinsData[key].isSpk) {
const asset: CoinData = coinsData[key];
const _name = asset.name.toLowerCase();
const _symbol = asset.symbol.toLowerCase();
@ -69,7 +69,7 @@ const AssetsSelect = ({ navigation }) => {
data.push(asset);
}
}
}
});
setListData(data);
_updateSortedList({ data });

View File

@ -14,6 +14,7 @@ import { getUpdatedUserKeys } from '../../providers/hive/auth';
import { getDigitPinCode } from '../../providers/hive/dhive';
import { updateCurrentAccount } from '../../redux/actions/accountAction';
// eslint-disable-next-line no-empty-pattern
export const ImportPrivateKeyModalModal = forwardRef(({}, ref) => {
const intl = useIntl();
const dispatch = useDispatch();

View File

@ -16,7 +16,7 @@ export default (raw: CommentHistoryItem[]) => {
for (let l = 0; l < raw.length; l += 1) {
if (raw[l].body.startsWith('@@')) {
const p = dmp.patch_fromText(raw[l].body);
h = dmp.patch_apply(p, h)[0];
[h] = dmp.patch_apply(p, h);
raw[l].body = h;
} else {
h = raw[l].body;

View File

@ -105,10 +105,11 @@ class EditorContainer extends Component<EditorContainerProps, any> {
if (route.params) {
const navigationParams = route.params;
hasSharedIntent = navigationParams.hasSharedIntent;
const { hasSharedIntent: _hasShared, draftId: _draftId } = navigationParams;
hasSharedIntent = _hasShared;
if (navigationParams.draftId) {
draftId = navigationParams.draftId;
if (_draftId) {
draftId = _draftId;
const cachedDrafts: any = queryClient.getQueryData([QUERIES.DRAFTS.GET]);
if (cachedDrafts && cachedDrafts.length) {

View File

@ -72,13 +72,6 @@ class EditorScreen extends Component {
}
}
componentWillUnmount() {
const { isEdit } = this.props;
if (!isEdit) {
this._saveDraftToDB();
}
}
componentDidUpdate(prevProps, prevState) {
const { isUploadingProp, communityProp } = this.state;
if (prevState.isUploadingProp !== isUploadingProp) {
@ -91,6 +84,13 @@ class EditorScreen extends Component {
}
}
componentWillUnmount() {
const { isEdit } = this.props;
if (!isEdit) {
this._saveDraftToDB();
}
}
static getDerivedStateFromProps(nextProps, prevState) {
// shoudl update state
const stateUpdate: any = {};