Skip to content

Commit de36492

Browse files
committed
Update deps, use biome
1 parent ad9518c commit de36492

File tree

34 files changed

+108
-104
lines changed

34 files changed

+108
-104
lines changed

app/(home)/components/header/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Globe, MapPin, User } from "react-feather";
88

99
import { HStack, VStack } from "~/components/stack";
1010

11-
import { HeaderItem, ItemProps } from "./components/item";
11+
import { HeaderItem, type ItemProps } from "./components/item";
1212
import styles from "./styles.module.scss";
1313

1414
const profile: ItemProps[] = [
@@ -45,7 +45,7 @@ const links: ItemProps[] = [
4545
{
4646
icon: IconBrandDiscord,
4747
label: "Discord",
48-
value: "nzws#0001",
48+
value: "nzws",
4949
},
5050
];
5151

@@ -73,13 +73,13 @@ export function Header() {
7373

7474
<HStack gap="12px" alignItems="center" wrap className={styles.items}>
7575
{profile.map((props, index) => (
76-
<HeaderItem key={index} {...props} />
76+
<HeaderItem key={props.href ?? index} {...props} />
7777
))}
7878
</HStack>
7979

8080
<HStack gap="12px" alignItems="center" wrap className={styles.items}>
8181
{links.map((props, index) => (
82-
<HeaderItem key={index} {...props} />
82+
<HeaderItem key={props.href ?? index} {...props} />
8383
))}
8484
</HStack>
8585
</VStack>

app/api/internal/search-raw/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import RemoveMarkdown from "remove-markdown";
44
import { ArticleFinderService } from "~/lib/article-finder-service";
55
import { CacheService } from "~/lib/cache-service";
66
import { ArticleType } from "~/utils/constants";
7-
import { ArticleDetails, ArticleSearchExport } from "~/utils/type";
7+
import type { ArticleDetails, ArticleSearchExport } from "~/utils/type";
88

99
const items = Object.values(ArticleType).map((type) =>
1010
new CacheService<ArticleDetails[]>("article-list", type).sync(() =>
@@ -14,7 +14,7 @@ const items = Object.values(ArticleType).map((type) =>
1414

1515
export async function GET() {
1616
const data = (await Promise.all(items))
17-
.flatMap((item) => item)
17+
.flat()
1818
.filter((item) => !item.isHidden);
1919

2020
const flatted: ArticleSearchExport[] = data.map((item) => ({

app/api/web/og/[hash]/[base64]/route.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ImageResponse } from "@vercel/og";
2-
import { NextRequest, NextResponse } from "next/server";
2+
import { type NextRequest, NextResponse } from "next/server";
33

44
import { signature } from "~/lib/crypto/browser";
55
import { decode } from "~/lib/encoder";
@@ -80,12 +80,11 @@ export async function GET(
8080
},
8181
],
8282
});
83-
} else {
84-
return NextResponse.json(
85-
{
86-
error: "Invalid type",
87-
},
88-
{ status: 400 },
89-
);
9083
}
84+
return NextResponse.json(
85+
{
86+
error: "Invalid type",
87+
},
88+
{ status: 400 },
89+
);
9190
}

app/api/web/search/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { NextRequest, NextResponse } from "next/server";
1+
import { type NextRequest, NextResponse } from "next/server";
22

33
import { BASE_URL } from "~/utils/constants";
4-
import { ArticleSearchExport } from "~/utils/type";
4+
import type { ArticleSearchExport } from "~/utils/type";
55

66
export const runtime = "edge";
77

app/blog/[id]/page.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Image } from "~/components/image";
66
import { MDXLoader } from "~/components/mdx-loader";
77
import { HStack, VStack } from "~/components/stack";
88
import { getArticle } from "~/lib/file-io";
9-
import { ArticleType, dateOptions, PUBLIC_URL } from "~/utils/constants";
9+
import { ArticleType, PUBLIC_URL, dateOptions } from "~/utils/constants";
1010

1111
import styles from "./styles.module.scss";
1212

@@ -66,9 +66,9 @@ export default async function Page({ params: { id } }: { params: Params }) {
6666
<MDXLoader content={article.markdown} />
6767
</div>
6868

69-
{article.scripts?.map((script, key) => (
69+
{article.scripts?.map((script) => (
7070
<Script
71-
key={key}
71+
key={scriptUrls[script] || script}
7272
src={scriptUrls[script] || script}
7373
strategy="lazyOnload"
7474
/>
@@ -101,7 +101,7 @@ export async function generateMetadata({
101101
description,
102102
openGraph: {
103103
title: `${article.title} - Blog - nzws.me`,
104-
url: PUBLIC_URL ? PUBLIC_URL + "/blog/" + article.slug : undefined,
104+
url: PUBLIC_URL ? `${PUBLIC_URL}/blog/${article.slug}` : undefined,
105105
description,
106106
images: [
107107
{

app/blog/components/item/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Link from "next/link";
2-
import { FC } from "react";
2+
import type { FC } from "react";
33

44
import { Image } from "~/components/image";
55
import { HStack, VStack } from "~/components/stack";

app/blog/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PropsWithChildren } from "react";
1+
import type { PropsWithChildren } from "react";
22

33
import { Footer } from "~/components/footer";
44
import { Navigation } from "~/components/navigation";

app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import "~/styles/global.scss";
33
import "react-loading-skeleton/dist/skeleton.css";
44

55
import { Analytics } from "@vercel/analytics/react";
6-
import { PropsWithChildren } from "react";
6+
import type { PropsWithChildren } from "react";
77

88
import { Mincho, Sans } from "~/styles/font";
99

app/product/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PropsWithChildren } from "react";
1+
import type { PropsWithChildren } from "react";
22

33
export default function Layout({ children }: PropsWithChildren) {
44
return children;

biome.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
"$schema": "node_modules/@biomejs/biome/configuration_schema.json",
33
"formatter": {
44
"enabled": true,
5-
"indentStyle": "space",
6-
"ignore": ["packages/publicapi-client/src/api"]
5+
"indentStyle": "space"
76
},
87
"linter": {
9-
"enabled": false
8+
"rules": {
9+
"recommended": true
10+
}
1011
},
1112
"organizeImports": {
1213
"enabled": true

bun.lockb

-122 KB
Binary file not shown.

components/image/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ async function RealComponent({ src, ...props }: Props) {
2929
});
3030
if (!metadata) {
3131
// @ts-expect-error: fallback
32-
// eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
32+
// biome-ignore lint/a11y/useAltText: <explanation>
3333
return <img src={src} {...props} />;
3434
}
3535

components/mdx-loader/components/image-with-note/index.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import { PropsWithChildren } from "react";
2-
3-
import { Image, ImageProps } from "~/components/image";
1+
import type { PropsWithChildren } from "react";
2+
import { Image, type ImageProps } from "~/components/image";
43
import { VStack } from "~/components/stack";
54

65
import styles from "./styles.module.scss";
@@ -13,7 +12,6 @@ export function ImageWithNote({
1312
}: PropsWithChildren<Props>) {
1413
return (
1514
<VStack>
16-
{/* eslint-disable-next-line jsx-a11y/alt-text */}
1715
<Image {...props} />
1816

1917
<div className={styles.note}>{children}</div>

components/mdx-loader/components/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { MDXRemoteProps } from "next-mdx-remote/rsc";
1+
import type { MDXRemoteProps } from "next-mdx-remote/rsc";
22

33
import { Image } from "~/components/image";
44

components/mdx-loader/components/link.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import NextLink from "next/link";
2-
import { HTMLAttributes } from "react";
2+
import type { HTMLAttributes } from "react";
33

44
type Props = HTMLAttributes<HTMLAnchorElement> & {
55
href?: string;

components/mdx-loader/components/mastodon-embed.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export function MastodonEmbed({ url }: Props) {
1313
border: "none",
1414
}}
1515
allowFullScreen
16+
title="Mastodon embed"
1617
/>
1718
);
1819
}

components/navigation/components/command/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ import "./global.scss";
55
import { Command } from "cmdk";
66
import { useRouter } from "next/navigation";
77
import {
8-
FC,
8+
type FC,
99
Fragment,
10-
KeyboardEvent,
10+
type KeyboardEvent,
1111
useCallback,
1212
useDeferredValue,
1313
useEffect,
1414
useRef,
1515
useState,
1616
} from "react";
1717

18-
import { ArticleSearch } from "~/utils/type";
18+
import type { ArticleSearch } from "~/utils/type";
1919

2020
import styles from "./styles.module.scss";
2121

components/navigation/components/link/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import NextLink from "next/link";
2-
import { FC, PropsWithChildren } from "react";
2+
import type { FC, PropsWithChildren } from "react";
33

44
import styles from "./styles.module.scss";
55

components/navigation/hooks/use-cmdk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Dispatch, SetStateAction, useEffect } from "react";
1+
import { type Dispatch, type SetStateAction, useEffect } from "react";
22

33
type Action = Dispatch<SetStateAction<boolean>>;
44

components/navigation/index.tsx

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

33
import NextLink from "next/link";
4-
import { FC, Fragment, useCallback, useState } from "react";
4+
import { type FC, Fragment, useCallback, useState } from "react";
55
import { Command } from "react-feather";
66

77
import { HStack } from "~/components/stack";
@@ -89,6 +89,7 @@ export const Navigation: FC<Props> = ({ currentPage }) => {
8989
className={styles.command_button}
9090
onClick={() => setIsCmdOpened((prev) => !prev)}
9191
aria-label="Command"
92+
type="button"
9293
>
9394
<Command size={22} />
9495
</button>

components/stack/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Property } from "csstype";
2-
import { FC, HTMLAttributes, PropsWithChildren } from "react";
2+
import type { FC, HTMLAttributes, PropsWithChildren } from "react";
33

44
import styles from "./styles.module.scss";
55

lib/article-finder-service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { readdir } from "fs/promises";
2-
import path from "path";
1+
import { readdir } from "node:fs/promises";
2+
import path from "node:path";
33

4-
import { ArticleType } from "~/utils/constants";
5-
import { ArticleDetails } from "~/utils/type";
4+
import type { ArticleType } from "~/utils/constants";
5+
import type { ArticleDetails } from "~/utils/type";
66

77
import { ArticleServiceV2 } from "./article-service-v2";
88

lib/article-service-v2.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { readFile } from "fs/promises";
1+
import { readFile } from "node:fs/promises";
2+
import path from "node:path";
23
import matter from "gray-matter";
3-
import path from "path";
44
import RemoveMarkdown from "remove-markdown";
55

6-
import { ArticleType } from "~/utils/constants";
7-
import { ArticleDetails, OGImageDataArticle } from "~/utils/type";
6+
import type { ArticleType } from "~/utils/constants";
7+
import type { ArticleDetails, OGImageDataArticle } from "~/utils/type";
88

99
import { signature } from "./crypto/node";
1010
import { encode } from "./encoder";
@@ -89,9 +89,8 @@ export class ArticleServiceV2 {
8989
const trimmed = text.trim();
9090
if (!length || trimmed.length < length) {
9191
return trimmed;
92-
} else {
93-
return trimmed.slice(0, length).trim() + "...";
9492
}
93+
return `${trimmed.slice(0, length).trim()}...`;
9594
}
9695

9796
private async getFallbackCoverImageUrl(data: OGImageDataArticle) {

lib/cache-service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { mkdir, readFile, writeFile } from "fs/promises";
2-
import path from "path";
1+
import { mkdir, readFile, writeFile } from "node:fs/promises";
2+
import path from "node:path";
33
import sanitize from "sanitize-filename";
44

55
const cacheDir = path.resolve(process.cwd(), ".nzws-cache");

lib/crypto/browser.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ const key = crypto.subtle.importKey(
1010
);
1111

1212
export const signature = async (data: string): Promise<string> =>
13-
(
14-
crypto.subtle.sign(
15-
"HMAC",
16-
await key,
17-
new TextEncoder().encode(data),
18-
) as Promise<Uint8Array>
19-
).then(binaryToString);
13+
crypto.subtle
14+
.sign("HMAC", await key, new TextEncoder().encode(data))
15+
.then(binaryToString);

lib/crypto/node.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import crypto from "crypto";
1+
import crypto from "node:crypto";
22

33
import { binaryToString } from "../encoder";
44
import { secret } from "./secret";
@@ -12,10 +12,6 @@ const key = crypto.webcrypto.subtle.importKey(
1212
);
1313

1414
export const signature = async (data: string): Promise<string> =>
15-
(
16-
crypto.webcrypto.subtle.sign(
17-
"HMAC",
18-
await key,
19-
new TextEncoder().encode(data),
20-
) as Promise<Uint8Array>
21-
).then(binaryToString);
15+
crypto.webcrypto.subtle
16+
.sign("HMAC", await key, new TextEncoder().encode(data))
17+
.then(binaryToString);

lib/encoder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
encode as encodeBase64,
88
} from "universal-base64url";
99

10-
export const binaryToString = (data: Uint8Array) => {
10+
export const binaryToString = (data: ArrayBuffer | Uint8Array) => {
1111
const arr = new Uint8Array(data);
1212
const result = [];
1313
for (let i = 0; i < arr.length; i++) {
@@ -20,7 +20,7 @@ export const binaryToString = (data: Uint8Array) => {
2020
export const stringToBinary = (data: string) => {
2121
const arr = new Uint8Array(data.length / 2);
2222
for (let i = 0; i < arr.length; i++) {
23-
arr[i] = parseInt(data.slice(i * 2, i * 2 + 2), 16);
23+
arr[i] = Number.parseInt(data.slice(i * 2, i * 2 + 2), 16);
2424
}
2525

2626
return arr;

lib/file-io.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import "server-only";
22

3-
import path from "path";
3+
import path from "node:path";
44
import { getPlaiceholder } from "plaiceholder";
55
import { cache } from "react";
66

7-
import { ArticleType } from "~/utils/constants";
8-
import { ImageDetails } from "~/utils/type";
7+
import type { ArticleType } from "~/utils/constants";
8+
import type { ImageDetails } from "~/utils/type";
99

1010
import { ArticleFinderService } from "./article-finder-service";
1111
import { ArticleServiceV2 } from "./article-service-v2";

middleware.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NextRequest, NextResponse } from "next/server";
1+
import { type NextRequest, NextResponse } from "next/server";
22

33
const blocklist: string[] = ["got (https://github.com/sindresorhus/got)"];
44

next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
/// <reference types="next/image-types/global" />
33

44
// NOTE: This file should not be edited
5-
// see https://nextjs.org/docs/basic-features/typescript for more information.
5+
// see https://nextjs.org/docs/app/building-your-application/configuring/typescript for more information.

0 commit comments

Comments
 (0)