Skip to content

Commit 9d382f3

Browse files
committed
lint fix
1 parent 3d897b2 commit 9d382f3

File tree

13 files changed

+73
-57
lines changed

13 files changed

+73
-57
lines changed

src/app/App.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function App({ locale }: AppProps): React.ReactElement {
2121

2222
// Determine basename for BrowserRouter based on locale
2323
// Non-default locales (e.g., 'fr') need their prefix as basename
24-
const basename = locale && locale !== 'en' ? `/${locale}` : undefined;
24+
const basename = locale != null && locale !== 'en' ? `/${locale}` : undefined;
2525

2626
useEffect(() => {
2727
app.auth().onAuthStateChanged((user) => {
@@ -36,14 +36,14 @@ function App({ locale }: AppProps): React.ReactElement {
3636
}, [dispatch]);
3737

3838
return (
39-
<Suspense>
40-
<LocalizationProvider dateAdapter={AdapterDayjs}>
41-
{/* BrowserRouter will be deprecated in favor of Next AppRouter */}
42-
<BrowserRouter basename={basename}>
43-
<AppContainer>{isAppReady ? <AppRouter /> : null}</AppContainer>
44-
</BrowserRouter>
45-
</LocalizationProvider>
46-
</Suspense>
39+
<Suspense>
40+
<LocalizationProvider dateAdapter={AdapterDayjs}>
41+
{/* BrowserRouter will be deprecated in favor of Next AppRouter */}
42+
<BrowserRouter basename={basename}>
43+
<AppContainer>{isAppReady ? <AppRouter /> : null}</AppContainer>
44+
</BrowserRouter>
45+
</LocalizationProvider>
46+
</Suspense>
4747
);
4848
}
4949

src/app/[locale]/[...slug]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ interface PageProps {
1616

1717
export default function Page({ params }: PageProps): ReactNode {
1818
const { locale } = use(params);
19-
19+
2020
// Pass locale to App so BrowserRouter can use correct basename
2121
return <App locale={locale} />;
2222
}

src/app/[locale]/about/page.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { type ReactElement } from 'react';
22
import { setRequestLocale } from 'next-intl/server';
3-
import { routing } from '../../../i18n/routing';
3+
import { type AVAILABLE_LOCALES, routing } from '../../../i18n/routing';
44
import AboutPage from './components/AboutPage';
55

66
export const dynamic = 'force-static';
77

8-
export function generateStaticParams() {
8+
export function generateStaticParams(): Array<{
9+
locale: (typeof AVAILABLE_LOCALES)[number];
10+
}> {
911
return routing.locales.map((locale) => ({ locale }));
1012
}
1113

src/app/[locale]/layout.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ import { Mulish, IBM_Plex_Mono } from 'next/font/google';
1111
import Footer from '../components/Footer';
1212
import Header from '../components/Header';
1313
import { Container } from '@mui/material';
14-
import { routing } from '../../i18n/routing';
14+
import { type AVAILABLE_LOCALES, routing } from '../../i18n/routing';
1515

1616
export const metadata = {
1717
title: 'Mobility Database',
18-
description: "Access GTFS, GTFS Realtime, GBFS transit data with over 4,000 feeds from 70+ countries on the web's leading transit data platform.",
18+
description:
19+
"Access GTFS, GTFS Realtime, GBFS transit data with over 4,000 feeds from 70+ countries on the web's leading transit data platform.",
1920
robots:
2021
process.env.VERCEL_ENV === 'production'
2122
? 'index, follow'
@@ -46,13 +47,15 @@ const ibmPlexMono = IBM_Plex_Mono({
4647
* Generate static params for all locales.
4748
* This enables static generation for locale-prefixed routes.
4849
*/
49-
export function generateStaticParams() {
50+
export function generateStaticParams(): Array<{
51+
locale: (typeof AVAILABLE_LOCALES)[number];
52+
}> {
5053
return routing.locales.map((locale) => ({ locale }));
5154
}
5255

5356
interface LocaleLayoutProps {
5457
children: React.ReactNode;
55-
params: Promise<{ locale: string }>;
58+
params: Promise<{ locale: (typeof AVAILABLE_LOCALES)[number] }>;
5659
}
5760

5861
/**
@@ -81,8 +84,8 @@ export default async function LocaleLayout({
8184
return (
8285
<html lang={locale}>
8386
<head>
84-
<link rel="preconnect" href="https://firebaseapp.com" />
85-
<link rel="dns-prefetch" href="https://firebaseapp.com" />
87+
<link rel='preconnect' href='https://firebaseapp.com' />
88+
<link rel='dns-prefetch' href='https://firebaseapp.com' />
8689
</head>
8790
<body className={`${mulish.variable} ${ibmPlexMono.variable}`}>
8891
<ThemeRegistry>
@@ -110,4 +113,3 @@ export default async function LocaleLayout({
110113
</html>
111114
);
112115
}
113-

src/app/[locale]/page.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import { type ReactElement } from 'react';
22
import { setRequestLocale } from 'next-intl/server';
3-
import { routing } from '../../i18n/routing';
3+
import { type AVAILABLE_LOCALES, routing } from '../../i18n/routing';
44
import HomePage from './components/HomePage';
55
import { type Metadata } from 'next';
66

77
export const dynamic = 'force-static';
88

9-
export function generateStaticParams() {
9+
export function generateStaticParams(): Array<{
10+
locale: (typeof AVAILABLE_LOCALES)[number];
11+
}> {
1012
return routing.locales.map((locale) => ({ locale }));
1113
}
1214

1315
interface PageProps {
14-
params: Promise<{ locale: string }>;
16+
params: Promise<{ locale: (typeof AVAILABLE_LOCALES)[number] }>;
1517
}
1618

1719
export const metadata: Metadata = {

src/app/components/Context.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
'use client';
22

3-
import React, { useEffect, useState } from 'react';
3+
import React, { useEffect } from 'react';
44
import type ContextProviderProps from '../interface/ContextProviderProps';
55
import { Provider } from 'react-redux';
66
import { store } from '../store/store';
77
import { PersistGate } from 'redux-persist/integration/react';
8-
import { persistStore, type Persistor } from 'redux-persist';
8+
import { persistStore } from 'redux-persist';
99
import { useAppDispatch } from '../hooks';
1010
import { resetProfileErrors } from '../store/profile-reducer';
1111

src/app/components/Header.tsx

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,35 +50,43 @@ import {
5050
} from '../store/profile-selectors';
5151

5252
// Lazy load components not needed for initial render
53-
const LogoutConfirmModal = dynamic(() => import('./LogoutConfirmModal'), {
54-
ssr: false,
55-
});
56-
const DrawerContent = dynamic(() => import('./HeaderMobileDrawer'), {
57-
ssr: false,
58-
});
53+
const LogoutConfirmModal = dynamic(
54+
async () => await import('./LogoutConfirmModal'),
55+
{
56+
ssr: false,
57+
},
58+
);
59+
const DrawerContent = dynamic(
60+
async () => await import('./HeaderMobileDrawer'),
61+
{
62+
ssr: false,
63+
},
64+
);
5965

6066
// Hook to safely access search params only on client
61-
function useClientSearchParams() {
62-
const [searchParams, setSearchParams] = React.useState<URLSearchParams | null>(null);
63-
67+
function useClientSearchParams(): URLSearchParams | null {
68+
const [searchParams, setSearchParams] =
69+
React.useState<URLSearchParams | null>(null);
70+
6471
React.useEffect(() => {
6572
if (typeof window !== 'undefined') {
6673
setSearchParams(new URLSearchParams(window.location.search));
6774
}
6875
}, []);
69-
76+
7077
return searchParams;
7178
}
7279

7380
export default function DrawerAppBar(): React.ReactElement {
7481
const clientSearchParams = useClientSearchParams();
7582
const hasTransitFeedsRedirectParam =
7683
clientSearchParams?.get('utm_source') === 'transitfeeds';
77-
84+
7885
const theme = useTheme();
7986
const pathname = usePathname();
8087
const [mobileOpen, setMobileOpen] = React.useState(false);
81-
const [hasTransitFeedsRedirect, setHasTransitFeedsRedirect] = React.useState(false);
88+
const [hasTransitFeedsRedirect, setHasTransitFeedsRedirect] =
89+
React.useState(false);
8290
const [openDialog, setOpenDialog] = React.useState(false);
8391
const [activeTab, setActiveTab] = React.useState('');
8492
const [navigationItems, setNavigationItems] = React.useState<
@@ -125,7 +133,8 @@ export default function DrawerAppBar(): React.ReactElement {
125133
handleMenuClose();
126134
};
127135

128-
const container = typeof window !== 'undefined' ? () => window.document.body : undefined;
136+
const container =
137+
typeof window !== 'undefined' ? () => window.document.body : undefined;
129138

130139
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
131140

@@ -446,7 +455,7 @@ export default function DrawerAppBar(): React.ReactElement {
446455
severity='warning'
447456
onClose={() => {
448457
setHasTransitFeedsRedirect(false);
449-
if (hasTransitFeedsRedirectParam && clientSearchParams) {
458+
if (hasTransitFeedsRedirectParam && clientSearchParams != null) {
450459
// Remove utm_source from URL
451460
const newSearchParams = new URLSearchParams(clientSearchParams);
452461
newSearchParams.delete('utm_source');

src/app/components/ThemeToggle.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ const ThemeToggle = (): React.ReactElement => {
88

99
return (
1010
<IconButton onClick={toggleTheme} color='inherit' aria-label='Theme Toggle'>
11-
{mode === 'dark' ? (
12-
<Brightness7Icon />
13-
) : (
14-
<Brightness4Icon />
15-
)}
11+
{mode === 'dark' ? <Brightness7Icon /> : <Brightness4Icon />}
1612
</IconButton>
1713
);
1814
};

src/app/context/ThemeProvider.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,28 @@ import type ContextProviderProps from '../interface/ContextProviderProps';
1111

1212
// TODO: Revisit theme for best SSR practices
1313

14-
const ThemeContext = createContext({
14+
const ThemeContext = createContext({
1515
mode: ThemeModeEnum.light,
16-
toggleTheme: () => {}
16+
toggleTheme: () => {},
1717
});
1818

1919
export const ThemeProvider: React.FC<ContextProviderProps> = ({ children }) => {
2020
const prefersDarkMode = useMediaQuery('(prefers-color-scheme: dark)');
21-
21+
2222
// Initialize with system preference for SSR, then check localStorage on client
2323
const [mode, setMode] = useState<ThemeModeEnum>(
24-
prefersDarkMode ? ThemeModeEnum.dark : ThemeModeEnum.light
24+
prefersDarkMode ? ThemeModeEnum.dark : ThemeModeEnum.light,
2525
);
2626

2727
// Load theme from localStorage only on client side
2828
useEffect(() => {
2929
if (typeof window !== 'undefined') {
3030
const savedTheme = localStorage.getItem('theme');
31-
if (savedTheme && Object.values(ThemeModeEnum).includes(savedTheme as ThemeModeEnum)) {
31+
if (
32+
savedTheme != null &&
33+
savedTheme !== '' &&
34+
Object.values(ThemeModeEnum).includes(savedTheme as ThemeModeEnum)
35+
) {
3236
setMode(savedTheme as ThemeModeEnum);
3337
}
3438
}
@@ -55,5 +59,5 @@ export const ThemeProvider: React.FC<ContextProviderProps> = ({ children }) => {
5559
);
5660
};
5761

58-
export const useTheme = (): { mode: ThemeModeEnum, toggleTheme: () => void } =>
62+
export const useTheme = (): { mode: ThemeModeEnum; toggleTheme: () => void } =>
5963
useContext(ThemeContext);

src/i18n/navigation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { routing } from './routing';
33

44
/**
55
* Locale-aware navigation APIs.
6-
*
6+
*
77
* Use these instead of Next.js navigation to automatically handle locale prefixes:
88
* - Link: Locale-aware link component
99
* - redirect: Server-side redirect with locale

0 commit comments

Comments
 (0)