Skip to content

Commit bc77afb

Browse files
committed
chore: moved components to correct places and standardises array types
1 parent ce748e1 commit bc77afb

39 files changed

+52
-47
lines changed

.eslintrc.json

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"parser": "@typescript-eslint/parser",
5151
"rules": {
5252
"@typescript-eslint/consistent-type-imports": "error",
53+
"@typescript-eslint/array-type": ["error", { "default": "generic" }],
5354
"no-relative-import-paths/no-relative-import-paths": [
5455
"warn",
5556
{ "allowSameFolder": true, "prefix": "@" }

app/[locale]/[[...path]]/page.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { dynamicRouter } from '@/next.dynamic.mjs';
1212
import { availableLocaleCodes, defaultLocale } from '@/next.locales.mjs';
1313
import { MatterProvider } from '@/providers/matterProvider';
1414

15-
type DynamicStaticPaths = { path: string[]; locale: string };
15+
type DynamicStaticPaths = { path: Array<string>; locale: string };
1616
type DynamicParams = { params: DynamicStaticPaths };
1717

1818
// This is the default Viewport Metadata
@@ -38,7 +38,7 @@ export const generateMetadata = async ({ params }: DynamicParams) => {
3838
// This provides all the possible paths that can be generated statically
3939
// + provides all the paths that we support on the Node.js Website
4040
export const generateStaticParams = async () => {
41-
const paths: DynamicStaticPaths[] = [];
41+
const paths: Array<DynamicStaticPaths> = [];
4242

4343
// We don't need to compute all possible paths on regular builds
4444
// as we benefit from Next.js's ISR (Incremental Static Regeneration)

app/sitemap.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const baseUrlAndPath = `${BASE_URL}${BASE_PATH}`;
1515
// Next.js Sitemap Generation doesn't support `alternate` refs yet
1616
// @see https://github.com/vercel/next.js/discussions/55646
1717
const sitemap = async (): Promise<MetadataRoute.Sitemap> => {
18-
const paths: string[] = [];
18+
const paths: Array<string> = [];
1919

2020
for (const locale of availableLocaleCodes) {
2121
const routes = await dynamicRouter.getRoutesByLanguage(locale);

components/Common/AvatarGroup/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { getAcronymFromString } from '@/util/stringUtils';
99
import styles from './index.module.css';
1010

1111
type AvatarGroupProps = {
12-
avatars: ComponentProps<typeof Avatar>[];
12+
avatars: Array<ComponentProps<typeof Avatar>>;
1313
limit?: number;
1414
isExpandable?: boolean;
1515
};

components/Common/BlogPostCard/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type BlogPostCardProps = {
1717
title: ComponentProps<typeof Preview>['title'];
1818
type: Required<ComponentProps<typeof Preview>>['type'];
1919
description: string;
20-
authors: Author[];
20+
authors: Array<Author>;
2121
date: Date;
2222
};
2323

components/Common/Breadcrumbs/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type BreadcrumbLink = {
1313
};
1414

1515
type BreadcrumbsProps = {
16-
links: BreadcrumbLink[];
16+
links: Array<BreadcrumbLink>;
1717
maxLength?: number;
1818
hideHome?: boolean;
1919
};

components/Common/LanguageDropDown/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type SimpleLocaleConfig = Pick<LocaleConfig, 'name' | 'code'>;
1313
type LanguageDropDownProps = {
1414
onChange?: (newLocale: SimpleLocaleConfig) => void;
1515
currentLanguage: string;
16-
availableLanguages: SimpleLocaleConfig[];
16+
availableLanguages: Array<SimpleLocaleConfig>;
1717
};
1818

1919
const LanguageDropdown: FC<LanguageDropDownProps> = ({

components/Common/Pagination/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type Page = { url: string };
1212
type PaginationProps = {
1313
// One-based number of the current page
1414
currentPage: number;
15-
pages: Page[];
15+
pages: Array<Page>;
1616
// The number of page buttons on each side of the current page button
1717
// @default 1
1818
currentPageSiblingsCount?: number;

components/Common/Pagination/useGetPageElements.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@ const parsePages = (
99
pages: ComponentProps<typeof Pagination>['pages'],
1010
currentPage: number,
1111
totalPages: number
12-
): PaginationListItemProps[] =>
12+
): Array<PaginationListItemProps> =>
1313
pages.map(({ url }, index) => ({
1414
url,
1515
pageNumber: index + 1,
1616
currentPage,
1717
totalPages,
1818
}));
1919

20-
const createPaginationListItems = (parsedPages: PaginationListItemProps[]) =>
21-
parsedPages.map(page => <PaginationListItem key={page.url} {...page} />);
20+
const createPaginationListItems = (
21+
parsedPages: Array<PaginationListItemProps>
22+
) => parsedPages.map(page => <PaginationListItem key={page.url} {...page} />);
2223

2324
// The minimum amount of elements are first page, current page, and last page
2425
const MINIMUM_AMOUNT_OF_ELEMENTS = 3;

components/Common/ProgressionSidebar/ProgressionSidebarGroup/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import styles from './index.module.css';
77

88
type ProgressionSidebarGroupProps = {
99
groupName: FormattedMessage;
10-
items: ComponentProps<typeof ProgressionSidebarItem>[];
10+
items: Array<ComponentProps<typeof ProgressionSidebarItem>>;
1111
};
1212

1313
const ProgressionSidebarGroup: FC<ProgressionSidebarGroupProps> = ({

components/Common/ProgressionSidebar/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import WithSidebarSelect from '@/components/withSidebarSelect';
66
import styles from './index.module.css';
77

88
type ProgressionSidebarProps = {
9-
groups: ComponentProps<typeof ProgressionSidebarGroup>[];
9+
groups: Array<ComponentProps<typeof ProgressionSidebarGroup>>;
1010
};
1111

1212
const ProgressionSidebar: FC<ProgressionSidebarProps> = ({ groups }) => (

components/Common/Select/index.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ type SelectValue = {
1818

1919
type SelectGroup = {
2020
label?: FormattedMessage;
21-
items: SelectValue[];
21+
items: Array<SelectValue>;
2222
};
2323

24-
const isStringArray = (values: unknown[]): values is string[] =>
24+
const isStringArray = (values: Array<unknown>): values is Array<string> =>
2525
Boolean(values[0] && typeof values[0] === 'string');
2626

27-
const isValuesArray = (values: unknown[]): values is SelectValue[] =>
27+
const isValuesArray = (values: Array<unknown>): values is Array<SelectValue> =>
2828
Boolean(values[0] && typeof values[0] === 'object' && 'value' in values[0]);
2929

3030
type SelectProps = {
31-
values: SelectGroup[] | SelectValue[] | string[];
31+
values: Array<SelectGroup> | Array<SelectValue> | Array<string>;
3232
defaultValue?: string;
3333
placeholder?: string;
3434
label?: string;

components/Common/Tabs/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ type Tab = {
1010
};
1111

1212
type TabsProps = {
13-
tabs: Tab[];
13+
tabs: Array<Tab>;
1414
addons?: ReactNode;
1515
headerClassName?: string;
1616
} & TabsPrimitive.TabsProps;

components/Containers/Footer/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useTranslations } from 'next-intl';
22
import type { FC, SVGProps } from 'react';
33

4-
import NavItem from '@/components/Common/NavItem';
4+
import NavItem from '@/components/Containers/NavBar/NavItem';
55
import GitHub from '@/components/Icons/Social/GitHub';
66
import LinkedIn from '@/components/Icons/Social/LinkedIn';
77
import Mastodon from '@/components/Icons/Social/Mastodon';

components/Common/MetaBar/index.stories.tsx renamed to components/Containers/MetaBar/index.stories.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { CodeBracketIcon } from '@heroicons/react/24/outline';
22
import type { Meta as MetaObj, StoryObj } from '@storybook/react';
33

44
import AvatarGroup from '@/components/Common/AvatarGroup';
5-
import MetaBar from '@/components/Common/MetaBar';
5+
import MetaBar from '@/components/Containers/MetaBar';
66
import GitHub from '@/components/Icons/Social/GitHub';
77
import Link from '@/components/Link';
88

components/Common/MetaBar/index.tsx renamed to components/Containers/MetaBar/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import styles from './index.module.css';
1010
type MetaBarProps = {
1111
items: Record<string, React.ReactNode>;
1212
headings?: {
13-
items: Heading[];
13+
items: Array<Heading>;
1414
minDepth?: number;
1515
};
1616
};

components/Common/NavItem/index.stories.tsx renamed to components/Containers/NavBar/NavItem/index.stories.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Meta as MetaObj, StoryObj } from '@storybook/react';
22

3-
import NavItem from '@/components/Common/NavItem';
3+
import NavItem from '@/components/Containers/NavBar/NavItem';
44

55
type Story = StoryObj<typeof NavItem>;
66
type Meta = MetaObj<typeof NavItem>;

components/Containers/NavBar/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { useState } from 'react';
77
import type { FC, ComponentProps } from 'react';
88

99
import LanguageDropdown from '@/components/Common/LanguageDropDown';
10-
import NavItem from '@/components/Common/NavItem';
1110
import ThemeToggle from '@/components/Common/ThemeToggle';
11+
import NavItem from '@/components/Containers/NavBar/NavItem';
1212
import NodejsDark from '@/components/Icons/Logos/NodejsDark';
1313
import NodejsLight from '@/components/Icons/Logos/NodejsLight';
1414
import GitHub from '@/components/Icons/Social/GitHub';
@@ -23,7 +23,7 @@ const navInteractionIcons = {
2323
};
2424

2525
type NavbarProps = {
26-
navItems: { text: FormattedMessage; link: string }[];
26+
navItems: Array<{ text: FormattedMessage; link: string }>;
2727
languages: ComponentProps<typeof LanguageDropdown>;
2828
onThemeTogglerClick: () => void;
2929
};

components/Common/Sidebar/SidebarGroup/index.tsx renamed to components/Containers/Sidebar/SidebarGroup/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import type { ComponentProps, FC } from 'react';
22

3-
import SidebarItem from '@/components/Common/Sidebar/SidebarItem';
3+
import SidebarItem from '@/components/Containers/Sidebar/SidebarItem';
44
import type { FormattedMessage } from '@/types';
55

66
import styles from './index.module.css';
77

88
type SidebarGroupProps = {
99
groupName: FormattedMessage;
10-
items: ComponentProps<typeof SidebarItem>[];
10+
items: Array<ComponentProps<typeof SidebarItem>>;
1111
};
1212

1313
const SidebarGroup: FC<SidebarGroupProps> = ({ groupName, items }) => (

components/Common/Sidebar/index.stories.tsx renamed to components/Containers/Sidebar/index.stories.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Meta as MetaObj, StoryObj } from '@storybook/react';
22

3-
import Sidebar from '@/components/Common/Sidebar';
3+
import Sidebar from '@/components/Containers/Sidebar';
44

55
type Story = StoryObj<typeof Sidebar>;
66
type Meta = MetaObj<typeof Sidebar>;

components/Common/Sidebar/index.tsx renamed to components/Containers/Sidebar/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import type { ComponentProps, FC } from 'react';
22

3-
import SidebarGroup from '@/components/Common/Sidebar/SidebarGroup';
3+
import SidebarGroup from '@/components/Containers/Sidebar/SidebarGroup';
44
import WithSidebarSelect from '@/components/withSidebarSelect';
55

66
import styles from './index.module.css';
77

88
type SidebarProps = {
9-
groups: ComponentProps<typeof SidebarGroup>[];
9+
groups: Array<ComponentProps<typeof SidebarGroup>>;
1010
};
1111

1212
const SideBar: FC<SidebarProps> = ({ groups }) => (

components/SideNavigation.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useSiteNavigation } from '@/hooks/server';
66
import type { NavigationKeys } from '@/types';
77

88
type SideNavigationProps = {
9-
navigationKeys: NavigationKeys[];
9+
navigationKeys: Array<NavigationKeys>;
1010
context?: Record<string, RichTranslationValues>;
1111
};
1212

components/withMetaBar.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useFormatter } from 'next-intl';
22
import type { FC } from 'react';
33

4-
import MetaBar from '@/components/Common/MetaBar';
4+
import MetaBar from '@/components/Containers/MetaBar';
55
import GitHub from '@/components/Icons/Social/GitHub';
66
import Link from '@/components/Link';
77
import { useClientContext } from '@/hooks/server';

components/withNodeRelease.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import getReleaseData from '@/next-data/releaseData';
44
import type { NodeRelease, NodeReleaseStatus } from '@/types';
55

66
type WithNodeReleaseProps = {
7-
status: NodeReleaseStatus[] | NodeReleaseStatus;
7+
status: Array<NodeReleaseStatus> | NodeReleaseStatus;
88
children: FC<{ release: NodeRelease }>;
99
};
1010

components/withSidebar.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import type { RichTranslationValues } from 'next-intl';
22
import type { FC } from 'react';
33

4-
import Sidebar from '@/components/Common/Sidebar';
4+
import Sidebar from '@/components/Containers/Sidebar';
55
import { useSiteNavigation } from '@/hooks/server';
66
import type { NavigationKeys } from '@/types';
77

88
type WithSidebarProps = {
9-
navKeys: NavigationKeys[];
9+
navKeys: Array<NavigationKeys>;
1010
context?: Record<string, RichTranslationValues>;
1111
};
1212

components/withSidebarSelect.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type SelectItem = {
1414
};
1515

1616
type WithSidebarSelectProps = {
17-
groups: { groupName: FormattedMessage; items: SelectItem[] }[];
17+
groups: Array<{ groupName: FormattedMessage; items: Array<SelectItem> }>;
1818
};
1919

2020
const WithSidebarSelect: FC<WithSidebarSelectProps> = ({ groups }) => {

hooks/react-generic/useSiteNavigation.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type Context = Record<string, RichTranslationValues>;
1212
type Navigation = Record<string, NavigationEntry>;
1313

1414
interface MappedNavigationEntry {
15-
items: [string, MappedNavigationEntry][];
15+
items: Array<[string, MappedNavigationEntry]>;
1616
label: FormattedMessage;
1717
link: string;
1818
}
@@ -51,7 +51,10 @@ const useSiteNavigation = () => {
5151
);
5252
};
5353

54-
const getSideNavigation = (keys: NavigationKeys[], context: Context = {}) => {
54+
const getSideNavigation = (
55+
keys: Array<NavigationKeys>,
56+
context: Context = {}
57+
) => {
5558
const navigationEntries: Navigation = keys.reduce(
5659
(acc, key) => ({ ...acc, [key]: siteNavigation.sideNavigation[key] }),
5760
{}

next-data/releaseData.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
} from '@/next.constants.mjs';
77
import type { NodeRelease } from '@/types';
88

9-
const getReleaseData = (): Promise<NodeRelease[]> => {
9+
const getReleaseData = (): Promise<Array<NodeRelease>> => {
1010
// When we're using Static Exports the Next.js Server is not running (during build-time)
1111
// hence the self-ingestion APIs will not be available. In this case we want to load
1212
// the data directly within the current thread, which will anyways be loaded only once

providers/matterProvider.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { LegacyFrontMatter } from '@/types';
1010
type MatterContext = {
1111
frontmatter: LegacyFrontMatter;
1212
pathname: string;
13-
headings: Heading[];
13+
headings: Array<Heading>;
1414
readingTime: ReadTimeResults;
1515
filename: string;
1616
};

types/blog.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ export interface BlogPost {
77
}
88

99
export interface BlogData {
10-
posts: BlogPost[];
11-
pagination: number[];
12-
categories: string[];
10+
posts: Array<BlogPost>;
11+
pagination: Array<number>;
12+
categories: Array<string>;
1313
}
1414

1515
export interface BlogDataRSC {
16-
posts: BlogPost[];
16+
posts: Array<BlogPost>;
1717
pagination: {
1818
next: number | null;
1919
prev: number | null;
2020
};
2121
meta: {
22-
categories: string[];
23-
pagination: number[];
22+
categories: Array<string>;
23+
pagination: Array<number>;
2424
};
2525
}

types/i18n.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ export interface LocaleConfig {
1313
export type FormattedMessage =
1414
| string
1515
| ReactElement<HTMLElement, string | JSXElementConstructor<HTMLElement>>
16-
| readonly ReactNode[];
16+
| ReadonlyArray<ReactNode>;

types/server.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { LegacyFrontMatter } from './frontmatter';
55

66
export interface ClientSharedServerContext {
77
frontmatter: LegacyFrontMatter;
8-
headings: Heading[];
8+
headings: Array<Heading>;
99
pathname: string;
1010
filename: string;
1111
readingTime: ReadTimeResults;

0 commit comments

Comments
 (0)