From 075ee0c30c05221b256a6cc5ce5002ff7696fa52 Mon Sep 17 00:00:00 2001 From: koalasat Date: Mon, 25 Nov 2024 10:38:33 +0100 Subject: [PATCH] Lint --- .pre-commit-config.yaml | 18 ++++++++++++++++++ frontend/src/basic/MakerPage/index.tsx | 2 +- .../src/components/BookTable/BookControl.tsx | 1 - .../src/components/Charts/DepthChart/index.tsx | 8 ++++---- frontend/src/components/Dialogs/Exchange.tsx | 9 ++++++++- .../src/components/MakerForm/MakerForm.tsx | 7 ++++++- .../components/MakerForm/SelectCoordinator.tsx | 2 +- frontend/src/utils/filterOrders.ts | 6 +++--- 8 files changed, 41 insertions(+), 12 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7b21d5f1..2a513317 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -38,6 +38,15 @@ repos: files: ^frontend/ types_or: [javascript, jsx, ts, tsx, css, markdown, json] # uses https://github.com/pre-commit/identify entry: bash -c 'cd frontend && npm run format' + - id: lintern-frontend + name: lintern-frontend + stages: + - commit + - merge-commit + language: system + files: ^frontend/ + types_or: [javascript, jsx, ts, tsx, css, markdown, json] # uses https://github.com/pre-commit/identify + entry: bash -c 'cd frontend && npm run lint' - id: prettier-mobile name: prettier-mobile stages: @@ -47,6 +56,15 @@ repos: files: ^mobile/ types_or: [javascript, jsx, ts, tsx, css, markdown, json] # uses https://github.com/pre-commit/identify entry: bash -c 'cd mobile && npm run format' + - id: lintern-mobile + name: lintern-mobile + stages: + - commit + - merge-commit + language: system + files: ^mobile/ + types_or: [javascript, jsx, ts, tsx, css, markdown, json] # uses https://github.com/pre-commit/identify + entry: bash -c 'cd frontend && npm run lint' - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.1.13 hooks: diff --git a/frontend/src/basic/MakerPage/index.tsx b/frontend/src/basic/MakerPage/index.tsx index e77c355f..f2afc39e 100644 --- a/frontend/src/basic/MakerPage/index.tsx +++ b/frontend/src/basic/MakerPage/index.tsx @@ -12,7 +12,7 @@ import { NoRobotDialog } from '../../components/Dialogs'; import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext'; import { GarageContext, type UseGarageStoreType } from '../../contexts/GarageContext'; import VisitThirdParty from '../../components/Dialogs/VisitThirdParty'; -import { PublicOrder } from '../../models'; +import { type PublicOrder } from '../../models'; const MakerPage = (): JSX.Element => { const { fav, windowSize, navbarHeight } = useContext(AppContext); diff --git a/frontend/src/components/BookTable/BookControl.tsx b/frontend/src/components/BookTable/BookControl.tsx index afa1d682..a182408b 100644 --- a/frontend/src/components/BookTable/BookControl.tsx +++ b/frontend/src/components/BookTable/BookControl.tsx @@ -22,7 +22,6 @@ import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank'; import SwapCalls from '@mui/icons-material/SwapCalls'; import { FederationContext, type UseFederationStoreType } from '../../contexts/FederationContext'; import RobotAvatar from '../RobotAvatar'; -import RoboSats from '../Icons/RoboSats'; import RoboSatsNoText from '../Icons/RoboSatsNoText'; interface BookControlProps { diff --git a/frontend/src/components/Charts/DepthChart/index.tsx b/frontend/src/components/Charts/DepthChart/index.tsx index db5169e7..7e1ebabe 100644 --- a/frontend/src/components/Charts/DepthChart/index.tsx +++ b/frontend/src/components/Charts/DepthChart/index.tsx @@ -129,13 +129,13 @@ const DepthChart: React.FC = ({ xType === 'base_price' ? enrichedOrders .filter( - (order: PublicOrder | null) => currencyCode === 0 || order?.currency == currencyCode, + (order: PublicOrder | null) => currencyCode === 0 || order?.currency === currencyCode, ) .filter( (order: PublicOrder | null) => coordinatorFilter === 'any' || (coordinatorFilter === 'robosats' && order?.federated) || - order?.coordinatorShortAlias == coordinatorFilter, + order?.coordinatorShortAlias === coordinatorFilter, ) .sort( (order1: PublicOrder | null, order2: PublicOrder | null) => @@ -143,13 +143,13 @@ const DepthChart: React.FC = ({ ) : enrichedOrders .filter( - (order: PublicOrder | null) => currencyCode === 0 || order?.currency == currencyCode, + (order: PublicOrder | null) => currencyCode === 0 || order?.currency === currencyCode, ) .filter( (order: PublicOrder | null) => coordinatorFilter === 'any' || (coordinatorFilter === 'robosats' && order?.federated) || - order?.coordinatorShortAlias == coordinatorFilter, + order?.coordinatorShortAlias === coordinatorFilter, ) .sort( (order1: PublicOrder | null, order2: PublicOrder | null) => diff --git a/frontend/src/components/Dialogs/Exchange.tsx b/frontend/src/components/Dialogs/Exchange.tsx index 32669465..5c491104 100644 --- a/frontend/src/components/Dialogs/Exchange.tsx +++ b/frontend/src/components/Dialogs/Exchange.tsx @@ -38,7 +38,14 @@ const ExchangeDialog = ({ open = false, onClose }: Props): JSX.Element => { const [loadingInfo, setLoadingInfo] = useState(true); useEffect(() => { - if (open) federation.loadInfo(); + if (open) { + federation + .loadInfo() + .then(() => {}) + .catch((error) => { + console.error('Error loading info:', error); + }); + } }, [open]); useEffect(() => { diff --git a/frontend/src/components/MakerForm/MakerForm.tsx b/frontend/src/components/MakerForm/MakerForm.tsx index e0dc2f15..3a4c2231 100644 --- a/frontend/src/components/MakerForm/MakerForm.tsx +++ b/frontend/src/components/MakerForm/MakerForm.tsx @@ -87,7 +87,12 @@ const MakerForm = ({ const amountSafeThresholds = [1.03, 0.98]; useEffect(() => { - federation.loadInfo(); + federation + .loadInfo() + .then(() => {}) + .catch((error) => { + console.error('Error loading info:', error); + }); }, []); useEffect(() => { diff --git a/frontend/src/components/MakerForm/SelectCoordinator.tsx b/frontend/src/components/MakerForm/SelectCoordinator.tsx index fe7208bc..6c869cd3 100644 --- a/frontend/src/components/MakerForm/SelectCoordinator.tsx +++ b/frontend/src/components/MakerForm/SelectCoordinator.tsx @@ -10,7 +10,7 @@ import { CircularProgress, Stack, } from '@mui/material'; -import { Bolt, Link, Info } from '@mui/icons-material'; +import { Link } from '@mui/icons-material'; import RobotAvatar from '../RobotAvatar'; import { AppContext, type UseAppStoreType } from '../../contexts/AppContext'; import { useTheme } from '@emotion/react'; diff --git a/frontend/src/utils/filterOrders.ts b/frontend/src/utils/filterOrders.ts index dab9cace..1a51de68 100644 --- a/frontend/src/utils/filterOrders.ts +++ b/frontend/src/utils/filterOrders.ts @@ -1,4 +1,4 @@ -import { type PublicOrder, type Favorites, type Federation, Coordinator } from '../models'; +import { type PublicOrder, type Favorites, type Federation } from '../models'; import thirdParties from '../../static/thirdparties.json'; interface AmountFilter { @@ -35,7 +35,7 @@ const filterByHost = function ( ): boolean { if (shortAlias === 'any') { return true; - } else if (shortAlias == 'robosats') { + } else if (shortAlias === 'robosats') { const coordinator = federation.getCoordinator(order.coordinatorShortAlias ?? ''); return coordinator?.federated ?? false; } else { @@ -84,7 +84,7 @@ const filterOrders = function ({ const coordinatorCheck = [...enabledCoordinators, ...Object.keys(thirdParties)].includes( order.coordinatorShortAlias ?? '', ); - const typeChecks = order.type === baseFilter.type || baseFilter.type == null; + const typeChecks = order.type === baseFilter.type || baseFilter.type === null; const modeChecks = baseFilter.mode === 'fiat' ? !(order.currency === 1000) : true; const premiumChecks = premium !== null ? filterByPremium(order, premium) : true; const currencyChecks = order.currency === baseFilter.currency || baseFilter.currency === 0;