From 5839692e520fc5462549ec3dd5a41f043e7bfd25 Mon Sep 17 00:00:00 2001 From: gnezim Date: Wed, 15 Apr 2026 09:51:23 +0300 Subject: [PATCH] Fix lint and typecheck issues in flights-map feature Add explicit undefined to optional properties for exactOptionalPropertyTypes compatibility. Remove unused import. Fix non-null assertions with proper null guards. Remove invalid eslint-disable comment. --- src/features/flights-map/api.test.ts | 1 - .../components/FlightsMapStartPage.tsx | 6 +++--- .../flights-map/components/MapCanvas.tsx | 10 ++++++---- src/features/flights-map/seo.test.ts | 1 + src/features/flights-map/types.ts | 16 ++++++++-------- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/features/flights-map/api.test.ts b/src/features/flights-map/api.test.ts index 05e3ad95..07f44592 100644 --- a/src/features/flights-map/api.test.ts +++ b/src/features/flights-map/api.test.ts @@ -3,7 +3,6 @@ import { ApiClient } from "@/shared/api/client"; import { searchDestinations, getFlightsMapCalendar } from "./api"; import type { FlightsMapSearchParams, - FlightsMapCalendarParams, IDestinationsResponse, IFlightsMapDaysResponse, } from "./types"; diff --git a/src/features/flights-map/components/FlightsMapStartPage.tsx b/src/features/flights-map/components/FlightsMapStartPage.tsx index 63c3c924..d6809a5b 100644 --- a/src/features/flights-map/components/FlightsMapStartPage.tsx +++ b/src/features/flights-map/components/FlightsMapStartPage.tsx @@ -98,11 +98,11 @@ export const FlightsMapStartPage: FC = () => { const handleMarkerClick = useCallback( (markerId: string) => { if (!filterState.departure) { - setFilterState((prev) => ({ ...prev, departure: markerId })); + setFilterState((prev): IFlightsMapFilterState => ({ ...prev, departure: markerId })); } else if (!filterState.arrival && markerId !== filterState.departure) { - setFilterState((prev) => ({ ...prev, arrival: markerId })); + setFilterState((prev): IFlightsMapFilterState => ({ ...prev, arrival: markerId })); } else { - setFilterState((prev) => ({ + setFilterState((prev): IFlightsMapFilterState => ({ ...prev, departure: markerId, arrival: undefined, diff --git a/src/features/flights-map/components/MapCanvas.tsx b/src/features/flights-map/components/MapCanvas.tsx index d88836e9..8e736e4f 100644 --- a/src/features/flights-map/components/MapCanvas.tsx +++ b/src/features/flights-map/components/MapCanvas.tsx @@ -201,8 +201,7 @@ export const MapCanvas: FC = ({ polylinesLayerRef.current = null; popupsLayerRef.current = null; }; - // Only run once on mount - // eslint-disable-next-line react-hooks/exhaustive-deps + // Only run once on mount -- stable props used from refs }, []); // --- Sync markers --- @@ -251,8 +250,11 @@ export const MapCanvas: FC = ({ // Build great-circle arcs between consecutive points const arcPoints: L.LatLng[] = []; for (let i = 0; i < pl.points.length - 1; i++) { - const from = L.latLng(pl.points[i]!.lat, pl.points[i]!.lng); - const to = L.latLng(pl.points[i + 1]!.lat, pl.points[i + 1]!.lng); + const ptFrom = pl.points[i]; + const ptTo = pl.points[i + 1]; + if (!ptFrom || !ptTo) continue; + const from = L.latLng(ptFrom.lat, ptFrom.lng); + const to = L.latLng(ptTo.lat, ptTo.lng); const arc = buildGreatCircleArc(from, to); arcPoints.push(...(i === 0 ? arc : arc.slice(1))); } diff --git a/src/features/flights-map/seo.test.ts b/src/features/flights-map/seo.test.ts index df4a5d68..736ddd95 100644 --- a/src/features/flights-map/seo.test.ts +++ b/src/features/flights-map/seo.test.ts @@ -47,6 +47,7 @@ describe("buildFlightsMapSeo", () => { const result = buildFlightsMapSeo(stubT, "ru", CANONICAL); expect(result.twitter).toBeDefined(); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- test assertion guards above expect(result.twitter!.card).toBe("summary"); }); }); diff --git a/src/features/flights-map/types.ts b/src/features/flights-map/types.ts index 9234bd75..499d4339 100644 --- a/src/features/flights-map/types.ts +++ b/src/features/flights-map/types.ts @@ -16,10 +16,10 @@ */ export interface FlightsMapSearchParams { departure: string; - arrival?: string; + arrival?: string | undefined; dateFrom: string; dateTo: string; - connections?: number; + connections?: number | undefined; } /** @@ -28,7 +28,7 @@ export interface FlightsMapSearchParams { export interface FlightsMapCalendarParams { date: string; departure: string; - arrival?: string; + arrival?: string | undefined; connections: boolean; } @@ -78,8 +78,8 @@ export interface IMapMarker { lat: number; lng: number; style: MarkerStyle; - label?: string; - tooltipPermanent?: boolean; + label?: string | undefined; + tooltipPermanent?: boolean | undefined; } /** @@ -113,9 +113,9 @@ export interface IMapPopup { * State shape for the flights map filter. */ export interface IFlightsMapFilterState { - departure?: string; - arrival?: string; - date?: string; + departure?: string | undefined; + arrival?: string | undefined; + date?: string | undefined; connections: boolean; domestic: boolean; international: boolean;