Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚨 Fix eslint errors #618

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions src/api/Message.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ApiUrl, Response } from './Api'
import { FeatureCollection, Geometry } from 'geojson'

interface MessagesResponseData {
messages: Array<Message>
Expand All @@ -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) {
Expand All @@ -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<Response<MessageResponseData>> => {
const postMessage = (
ticker: string,
text: string,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
geoInformation: FeatureCollection<Geometry, any>,
attachments: number[]
): Promise<Response<MessageResponseData>> => {
return fetch(`${ApiUrl}/admin/tickers/${ticker}/messages`, {
headers: headers,
body: JSON.stringify({
Expand All @@ -56,7 +66,7 @@ export function useMessageApi(token: string) {
}).then(response => response.json())
}

const deleteMessage = (message: Message): Promise<Response<any>> => {
const deleteMessage = (message: Message): Promise<Response<void>> => {
return fetch(`${ApiUrl}/admin/tickers/${message.ticker}/messages/${message.id}`, {
headers: headers,
method: 'delete',
Expand Down
8 changes: 4 additions & 4 deletions src/api/Ticker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export function useTickerApi(token: string) {
'Content-Type': 'application/json',
}

const deleteTicker = (ticker: Ticker): Promise<Response<any>> => {
const deleteTicker = (ticker: Ticker): Promise<Response<void>> => {
return fetch(`${ApiUrl}/admin/tickers/${ticker.id}`, {
headers: headers,
method: 'delete',
Expand All @@ -92,7 +92,7 @@ export function useTickerApi(token: string) {
}).then(response => response.json())
}

const deleteTickerUser = (ticker: Ticker, user: User): Promise<Response<any>> => {
const deleteTickerUser = (ticker: Ticker, user: User): Promise<Response<void>> => {
return fetch(`${ApiUrl}/admin/tickers/${ticker.id}/users/${user.id}`, {
headers: headers,
method: 'delete',
Expand All @@ -107,15 +107,15 @@ export function useTickerApi(token: string) {
return fetch(`${ApiUrl}/admin/tickers/${id}`, { headers: headers }).then(response => response.json())
}

const postTicker = (data: any): Promise<Response<TickerResponseData>> => {
const postTicker = (data: Ticker): Promise<Response<TickerResponseData>> => {
return fetch(`${ApiUrl}/admin/tickers`, {
headers: headers,
body: JSON.stringify(data),
method: 'post',
}).then(response => response.json())
}

const putTicker = (data: any, id: number): Promise<Response<TickerResponseData>> => {
const putTicker = (data: Ticker, id: number): Promise<Response<TickerResponseData>> => {
return fetch(`${ApiUrl}/admin/tickers/${id}`, {
headers: headers,
body: JSON.stringify(data),
Expand Down
2 changes: 1 addition & 1 deletion src/api/Upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function useUploadApi(token: string) {
Authorization: `Bearer ${token}`,
}

const postUpload = (formData: any): Promise<Response<UploadeResponseData>> => {
const postUpload = (formData: FormData): Promise<Response<UploadeResponseData>> => {
return fetch(`${ApiUrl}/admin/upload`, {
headers: headers,
body: formData,
Expand Down
2 changes: 1 addition & 1 deletion src/api/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function useUserApi(token: string) {
}).then(response => response.json())
}

const deleteUser = (user: User): Promise<Response<any>> => {
const deleteUser = (user: User): Promise<Response<void>> => {
return fetch(`${ApiUrl}/admin/users/${user.id}`, {
headers: headers,
method: 'delete',
Expand Down
5 changes: 2 additions & 3 deletions src/lib/leafletFitBoundsHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading