From 9b73711dc69009ac541716396a7a722e5bb8ee55 Mon Sep 17 00:00:00 2001 From: QueenGiba Date: Sat, 17 Oct 2026 04:38:21 +0100 Subject: [PATCH] fix: resolve lint errors blocking CI and add missing test script - #824: Fix import order in TVChartContainer, DepthLadder, ConfirmationDialog. External/builtin imports precede internal/relative imports; type imports follow value imports. Remove unnecessary nullish coalescing in DepthLadder (line 222) and ConfirmationDialog (lines 135-136). Remove unnecessary type assertion in useSourceFreshness.test.ts (line 152). - #823: Add `test` and `test:coverage` scripts to apps/web/package.json so that turbo test and CI properly run the web test suite. Closes #824 Closes #823 --- apps/web/package.json | 4 +++- .../trade/components/chart/TVChartContainer.tsx | 6 +++--- .../trade/components/orderbook/DepthLadder.tsx | 12 +++++++----- .../components/trade-panel/ConfirmationDialog.tsx | 6 +++--- .../features/trade/hooks/useSourceFreshness.test.ts | 2 +- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/apps/web/package.json b/apps/web/package.json index 664de9b4..95f8e4a0 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -9,7 +9,9 @@ "preview": "vite preview", "lint": "eslint", "format": "prettier --write \"**/*.{ts,tsx}\"", - "typecheck": "tsc --noEmit" + "typecheck": "tsc --noEmit", + "test": "vitest run", + "test:coverage": "vitest run --coverage" }, "dependencies": { "@creit.tech/stellar-wallets-kit": "^2.4.0", diff --git a/apps/web/src/features/trade/components/chart/TVChartContainer.tsx b/apps/web/src/features/trade/components/chart/TVChartContainer.tsx index 09a8462a..940fc72c 100644 --- a/apps/web/src/features/trade/components/chart/TVChartContainer.tsx +++ b/apps/web/src/features/trade/components/chart/TVChartContainer.tsx @@ -17,17 +17,17 @@ import { useOracleCandles } from "../../hooks/useOracleCandles" import { useLiveBar } from "../../hooks/useLiveBar" import { usePositions } from "../../hooks/usePositions" import { useOrders } from "../../hooks/useOrders" -import { useWalletStore } from "@/features/wallet/store/wallet-store" import { buildCandleOptions, buildChartOptions, getChartPalette, positionLineColor, } from "../../lib/chart-theme" -import type { CandlestickData, IChartApi, IPriceLine, ISeriesApi, UTCTimestamp } from "lightweight-charts" -import type { OhlcBar } from "../../lib/oracle" import { formatUsd } from "@/shared/lib/format" import { ENV } from "@/app/config/env" +import type { CandlestickData, IChartApi, IPriceLine, ISeriesApi, UTCTimestamp } from "lightweight-charts" +import type { OhlcBar } from "../../lib/oracle" +import { useWalletStore } from "@/features/wallet/store/wallet-store" type ChartLine = { id: string diff --git a/apps/web/src/features/trade/components/orderbook/DepthLadder.tsx b/apps/web/src/features/trade/components/orderbook/DepthLadder.tsx index 4b968bc4..5a496334 100644 --- a/apps/web/src/features/trade/components/orderbook/DepthLadder.tsx +++ b/apps/web/src/features/trade/components/orderbook/DepthLadder.tsx @@ -1,9 +1,11 @@ +import { useState } from "react" + import { cn } from "@workspace/ui/lib/utils" -import { useOrderBook } from "../../hooks/useOrderBook" -import type {OrderBookLevel} from "../../hooks/useOrderBook"; import { formatUsd } from "@/shared/lib/format" + +import { useOrderBook } from "../../hooks/useOrderBook" import { useRecentTrades } from "../../hooks/useRecentTrades" -import { useState } from "react" +import type { OrderBookLevel } from "../../hooks/useOrderBook" type Props = { symbol: string | undefined @@ -217,9 +219,9 @@ export function DepthLadder({ symbol, compact = false }: Props) { const { trades } = useRecentTrades(symbol) // OB-054: Determine reference price — prefer last trade, fall back to mid price - const lastTradePrice = trades[0]?.price ?? null + const lastTradePrice = trades[0]?.price const referencePrice = lastTradePrice ?? midPrice - const referencePriceLabel = lastTradePrice !== null ? "Last" : midPrice !== null ? "Mid" : "Mark" + const referencePriceLabel = lastTradePrice ? "Last" : midPrice ? "Mid" : "Mark" // OB-056: Cumulative depth inspection state const [hoveredLevel, setHoveredLevel] = useState<{ level: OrderBookLevel; side: "bid" | "ask" } | null>(null) diff --git a/apps/web/src/features/trade/components/trade-panel/ConfirmationDialog.tsx b/apps/web/src/features/trade/components/trade-panel/ConfirmationDialog.tsx index 7444813a..90d5ffb3 100644 --- a/apps/web/src/features/trade/components/trade-panel/ConfirmationDialog.tsx +++ b/apps/web/src/features/trade/components/trade-panel/ConfirmationDialog.tsx @@ -1,4 +1,4 @@ -import { useEffect, useMemo, useState, useRef } from "react" +import { useEffect, useMemo, useRef, useState } from "react" import { Dialog, DialogContent, @@ -132,8 +132,8 @@ export function ConfirmationDialog({ sizeUsd, entryPrice, leverage, - triggerPrice: triggerPrice ?? "", - collateralAmount: fromAmount ?? "", + triggerPrice, + collateralAmount: fromAmount, } if (!inputSnapshotRef.current) { diff --git a/apps/web/src/features/trade/hooks/useSourceFreshness.test.ts b/apps/web/src/features/trade/hooks/useSourceFreshness.test.ts index 80a6e7b6..d5a258f8 100644 --- a/apps/web/src/features/trade/hooks/useSourceFreshness.test.ts +++ b/apps/web/src/features/trade/hooks/useSourceFreshness.test.ts @@ -149,7 +149,7 @@ describe("useSourceFreshness", () => { const { result, rerender } = renderHook( ({ symbol }: { symbol: string | undefined }) => useSourceFreshness(symbol), { - initialProps: { symbol: "BTC" as string | undefined }, + initialProps: { symbol: "BTC" }, }, ) expect(result.current).not.toBeNull()