Skip to content

Commit acb17e0

Browse files
authored
ci(docs): add linter check (#10376)
### Description Turning on the linter for the docs site now that we've done the bulk of our high velocity work. ### Testing Instructions CI. You can also browse the preview for anything that may look amiss.
1 parent 4c346b9 commit acb17e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+348
-243
lines changed

docs/site/.eslintrc.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
/** @type {import('eslint').Linter.Config} */
22
module.exports = {
33
root: true,
4-
extends: ["@turbo/eslint-config/library", "next"],
4+
extends: ["@turbo/eslint-config/library", "plugin:@next/next/recommended"],
55
ignorePatterns: [
66
"turbo",
77
".map.ts",
88
"!app/.well-known/vercel/flags/route.ts",
99
".source",
10+
"components/ui/**",
11+
// TODO: Need to fix the JSON inference in this file
12+
"components/examples-table.tsx",
1013
],
1114
overrides: [
1215
{
@@ -16,7 +19,15 @@ module.exports = {
1619
},
1720
},
1821
{
19-
files: ["next.config.mjs", "global-error.jsx"],
22+
files: [
23+
"next.config.mjs",
24+
"global-error.tsx",
25+
"page.tsx",
26+
"not-found.tsx",
27+
"source.config.ts",
28+
"next.config.ts",
29+
"layout.tsx",
30+
],
2031
rules: {
2132
"import/no-default-export": "off",
2233
},

docs/site/app/(no-sidebar)/[...slug]/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { notFound } from "next/navigation";
22
import { extraPages } from "@/app/source";
33

44
export default async function SlugLayout(props: {
5-
params: Promise<{ slug?: string[] }>;
5+
params: Promise<{ slug?: Array<string> }>;
66
children: React.ReactNode;
77
}): Promise<JSX.Element> {
88
const params = await props.params;

docs/site/app/(no-sidebar)/[...slug]/page.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { createMetadata } from "@/lib/create-metadata";
55
import { mdxComponents } from "@/mdx-components";
66

77
export default async function Page(props: {
8-
params: Promise<{ slug?: string[] }>;
8+
params: Promise<{ slug?: Array<string> }>;
99
}): Promise<JSX.Element> {
1010
const params = await props.params;
1111
const page = extraPages.getPage(params.slug);
@@ -14,6 +14,7 @@ export default async function Page(props: {
1414
notFound();
1515
}
1616

17+
/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- MDX component */
1718
const Mdx = page.data.body;
1819

1920
return (
@@ -24,14 +25,14 @@ export default async function Page(props: {
2425
);
2526
}
2627

27-
export function generateStaticParams(): { slug: string[] }[] {
28+
export function generateStaticParams(): Array<{ slug: Array<string> }> {
2829
return extraPages.getPages().map((page) => ({
2930
slug: page.slugs,
3031
}));
3132
}
3233

3334
export async function generateMetadata(props: {
34-
params: Promise<{ slug?: string[] }>;
35+
params: Promise<{ slug?: Array<string> }>;
3536
}): Promise<Metadata> {
3637
const params = await props.params;
3738
const page = extraPages.getPage(params.slug);

docs/site/app/(no-sidebar)/blog/[...slug]/page.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import { createMetadata } from "@/lib/create-metadata";
77
import { FaviconHandler } from "@/app/_components/favicon-handler";
88
import { mdxComponents } from "@/mdx-components";
99

10-
export function generateStaticParams(): { slug: string[] }[] {
10+
export function generateStaticParams(): Array<{ slug: Array<string> }> {
1111
return blog.getPages().map((page) => ({
1212
slug: page.slugs,
1313
}));
1414
}
1515

1616
export async function generateMetadata(props: {
17-
params: Promise<{ slug?: string[] }>;
17+
params: Promise<{ slug?: Array<string> }>;
1818
}): Promise<Metadata> {
1919
const params = await props.params;
2020
const page = blog.getPage(params.slug);
@@ -38,13 +38,14 @@ export async function generateMetadata(props: {
3838
}
3939

4040
export default async function Page(props: {
41-
params: Promise<{ slug?: string[] }>;
41+
params: Promise<{ slug?: Array<string> }>;
4242
}): Promise<JSX.Element> {
4343
const params = await props.params;
4444
const page = blog.getPage(params.slug);
4545

4646
if (!page) notFound();
4747

48+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- Not being inferred correctly
4849
const Mdx = page.data.body;
4950

5051
return (

docs/site/app/(no-sidebar)/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default function Layout({
1111
return (
1212
<>
1313
<FaviconHandler />
14-
{/* @ts-expect-error */}
14+
{/* @ts-expect-error - className isn't on type but it works. */}
1515
<HomeLayout className="p-0" {...baseOptions}>
1616
{children}
1717
</HomeLayout>

docs/site/app/(no-sidebar)/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
"use client";
22

33
import React, { useState } from "react";
4-
import { cn } from "@/components/cn";
54
import Link from "next/link";
65
import { motion } from "framer-motion";
6+
import { cn } from "@/components/cn";
77
import { Clients } from "@/app/_clients/clients";
88
import { FadeIn } from "@/app/_components/home-shared/fade-in";
99
import { PackLogo } from "@/app/_components/logos/pack-logo";

docs/site/app/(openapi)/docs/openapi/[[...slug]]/page.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ import {
77
import { notFound } from "next/navigation";
88
import defaultMdxComponents from "fumadocs-ui/mdx";
99
import { openapi, openapiPages } from "../source";
10-
// eslint-disable-next-line rulesdir/global-css
1110
import "./openapi.css";
1211

1312
export default async function Page(props: {
14-
params: Promise<{ slug?: string[] }>;
13+
params: Promise<{ slug?: Array<string> }>;
1514
}): Promise<JSX.Element> {
1615
const params = await props.params;
1716
const page = openapiPages.getPage(params.slug);
@@ -20,6 +19,7 @@ export default async function Page(props: {
2019
notFound();
2120
}
2221

22+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- Not typed properly?
2323
const Mdx = page.data.body;
2424

2525
return (
@@ -30,6 +30,7 @@ export default async function Page(props: {
3030
<Mdx
3131
components={{
3232
...defaultMdxComponents,
33+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- Not typed properly?
3334
APIPage: openapi.APIPage,
3435
}}
3536
/>
@@ -38,6 +39,6 @@ export default async function Page(props: {
3839
);
3940
}
4041

41-
export function generateStaticParams(): { slug: string[] }[] {
42+
export function generateStaticParams(): Array<{ slug: Array<string> }> {
4243
return openapiPages.generateParams();
4344
}

docs/site/app/(openapi)/docs/openapi/layout.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ import { Navigation } from "@/components/nav";
44
import { Sidebar } from "#/components/docs-layout/sidebar";
55
import { openapiPages } from "./source";
66

7-
export default async function Layout({
8-
children,
9-
}: {
10-
children: React.ReactNode;
11-
}) {
7+
export default function Layout({ children }: { children: React.ReactNode }) {
128
return (
139
<>
1410
<Navigation />
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import { createMDXSource } from "fumadocs-mdx";
2-
import { createOpenAPI, attachFile } from "fumadocs-openapi/server";
2+
import { createOpenAPI } from "fumadocs-openapi/server";
33
import { loader } from "fumadocs-core/source";
44
import { openapiDocs, openapiMeta } from "@/.source";
55

66
export const openapiPages = loader({
77
baseUrl: "/docs/openapi",
88
source: createMDXSource(openapiDocs, openapiMeta),
9-
pageTree: {
10-
attachFile,
11-
},
129
});
1310

1411
export const openapi = createOpenAPI();

docs/site/app/(sidebar)/docs/[[...slug]]/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { notFound } from "next/navigation";
33
import { repoDocsPages } from "@/app/source";
44

55
export default async function SlugLayout(props: {
6-
params: Promise<{ slug?: string[] }>;
6+
params: Promise<{ slug?: Array<string> }>;
77
children: React.ReactNode;
88
}): Promise<JSX.Element> {
99
const params = await props.params;

docs/site/app/(sidebar)/docs/[[...slug]]/page.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1+
import { readFileSync } from "node:fs";
12
import { notFound } from "next/navigation";
2-
import { readFileSync } from "fs";
33
import type { Metadata } from "next/types";
44
import { repoDocsPages } from "@/app/source";
55
import { createMetadata } from "@/lib/create-metadata";
66
import { mdxComponents } from "@/mdx-components";
7-
import { SystemEnvironmentVariablesHashHighlighter } from "./system-environment-variables-hash-highlighter";
87
import { CopyToMarkdown } from "@/components/copy-to-markdown";
8+
import { SystemEnvironmentVariablesHashHighlighter } from "./system-environment-variables-hash-highlighter";
99

1010
export async function generateMetadata(props: {
11-
params: Promise<{ slug?: string[] }>;
11+
params: Promise<{ slug?: Array<string> }>;
1212
}): Promise<Metadata> {
1313
const params = await props.params;
1414
const page = repoDocsPages.getPage(params.slug);
@@ -22,14 +22,14 @@ export async function generateMetadata(props: {
2222
});
2323
}
2424

25-
export function generateStaticParams(): { slug: string[] }[] {
25+
export function generateStaticParams(): Array<{ slug: Array<string> }> {
2626
return repoDocsPages.getPages().map((page) => ({
2727
slug: page.slugs,
2828
}));
2929
}
3030

3131
export default async function Page(props: {
32-
params: Promise<{ slug?: string[] }>;
32+
params: Promise<{ slug?: Array<string> }>;
3333
}): Promise<JSX.Element> {
3434
const params = await props.params;
3535
const page = repoDocsPages.getPage(params.slug);
@@ -41,10 +41,14 @@ export default async function Page(props: {
4141
const rawMarkdown = readFileSync(page.data._file.absolutePath)
4242
.toString()
4343
// Removes frontmatter
44-
.replace(/^---\n(.*?\n)---\n/s, "")
44+
.replace(/^---\n(?<content>.*?\n)---\n/s, "")
4545
// Removes import statements for components
46-
.replace(/^import\s+{[^}]+}\s+from\s+['"]#\/[^'"]+['"];(\r?\n|$)/gm, "");
46+
.replace(
47+
/^import\s+{[^}]+}\s+from\s+['"]#\/[^'"]+['"];(?<lineEnding>\r?\n|$)/gm,
48+
""
49+
);
4750

51+
/* eslint-disable-next-line @typescript-eslint/no-unsafe-assignment -- MDX component is dynamically imported */
4852
const Mdx = page.data.body;
4953

5054
return (

docs/site/app/(sidebar)/layout.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import { DocsLayout } from "@/components/docs-layout";
22
import { repoDocsPages } from "@/app/source";
3-
import { baseOptions } from "../layout-config";
43
import { Navigation } from "@/components/nav";
5-
import { RedirectsHandler } from "./redirects-handler";
64
import { Sidebar } from "#/components/docs-layout/sidebar";
5+
import { baseOptions } from "../layout-config";
6+
import { RedirectsHandler } from "./redirects-handler";
77

8-
export default async function Layout({
9-
children,
10-
}: {
11-
children: React.ReactNode;
12-
}) {
8+
export default function Layout({ children }: { children: React.ReactNode }) {
139
return (
1410
<>
1511
<Navigation />

docs/site/app/(sidebar)/redirects-handler.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,18 +193,19 @@ const handleRedirect = (
193193
clientRedirectsMap[pathname as keyof typeof clientRedirectsMap];
194194

195195
const newHash: string | undefined =
196-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
196+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- These are correct.
197197
redirectList?.[window.location.hash]?.hash;
198198

199199
const newLocation: string | undefined =
200-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
200+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- These are correct.
201201
redirectList?.[window.location.hash]?.location;
202202

203203
if (newHash && newLocation) {
204204
/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- TODO: Fix ESLint Error (#13355)
205205
* biome-ignore lint/correctness/noVoidTypeReturn: Ignored using `--suppress`
206206
* */
207-
return router.push(`${newLocation ?? ""}${newHash ? `#${newHash}` : ""}`);
207+
router.push(`${newLocation ?? ""}${newHash ? `#${newHash}` : ""}`);
208+
return;
208209
}
209210

210211
if (newHash) {
@@ -223,7 +224,6 @@ export function RedirectsHandler(): null {
223224

224225
useEffect(() => {
225226
handleRedirect(router, pathname);
226-
// eslint-disable-next-line react-hooks/exhaustive-deps -- We only want this hook to run on initial entry to the site.
227227
}, []);
228228

229229
return null;

docs/site/app/_clients/client-logo.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react";
2-
import { cn } from "@/components/cn";
32
import Image from "next/image";
3+
import { cn } from "@/components/cn";
44
import type { TurboUser } from "./users";
55

66
const DEFAULT_SIZE = {
@@ -23,28 +23,30 @@ export function Logo({
2323
...DEFAULT_SIZE,
2424
...user.style,
2525
};
26-
let numericWidth: number;
27-
let numericHeight: number;
26+
27+
// Initialize with default values
28+
let numericWidth = DEFAULT_SIZE.width;
29+
let numericHeight = DEFAULT_SIZE.height;
30+
2831
if (typeof styles.width === "number") {
2932
numericWidth = styles.width;
3033
}
3134
if (typeof styles.height === "number") {
3235
numericHeight = styles.height;
3336
}
37+
3438
const logo = (
3539
<Image
3640
alt={`${user.caption}'s Logo`}
3741
className={cn("mx-8", className)}
38-
// biome-ignore lint/style/noNonNullAssertion: Ignored using `--suppress`
39-
height={numericHeight!}
42+
height={numericHeight}
4043
priority
4144
src={user.image.replace(
4245
"/logos",
4346
theme === "light" ? "/logos/white" : "/logos/color"
4447
)}
4548
style={styles}
46-
// biome-ignore lint/style/noNonNullAssertion: Ignored using `--suppress`
47-
width={numericWidth!}
49+
width={numericWidth}
4850
/>
4951
);
5052

docs/site/app/_clients/clients.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
import type { ReactElement } from "react";
44
import React, { useEffect, useState } from "react";
5+
import { useTheme } from "next-themes";
56
import { cn } from "@/components/cn";
67
import { users } from "./users";
78
import { Logo } from "./client-logo";
8-
import { useTheme } from "next-themes";
99

1010
interface LogoWrapperProps {
1111
className: string;
@@ -31,7 +31,7 @@ export function Clients({
3131
}: {
3232
linked?: boolean;
3333
staticWidth?: boolean;
34-
companyList?: string[];
34+
companyList?: Array<string>;
3535
}) {
3636
const [mounted, setMounted] = useState(false);
3737
const { theme } = useTheme();

docs/site/app/_clients/users.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export interface TurboUser {
88
style?: CSSProperties;
99
}
1010

11-
export const users: TurboUser[] = [
11+
export const users: Array<TurboUser> = [
1212
{
1313
caption: "Vercel",
1414
image: "/images/logos/vercel.svg",

0 commit comments

Comments
 (0)