From 90f8401cd6dd469c32577ffb27464074851fc3a9 Mon Sep 17 00:00:00 2001 From: louis Date: Fri, 26 Apr 2024 23:03:38 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A8=20Fix=20eslint=20errors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/Message.ts | 20 +++++++++++++++----- src/api/Ticker.ts | 8 ++++---- src/api/Upload.ts | 2 +- src/api/User.ts | 2 +- src/lib/leafletFitBoundsHelper.ts | 5 ++--- 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/api/Message.ts b/src/api/Message.ts index dfc5ea97..3d44f090 100644 --- a/src/api/Message.ts +++ b/src/api/Message.ts @@ -1,4 +1,5 @@ import { ApiUrl, Response } from './Api' +import { FeatureCollection, Geometry } from 'geojson' interface MessagesResponseData { messages: Array @@ -16,8 +17,12 @@ export interface Message { telegramUrl?: string mastodonUrl?: string geoInformation: string - // TODO - attachments: any[] + attachments?: Attachment[] +} + +export interface Attachment { + url: string + contentType: string } export function useMessageApi(token: string) { @@ -43,8 +48,13 @@ export function useMessageApi(token: string) { }).then(response => response.json()) } - // TODO: any - const postMessage = (ticker: string, text: string, geoInformation: any, attachments: any[]): Promise> => { + const postMessage = ( + ticker: string, + text: string, + // eslint-disable-next-line @typescript-eslint/no-explicit-any + geoInformation: FeatureCollection, + attachments: number[] + ): Promise> => { return fetch(`${ApiUrl}/admin/tickers/${ticker}/messages`, { headers: headers, body: JSON.stringify({ @@ -56,7 +66,7 @@ export function useMessageApi(token: string) { }).then(response => response.json()) } - const deleteMessage = (message: Message): Promise> => { + const deleteMessage = (message: Message): Promise> => { return fetch(`${ApiUrl}/admin/tickers/${message.ticker}/messages/${message.id}`, { headers: headers, method: 'delete', diff --git a/src/api/Ticker.ts b/src/api/Ticker.ts index 690c93a7..e3bb82c6 100644 --- a/src/api/Ticker.ts +++ b/src/api/Ticker.ts @@ -79,7 +79,7 @@ export function useTickerApi(token: string) { 'Content-Type': 'application/json', } - const deleteTicker = (ticker: Ticker): Promise> => { + const deleteTicker = (ticker: Ticker): Promise> => { return fetch(`${ApiUrl}/admin/tickers/${ticker.id}`, { headers: headers, method: 'delete', @@ -92,7 +92,7 @@ export function useTickerApi(token: string) { }).then(response => response.json()) } - const deleteTickerUser = (ticker: Ticker, user: User): Promise> => { + const deleteTickerUser = (ticker: Ticker, user: User): Promise> => { return fetch(`${ApiUrl}/admin/tickers/${ticker.id}/users/${user.id}`, { headers: headers, method: 'delete', @@ -107,7 +107,7 @@ export function useTickerApi(token: string) { return fetch(`${ApiUrl}/admin/tickers/${id}`, { headers: headers }).then(response => response.json()) } - const postTicker = (data: any): Promise> => { + const postTicker = (data: Ticker): Promise> => { return fetch(`${ApiUrl}/admin/tickers`, { headers: headers, body: JSON.stringify(data), @@ -115,7 +115,7 @@ export function useTickerApi(token: string) { }).then(response => response.json()) } - const putTicker = (data: any, id: number): Promise> => { + const putTicker = (data: Ticker, id: number): Promise> => { return fetch(`${ApiUrl}/admin/tickers/${id}`, { headers: headers, body: JSON.stringify(data), diff --git a/src/api/Upload.ts b/src/api/Upload.ts index 610fabfb..319ac20c 100644 --- a/src/api/Upload.ts +++ b/src/api/Upload.ts @@ -18,7 +18,7 @@ export function useUploadApi(token: string) { Authorization: `Bearer ${token}`, } - const postUpload = (formData: any): Promise> => { + const postUpload = (formData: FormData): Promise> => { return fetch(`${ApiUrl}/admin/upload`, { headers: headers, body: formData, diff --git a/src/api/User.ts b/src/api/User.ts index a82bcf09..5a6766ac 100644 --- a/src/api/User.ts +++ b/src/api/User.ts @@ -56,7 +56,7 @@ export function useUserApi(token: string) { }).then(response => response.json()) } - const deleteUser = (user: User): Promise> => { + const deleteUser = (user: User): Promise> => { return fetch(`${ApiUrl}/admin/users/${user.id}`, { headers: headers, method: 'delete', diff --git a/src/lib/leafletFitBoundsHelper.ts b/src/lib/leafletFitBoundsHelper.ts index d66cae3e..24b1e0ec 100644 --- a/src/lib/leafletFitBoundsHelper.ts +++ b/src/lib/leafletFitBoundsHelper.ts @@ -6,11 +6,10 @@ export const leafletOnDataAddFitToBounds = (event: LeafletEvent) => { if ( features.length === 1 && - // type is currently not defined - // @ts-ignore + // @ts-expect-error type is currently not defined features[0].feature.geometry.type === 'Point' ) { - // @ts-ignore + // @ts-expect-error type is currently not defined const coords = features[0].feature.geometry.coordinates leafletLayer._map.setView([coords[1], coords[0]], 13) } else if (features.length > 1) {