From 5b461beff6394f9ae8095494342f4c688397e82b Mon Sep 17 00:00:00 2001 From: thisyahlen <104053934+thisyahlen-deriv@users.noreply.github.com> Date: Fri, 29 Sep 2023 15:22:15 +0800 Subject: [PATCH] Thisyahlen/updated eslint wallets (#10388) * chore: fix ci * chore: add new eslint rule for typescript and enabled switch account for mobile * chore: update eslint --- packages/wallets/.eslintrc.js | 6 ++++-- .../components/MT5AccountTypeModal/MT5AccountTypeModal.tsx | 4 ++-- .../WalletsCarouselContent/WalletsCarouselContent.tsx | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/wallets/.eslintrc.js b/packages/wallets/.eslintrc.js index 567a708bc232..1ea8a3586f11 100644 --- a/packages/wallets/.eslintrc.js +++ b/packages/wallets/.eslintrc.js @@ -5,6 +5,7 @@ module.exports = { env: { es6: true }, plugins: ['eslint-plugin-local-rules', 'simple-import-sort', 'sort-destructure-keys', 'typescript-sort-keys'], rules: { + camelcase: 'error', 'simple-import-sort/imports': [ 'error', { @@ -36,12 +37,15 @@ module.exports = { '@typescript-eslint/array-type': 'error', '@typescript-eslint/no-unused-vars': 'error', '@typescript-eslint/sort-type-constituents': 'error', + '@typescript-eslint/no-explicit-any': 'error', 'import/first': 'error', 'import/newline-after-import': 'error', 'import/no-duplicates': 'error', + 'import/no-extraneous-dependencies': ['off', { devDependencies: ['**/*.spec.*', '**/*.test.*', '**/*.d.ts*'] }], 'lines-around-comment': ['error', { allowObjectStart: true }], 'local-rules/no-react-namespace': 'error', 'no-unneeded-ternary': 'error', + 'no-useless-return': 'error', 'object-shorthand': 'error', 'prefer-const': 'error', 'react/jsx-pascal-case': 'error', @@ -51,8 +55,6 @@ module.exports = { 'sort-keys': 'warn', 'typescript-sort-keys/interface': 'warn', 'typescript-sort-keys/string-enum': 'warn', - camelcase: 'error', - 'import/no-extraneous-dependencies': ['off', { devDependencies: ['**/*.spec.*', '**/*.test.*', '**/*.d.ts*'] }], }, overrides: [ { diff --git a/packages/wallets/src/components/MT5AccountTypeModal/MT5AccountTypeModal.tsx b/packages/wallets/src/components/MT5AccountTypeModal/MT5AccountTypeModal.tsx index 593037bcc1a3..44e962a094d6 100644 --- a/packages/wallets/src/components/MT5AccountTypeModal/MT5AccountTypeModal.tsx +++ b/packages/wallets/src/components/MT5AccountTypeModal/MT5AccountTypeModal.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useState } from 'react'; import { MT5AccountType } from '../ExternalTradingPlatforms/MT5AccountType'; import { PrimaryActionButton } from '../PrimaryActionButton'; import { WalletModal } from '../WalletModal'; @@ -7,7 +7,7 @@ import { WideWrapper } from '../WideWrapper'; type TMarketTypes = React.ComponentProps['selectedMarketType']; const MT5AccountTypeModal = () => { - const [selectedMarketType, setSelectedMarketType] = React.useState(undefined); + const [selectedMarketType, setSelectedMarketType] = useState(undefined); return ( diff --git a/packages/wallets/src/components/WalletsCarouselContent/WalletsCarouselContent.tsx b/packages/wallets/src/components/WalletsCarouselContent/WalletsCarouselContent.tsx index d669ea85bf26..0e4f829afc81 100644 --- a/packages/wallets/src/components/WalletsCarouselContent/WalletsCarouselContent.tsx +++ b/packages/wallets/src/components/WalletsCarouselContent/WalletsCarouselContent.tsx @@ -28,9 +28,9 @@ const WalletsCarouselContent: React.FC = () => { useEffect(() => { walletsCarouselEmblaApi?.on('settle', () => { - // const scroll_snap_index = walletsCarouselEmblaApi?.selectedScrollSnap(); - // const loginid = wallet_accounts_list[scroll_snap_index]?.loginid; - // switchAccount(loginid); + const scrollSnapIndex = walletsCarouselEmblaApi?.selectedScrollSnap(); + const loginid = walletAccountsList?.[scrollSnapIndex]?.loginid; + switchAccount(loginid || ''); }); walletsCarouselEmblaApi?.on('select', () => {