From ee81bb72b2bdc47bfc32eefff462448be9012aac Mon Sep 17 00:00:00 2001 From: Cameron Clough Date: Wed, 12 Jun 2024 01:04:17 +0100 Subject: [PATCH] fix linting errors --- postcss.config.cjs | 1 + src/api/auth/client.ts | 5 ++-- src/api/derived.ts | 2 +- src/api/index.ts | 3 +- src/api/route.ts | 2 +- src/components/RouteStaticMap.tsx | 2 +- src/components/material/ButtonBase.tsx | 2 +- src/map/config.ts | 3 +- src/pages/auth/auth.tsx | 2 +- src/pages/dashboard/Dashboard.tsx | 2 +- .../dashboard/activities/DeviceActivity.tsx | 2 -- src/pages/dashboard/components/RouteList.tsx | 1 + tailwind.config.cjs => tailwind.config.ts | 28 +++++++++---------- 13 files changed, 29 insertions(+), 26 deletions(-) rename tailwind.config.cjs => tailwind.config.ts (90%) diff --git a/postcss.config.cjs b/postcss.config.cjs index 74892551..245a424e 100644 --- a/postcss.config.cjs +++ b/postcss.config.cjs @@ -1,3 +1,4 @@ +/* eslint-disable */ module.exports = { plugins: { 'tailwindcss/nesting': {}, diff --git a/src/api/auth/client.ts b/src/api/auth/client.ts index 80796ee7..457eaf1b 100644 --- a/src/api/auth/client.ts +++ b/src/api/auth/client.ts @@ -19,14 +19,15 @@ export async function refreshAccessToken( throw new Error(`${resp.status}: ${await resp.text()}`) } - const json = await resp.json() + // TODO: validate response + const json = await resp.json() as Record if (!json.access_token) { throw new Error('unknown error') } setAccessToken(json.access_token) } catch (e) { - throw new Error(`Could not exchange oauth code for access token: ${e}`) + throw new Error('Could not exchange oauth code for access token', { cause: e }) } } diff --git a/src/api/derived.ts b/src/api/derived.ts index bf98579c..0340b476 100644 --- a/src/api/derived.ts +++ b/src/api/derived.ts @@ -43,7 +43,7 @@ type StateDriveEvent = IDriveEvent & { type UserFlagDriveEvent = IDriveEvent & { type: 'user_flag' - data: {} + data: Record } type DriveEvent = EventDriveEvent | StateDriveEvent | UserFlagDriveEvent diff --git a/src/api/index.ts b/src/api/index.ts index b585b62f..c5e8b0a6 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -8,7 +8,8 @@ export async function fetcher(endpoint: string): Promise { }, }) - const json = await res.json() + // TODO: validate responses + const json = await res.json() as T & { error?: string; description?: string } if (json.error) { throw new Error(json.description) } diff --git a/src/api/route.ts b/src/api/route.ts index 70970822..f6658ea3 100644 --- a/src/api/route.ts +++ b/src/api/route.ts @@ -56,7 +56,7 @@ export const createQCameraStreamUrl = ( ): string => `${BASE_URL}/v1/route/${routeName}/qcamera.m3u8?${new URLSearchParams( signature, - )}` + ).toString()}` export const getQCameraStreamUrl = ( routeName: Route['fullname'], diff --git a/src/components/RouteStaticMap.tsx b/src/components/RouteStaticMap.tsx index 56c1c7b1..8bfa23d6 100644 --- a/src/components/RouteStaticMap.tsx +++ b/src/components/RouteStaticMap.tsx @@ -70,7 +70,7 @@ const RouteStaticMap: VoidComponent = (props) => { )} > - + error}> Problem loading map diff --git a/src/components/material/ButtonBase.tsx b/src/components/material/ButtonBase.tsx index be609e08..d47a034c 100644 --- a/src/components/material/ButtonBase.tsx +++ b/src/components/material/ButtonBase.tsx @@ -10,7 +10,7 @@ export type ButtonBaseProps = JSX.HTMLAttributes & { } const ButtonBase: Component = (props) => { - const onClick: JSX.EventHandler = (e: MouseEvent) => { + const onClick: JSX.EventHandler = (e: MouseEvent) => { props.onClick?.(e) } diff --git a/src/map/config.ts b/src/map/config.ts index 3efd2602..1aca32b0 100644 --- a/src/map/config.ts +++ b/src/map/config.ts @@ -3,4 +3,5 @@ export const MAPBOX_USERNAME = 'commaai' export const MAPBOX_LIGHT_STYLE_ID = 'clcl7mnu2000214s2zgcdly6e' export const MAPBOX_DARK_STYLE_ID = 'clcgvbi4f000q15t6o2s8gys3' -export const MAPBOX_TOKEN = import.meta.env.VITE_MAPBOX_TOKEN +// TODO: validate env or throw error +export const MAPBOX_TOKEN = import.meta.env.VITE_MAPBOX_TOKEN as string diff --git a/src/pages/auth/auth.tsx b/src/pages/auth/auth.tsx index 7c14fc0d..7025a248 100644 --- a/src/pages/auth/auth.tsx +++ b/src/pages/auth/auth.tsx @@ -13,7 +13,7 @@ export default function Auth() { const [{ code, provider }] = useSearchParams() if (code && provider) { - refreshAccessToken(code, provider).then(() => { + void refreshAccessToken(code, provider).then(() => { navigate('/') }) } diff --git a/src/pages/dashboard/Dashboard.tsx b/src/pages/dashboard/Dashboard.tsx index 4f9d6e92..36dca7e0 100644 --- a/src/pages/dashboard/Dashboard.tsx +++ b/src/pages/dashboard/Dashboard.tsx @@ -88,7 +88,7 @@ const DashboardLayout: VoidComponent = () => { } > - + diff --git a/src/pages/dashboard/activities/DeviceActivity.tsx b/src/pages/dashboard/activities/DeviceActivity.tsx index 4a098b1d..583547c2 100644 --- a/src/pages/dashboard/activities/DeviceActivity.tsx +++ b/src/pages/dashboard/activities/DeviceActivity.tsx @@ -9,8 +9,6 @@ import Typography from '~/components/material/Typography' import RouteList from '../components/RouteList' import { DashboardContext } from '../Dashboard' import DeviceStatistics from '~/components/DeviceStatistics' -import Card from '~/components/material/Card' -import Surface from '~/components/material/Surface' type DeviceActivityProps = { dongleId: string diff --git a/src/pages/dashboard/components/RouteList.tsx b/src/pages/dashboard/components/RouteList.tsx index 3ac1b00b..fd9474f4 100644 --- a/src/pages/dashboard/components/RouteList.tsx +++ b/src/pages/dashboard/components/RouteList.tsx @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-misused-promises */ import { createEffect, createResource, diff --git a/tailwind.config.cjs b/tailwind.config.ts similarity index 90% rename from tailwind.config.cjs rename to tailwind.config.ts index 14326344..69920035 100644 --- a/tailwind.config.cjs +++ b/tailwind.config.ts @@ -1,7 +1,7 @@ -const defaultTheme = require('tailwindcss/defaultTheme') +import type { Config } from 'tailwindcss' +import * as defaultTheme from 'tailwindcss/defaultTheme' -/** @type {import('tailwindcss').Config} */ -module.exports = { +export default { content: ['./src/**/*.{ts,tsx}', './index.html'], darkMode: ['class', '[data-theme="dark"]'], theme: { @@ -15,12 +15,12 @@ module.exports = { full: '9999px', }, fontWeight: { - light: 300, - regular: 400, - medium: 500, - semibold: 600, - bold: 700, - extrabold: 800, + light: '300', + regular: '400', + medium: '500', + semibold: '600', + bold: '700', + extrabold: '800', }, extend: { colors: Object.fromEntries( @@ -84,7 +84,7 @@ module.exports = { ripple: { '100%': { transform: 'scale(4)', - opacity: 0, + opacity: '0', }, }, shimmer: { @@ -131,15 +131,15 @@ module.exports = { 'circular-dash': { '0%': { strokeDasharray: '1px, 200px', - strokeDashoffset: 0, + strokeDashoffset: '0', }, '50%': { strokeDasharray: '100px, 200px', - strokeDashoffset: -15, + strokeDashoffset: '-15', }, '100%': { strokeDasharray: '100px, 200px', - strokeDashoffset: -125, + strokeDashoffset: '-125', }, }, }, @@ -158,4 +158,4 @@ module.exports = { }, }, }, -} +} satisfies Config