Skip to content

Commit

Permalink
A suite of dependency upgrades (#376)
Browse files Browse the repository at this point in the history
## Ticket

Resolves #{TICKET NUMBER OR URL} N/A

## Changes
- Upgrade next.js to 15 (Requires us to await params):
https://nextjs.org/docs/messages/sync-dynamic-apis
- Upgrade eslint to 9
- A few addl upgrades
- npm audit 

## Context for reviewers
Working through the separate dependabot PRs was a bit slow

## Testing
Clean run locally: 
<img width="1470" alt="Screenshot 2024-12-17 at 3 18 09 PM"
src="https://github.com/user-attachments/assets/227e09dc-7fd9-4dba-a2f9-1ad3928b7f63"
/>
  • Loading branch information
aligg authored Dec 18, 2024
1 parent d50eaad commit 2fd54c5
Show file tree
Hide file tree
Showing 9 changed files with 5,272 additions and 17,316 deletions.
2 changes: 1 addition & 1 deletion app/.storybook/I18nStoryWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { defaultLocale, formats, timeZone } from "../src/i18n/config";

const I18nStoryWrapper = (
Story: React.ComponentType,
context: StoryContext
context: StoryContext,
) => {
const locale = context.globals.locale ?? defaultLocale;

Expand Down
22,533 changes: 5,244 additions & 17,289 deletions app/package-lock.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"@trussworks/react-uswds": "^9.0.0",
"@uswds/uswds": "3.8.1",
"lodash": "^4.17.21",
"next": "^14.0.3",
"next": "^15.1.1",
"next-intl": "^3.2.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand All @@ -44,13 +44,13 @@
"@types/jest": "^29.5.5",
"@types/jest-axe": "^3.5.5",
"@types/lodash": "^4.14.202",
"@types/node": "^20.0.0",
"@types/node": "^22.10.2",
"@types/react": "^18.2.42",
"@types/react-dom": "^18.2.17",
"@typescript-eslint/eslint-plugin": "^8.0.0",
"@typescript-eslint/parser": "^8.0.0",
"eslint": "^8.36.0",
"eslint-config-next": "^14.0.0",
"@typescript-eslint/eslint-plugin": "^8.18.1",
"@typescript-eslint/parser": "^8.18.1",
"eslint": "^9.0.0",
"eslint-config-next": "^15.1.1",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-jest": "^28.0.0",
"eslint-plugin-jest-dom": "^5.0.1",
Expand All @@ -64,10 +64,10 @@
"postcss": "^8.4.31",
"postcss-loader": "^8.0.0",
"postcss-preset-env": "^10.0.0",
"prettier": "^2.8.4",
"prettier": "^3.4.2",
"sass": "^1.59.3",
"sass-loader": "^16.0.0",
"storybook": "^8.0.0",
"storybook": "^8.4.7",
"style-loader": "^4.0.0",
"typescript": "^5.0.0"
}
Expand Down
11 changes: 5 additions & 6 deletions app/src/app/[locale]/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@ export const metadata: Metadata = {

interface LayoutProps {
children: React.ReactNode;
params: {
locale: string;
};
params: Promise<{ locale: string }>;
}

export default function RootLayout({ children, params }: LayoutProps) {
export default async function RootLayout({ children, params }: LayoutProps) {
const { locale } = await params;
return (
<html lang={params.locale}>
<html lang={locale}>
<body>
{/* Separate layout component for the inner-body UI elements since Storybook
and tests trip over the fact that this file renders an <html> tag */}
<Layout locale={params.locale}>{children}</Layout>
<Layout locale={locale}>{children}</Layout>
</body>
</html>
);
Expand Down
13 changes: 7 additions & 6 deletions app/src/app/[locale]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { getTranslations } from "next-intl/server";

import { View } from "./view";

interface RouteParams {
locale: string;
}

export async function generateMetadata({ params }: { params: RouteParams }) {
const t = await getTranslations({ locale: params.locale });
export async function generateMetadata({
params,
}: {
params: Promise<{ locale: string }>;
}) {
const { locale } = await params;
const t = await getTranslations({ locale });
const meta: Metadata = {
title: t("home.title"),
};
Expand Down
4 changes: 2 additions & 2 deletions app/src/components/Layout.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe("Layout", () => {
render(
<Layout locale="en-US">
<h1>child</h1>
</Layout>
</Layout>,
);

const header = screen.getByRole("heading", { name: /child/i, level: 1 });
Expand All @@ -20,7 +20,7 @@ describe("Layout", () => {
const { container } = render(
<Layout locale="en-US">
<h1>child</h1>
</Layout>
</Layout>,
);
const results = await axe(container);

Expand Down
4 changes: 2 additions & 2 deletions app/src/i18n/getMessagesWithFallbacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ async function importMessages(locale: Locale) {
* from the current locale, the missing key will fallback to the default locale
*/
export async function getMessagesWithFallbacks(
requestedLocale: string = defaultLocale
requestedLocale: string = defaultLocale,
) {
const isValidLocale = locales.includes(requestedLocale as Locale); // https://github.com/microsoft/TypeScript/issues/26255
if (!isValidLocale) {
console.error(
"Unsupported locale was requested. Falling back to the default locale.",
{ locale: requestedLocale, defaultLocale }
{ locale: requestedLocale, defaultLocale },
);
requestedLocale = defaultLocale;
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/i18n/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { getMessagesWithFallbacks } from "./getMessagesWithFallbacks";
* This method is used behind the scenes by `next-intl/plugin`, which is setup in next.config.js.
* @see https://next-intl-docs.vercel.app/docs/usage/configuration#nextconfigjs
*/
export default getRequestConfig(async ({ locale }) => {
export default getRequestConfig(async ({ requestLocale }) => {
const locale = await requestLocale;
return {
formats,
messages: await getMessagesWithFallbacks(locale),
Expand Down
2 changes: 1 addition & 1 deletion app/tests/react-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export * from "@testing-library/react";
// 2. Then override the "@testing-library/react" render method
export function render(
ui: React.ReactElement,
options: Omit<RenderOptions, "wrapper"> = {}
options: Omit<RenderOptions, "wrapper"> = {},
) {
return _render(ui, { wrapper: GlobalProviders, ...options });
}

1 comment on commit 2fd54c5

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report for app

St.
Category Percentage Covered / Total
🟢 Statements 97.92% 47/48
🟢 Branches 85.71% 6/7
🟢 Functions 100% 8/8
🟢 Lines 100% 40/40

Test suite run success

5 tests passing in 3 suites.

Report generated by 🧪jest coverage report action from 2fd54c5

Please sign in to comment.