From fdee83959451636c61aee799399d5a7579750da3 Mon Sep 17 00:00:00 2001 From: Amin <26092352+aminamos@users.noreply.github.com> Date: Sun, 13 Sep 2026 19:57:16 -0500 Subject: [PATCH] feat: enable typescript-eslint no-unsafe rules and resolve type issues (#161) --- eslint.config.mjs | 12 ++++++------ .../components/ErrorDetailsDialog.tsx | 4 ++-- src/app/services/api-auth-middleware.ts | 2 +- src/app/services/profile-service.ts | 2 +- src/app/types.ts | 6 +++--- src/app/utils/precompute.ts | 14 ++++++-------- 6 files changed, 19 insertions(+), 21 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index aa94178c..4756059c 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -55,12 +55,12 @@ export default tseslint.config( // Type-checked rules from recommendedTypeChecked that are too noisy // for the current codebase — kept off to preserve parity with the // previous eslint-config-standard-with-typescript baseline. - '@typescript-eslint/no-unsafe-assignment': 'off', - '@typescript-eslint/no-unsafe-member-access': 'off', - '@typescript-eslint/no-unsafe-argument': 'off', - '@typescript-eslint/no-unsafe-call': 'off', - '@typescript-eslint/no-unsafe-return': 'off', - '@typescript-eslint/no-unsafe-enum-comparison': 'off', + '@typescript-eslint/no-unsafe-assignment': 'warn', + '@typescript-eslint/no-unsafe-member-access': 'warn', + '@typescript-eslint/no-unsafe-argument': 'warn', + '@typescript-eslint/no-unsafe-call': 'warn', + '@typescript-eslint/no-unsafe-return': 'warn', + '@typescript-eslint/no-unsafe-enum-comparison': 'warn', '@typescript-eslint/no-unnecessary-type-assertion': 'off', '@typescript-eslint/no-redundant-type-constituents': 'off', '@typescript-eslint/require-await': 'off', diff --git a/src/app/screens/GbfsValidator/components/ErrorDetailsDialog.tsx b/src/app/screens/GbfsValidator/components/ErrorDetailsDialog.tsx index e045892e..de866a11 100644 --- a/src/app/screens/GbfsValidator/components/ErrorDetailsDialog.tsx +++ b/src/app/screens/GbfsValidator/components/ErrorDetailsDialog.tsx @@ -431,7 +431,7 @@ export function ErrorDetailsDialog({ )} {renderHighlightedObject( - parentContextData as JSONValue, + parentContextData, null, null, )} @@ -439,7 +439,7 @@ export function ErrorDetailsDialog({ ); } return renderHighlightedObject( - parentContextData as JSONValue, + parentContextData, lastPointerSegment ?? null, lastArrayIndex, ); diff --git a/src/app/services/api-auth-middleware.ts b/src/app/services/api-auth-middleware.ts index d83ba77b..1f30c393 100644 --- a/src/app/services/api-auth-middleware.ts +++ b/src/app/services/api-auth-middleware.ts @@ -25,7 +25,7 @@ export const generateAuthMiddlewareWithToken = ( userContextJwt?: string, ): Middleware => { return { - async onRequest(req) { + onRequest(req) { // Always attach the bearer token for IAP/GCIP. req.headers.set('Authorization', `Bearer ${accessToken}`); diff --git a/src/app/services/profile-service.ts b/src/app/services/profile-service.ts index ef6158fc..02503abc 100644 --- a/src/app/services/profile-service.ts +++ b/src/app/services/profile-service.ts @@ -22,7 +22,7 @@ export const sendEmailVerification = async (): Promise => { /** * Return the current user or null if the user is not logged in. */ -export const getUserFromSession = async (): Promise => { +export const getUserFromSession = (): User | null => { const currentUser = app.auth().currentUser; if (currentUser === null) { return null; diff --git a/src/app/types.ts b/src/app/types.ts index 43898e54..9da1d6cb 100644 --- a/src/app/types.ts +++ b/src/app/types.ts @@ -80,19 +80,19 @@ export enum LicenseErrorSource { } export interface ProfileError { - code: string | 'unknown'; + code: string; message: string; source?: ProfileErrorSource; } export interface FeedError { - code: string | 'unknown'; + code: string; message: string; source?: FeedErrorSource; } export interface LicenseError { - code: string | 'unknown'; + code: string; message: string; source?: LicenseErrorSource; } diff --git a/src/app/utils/precompute.ts b/src/app/utils/precompute.ts index 62bce45e..acd390cd 100644 --- a/src/app/utils/precompute.ts +++ b/src/app/utils/precompute.ts @@ -41,14 +41,12 @@ export interface PrecomputeDeps { } /** Small helper: wait once for a map event */ -async function once(map: maplibregl.Map, ev: string): Promise { - await new Promise( - // eslint-disable-next-line no-async-promise-executor - async (resolve) => - await map.once(ev, () => { - resolve(); - }), - ); +function once(map: maplibregl.Map, ev: string): Promise { + return new Promise((resolve) => { + map.once(ev, () => { + resolve(); + }); + }); } // Extend helpers for [minLng,minLat,maxLng,maxLat]