Skip to content

Commit 4387594

Browse files
committed
chore: upgrade dependencies
1 parent ca07468 commit 4387594

File tree

16 files changed

+2500
-2272
lines changed

16 files changed

+2500
-2272
lines changed

.eslintignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

.eslintrc

Lines changed: 0 additions & 10 deletions
This file was deleted.

eslint.config.mjs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// @ts-check
2+
3+
import jcRules from "eslint-config-jc";
4+
import tseslint from "typescript-eslint";
5+
6+
export default tseslint.config(
7+
...jcRules({
8+
node: true,
9+
react: true,
10+
typescriptTypeCheck: true,
11+
}),
12+
{
13+
ignores: ["node_modules", ".yarn", "dist", "build"],
14+
},
15+
{
16+
languageOptions: {
17+
parserOptions: {
18+
project: true,
19+
},
20+
},
21+
rules: {
22+
"import/no-extraneous-dependencies": "off",
23+
},
24+
},
25+
);

package.json

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,67 +10,68 @@
1010
"build": "vite build --outDir dist/static && vite build --ssr src/server-entry.tsx --outDir dist/server && node --loader=ts-node/esm --no-warnings=ExperimentalWarning server/pre-render.ts",
1111
"preview": "vite preview",
1212
"format": "prettier -w .",
13-
"lint": "eslint \"**/*.{js,ts,jsx,tsx}\"",
13+
"lint": "eslint .",
1414
"spellcheck": "cspell \"**\" --no-progress",
1515
"prepare": "husky install"
1616
},
17-
"packageManager": "yarn@4.0.2",
17+
"packageManager": "yarn@4.1.1",
1818
"devDependencies": {
1919
"@types/color": "^3.0.6",
2020
"@types/express": "^4.17.21",
21-
"@types/node": "^20.10.3",
21+
"@types/node": "^20.12.7",
2222
"@types/prismjs": "^1.26.3",
23-
"@types/react": "^18.2.41",
24-
"@types/react-dom": "^18.2.17",
23+
"@types/react": "^18.2.79",
24+
"@types/react-dom": "^18.2.25",
2525
"@types/react-helmet-async": "^1.0.3",
26-
"@typescript-eslint/eslint-plugin": "^6.13.1",
27-
"@typescript-eslint/parser": "^6.13.1",
28-
"cspell": "^8.1.0",
29-
"eslint": "^8.55.0",
30-
"eslint-config-jc": "^4.2.1",
26+
"@typescript-eslint/eslint-plugin": "^7.7.1",
27+
"@typescript-eslint/parser": "^7.7.1",
28+
"cspell": "^8.7.0",
29+
"eslint": "^8.57.0",
30+
"eslint-config-jc": "^5.1.0",
3131
"eslint-plugin-header": "^3.1.1",
32-
"eslint-plugin-import": "^2.29.0",
32+
"eslint-plugin-import": "^2.29.1",
3333
"eslint-plugin-jsx-a11y": "^6.8.0",
34-
"eslint-plugin-n": "^16.3.1",
35-
"eslint-plugin-react": "^7.33.2",
34+
"eslint-plugin-n": "^17.2.1",
35+
"eslint-plugin-react": "^7.34.1",
3636
"eslint-plugin-react-hooks": "^4.6.0",
37-
"eslint-plugin-regexp": "^2.1.1",
38-
"express": "^4.18.2",
39-
"glob": "^10.3.10",
40-
"husky": "^8.0.3",
41-
"lint-staged": "^15.2.0",
42-
"prettier": "^3.1.0",
37+
"eslint-plugin-regexp": "^2.5.0",
38+
"express": "^4.19.2",
39+
"glob": "^10.3.12",
40+
"husky": "^9.0.11",
41+
"lint-staged": "^15.2.2",
42+
"prettier": "^3.2.5",
4343
"prettier-config-jc": "^2.3.0",
44-
"ts-node": "^10.9.1",
44+
"ts-node": "^10.9.2",
4545
"tsconfig-jc": "^2.3.1",
46-
"typescript": "~5.2.2",
47-
"typescript-plugin-css-modules": "^5.0.2"
46+
"typescript": "~5.4.5",
47+
"typescript-eslint": "^7.7.1",
48+
"typescript-plugin-css-modules": "^5.1.0"
4849
},
4950
"dependencies": {
50-
"@mdx-js/react": "^3.0.0",
51-
"@mdx-js/rollup": "^3.0.0",
52-
"@vitejs/plugin-react": "^4.2.0",
51+
"@mdx-js/react": "^3.0.1",
52+
"@mdx-js/rollup": "^3.0.1",
53+
"@vitejs/plugin-react": "^4.2.1",
5354
"bash-parser": "patch:bash-parser@npm%3A0.5.0#~/.yarn/patches/bash-parser-npm-0.5.0-911330943d.patch",
54-
"clsx": "^2.0.0",
55+
"clsx": "^2.1.1",
5556
"color": "^4.2.3",
5657
"copy-text-to-clipboard": "^3.2.0",
57-
"core-js": "^3.33.3",
58+
"core-js": "^3.37.0",
5859
"github-slugger": "^2.0.0",
59-
"hast-util-to-text": "^4.0.0",
60-
"prism-react-renderer": "^2.3.0",
60+
"hast-util-to-text": "^4.0.2",
61+
"prism-react-renderer": "^2.3.1",
6162
"prismjs": "^1.29.0",
6263
"react": "^18.2.0",
6364
"react-dom": "^18.2.0",
64-
"react-helmet-async": "^1.3.0",
65-
"react-router-dom": "^6.20.1",
66-
"react-tooltip": "^5.24.0",
65+
"react-helmet-async": "^2.0.4",
66+
"react-router-dom": "^6.23.0",
67+
"react-tooltip": "^5.26.3",
6768
"rehype-katex": "^7.0.0",
6869
"remark-frontmatter": "^5.0.0",
6970
"remark-gfm": "^4.0.0",
7071
"remark-math": "^6.0.0",
7172
"remark-mdx-frontmatter": "^4.0.0",
72-
"use-local-storage-state": "^19.1.0",
73-
"vite": "^5.0.4",
73+
"use-local-storage-state": "^19.2.0",
74+
"vite": "^5.2.10",
7475
"vite-plugin-svgr": "^4.2.0"
7576
}
7677
}

server/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import FS from "node:fs";
1+
import FS from "node:fs/promises";
22
import Path from "node:path";
33
import { fileURLToPath } from "node:url";
44
import express from "express";
@@ -34,11 +34,12 @@ export async function createServer(
3434
});
3535
app.use(viteServer.middlewares);
3636

37+
// eslint-disable-next-line @typescript-eslint/no-misused-promises
3738
app.use("*", async (req, res) => {
3839
try {
3940
const url = req.originalUrl;
4041

41-
let template = FS.readFileSync(toAbsolute("../index.html"), "utf-8");
42+
let template = await FS.readFile(toAbsolute("../index.html"), "utf-8");
4243
template = await viteServer.transformIndexHtml(url, template);
4344
const { render } = (await viteServer.ssrLoadModule(
4445
"/src/server-entry.tsx",
@@ -73,7 +74,7 @@ export async function createServer(
7374
return { app };
7475
}
7576

76-
createServer().then(({ app }) =>
77+
void createServer().then(({ app }) =>
7778
app.listen(5173, () => {
7879
console.log("Dev server started on http://localhost:5173");
7980
}),

server/pre-render.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ const promises = routesToPrerender.map(async (url) => {
5656
console.log(e);
5757
}
5858
});
59-
Promise.all(promises);
59+
void Promise.all(promises);

src/Layout/Command/commandHandler.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-return */
12
import type { Dispatch, SetStateAction } from "react";
23
import parseBash from "bash-parser";
34
import { paths } from "@/routes";
@@ -85,8 +86,8 @@ export function handleCommand(
8586
});
8687
if (ast.commands.length !== 1 || ast.commands[0].type !== "Command")
8788
return [1, "The shell only supports single commands at the moment"];
88-
const args = ((ast.commands[0].suffix as any[]) ?? []).filter(
89-
(s: any) => s.type === "Word",
89+
const args = ((ast.commands[0].suffix as any[] | undefined) ?? []).filter(
90+
(s) => s.type === "Word",
9091
);
9192
switch (ast.commands[0].name.text) {
9293
case "cd": {
@@ -102,7 +103,7 @@ export function handleCommand(
102103
return [0, ""];
103104
}
104105
case "echo":
105-
return [0, args.map((a: any) => a.text).join(" ")];
106+
return [0, args.map((a) => a.text).join(" ")];
106107
case "export":
107108
setEnv({
108109
__proto__: null as never,
@@ -125,19 +126,19 @@ export function handleCommand(
125126
const originalConsoleWarn = console.warn;
126127
const originalConsoleError = console.error;
127128
const originalConsoleInfo = console.info;
128-
window.console.log = (...values: any[]) => {
129+
window.console.log = (...values) => {
129130
output += `${values.join(" ")}\n`;
130131
};
131-
window.console.warn = (...values: any[]) => {
132+
window.console.warn = (...values) => {
132133
output += `${values.join(" ")}\n`;
133134
};
134-
window.console.error = (...values: any[]) => {
135+
window.console.error = (...values) => {
135136
output += `${values.join(" ")}\n`;
136137
};
137-
window.console.info = (...values: any[]) => {
138+
window.console.info = (...values) => {
138139
output += `${values.join(" ")}\n`;
139140
};
140-
// eslint-disable-next-line no-eval
141+
// eslint-disable-next-line no-eval, @typescript-eslint/no-unnecessary-condition
141142
const res = eval?.(args[0]?.text ?? "");
142143
window.console.log = originalConsoleLog;
143144
window.console.warn = originalConsoleWarn;
@@ -175,7 +176,7 @@ export function handleCommand(
175176
return ls(args[0]?.text ?? ".", env.PWD!);
176177
case "open":
177178
if (args.length > 1) return [1, "open: too many arguments"];
178-
navigate(new URL(args[0]?.text ?? ".", env.PWD!).pathname);
179+
navigate(new URL(args[0]?.text ?? ".", env.PWD).pathname);
179180
return [0, ""];
180181
case "pwd":
181182
return [0, env.PWD!];

src/components/CodeBlock/index.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Children, type ReactNode } from "react";
22
import clsx from "clsx";
3-
import { Highlight, themes, type Language } from "prism-react-renderer";
3+
import { Highlight, themes } from "prism-react-renderer";
44
import { useColorMode } from "@/context/ColorMode";
55
import CopyButton from "@/components/CopyButton";
66
import styles from "./index.module.css";
@@ -47,10 +47,7 @@ export default function CodeBlock({
4747
)}>
4848
{title && <div className={styles.codeBlockTitle}>{title}</div>}
4949
<div className={styles.codeBlockContent}>
50-
<Highlight
51-
theme={theme}
52-
code={code}
53-
language={(language ?? "text") as Language}>
50+
<Highlight theme={theme} code={code} language={language ?? "text"}>
5451
{({ className, style, tokens, getLineProps, getTokenProps }) => (
5552
<pre
5653
// eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex

src/components/Heading/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function SluggerProvider({
1212
const slugger = useMemo(() => new GithubSlugger(), []);
1313
useEffect(
1414
() => () => {
15-
slugger?.reset();
15+
slugger.reset();
1616
},
1717
[slugger],
1818
);
@@ -30,7 +30,8 @@ function getText(children: ReactNode): string {
3030
if (typeof children === "string") return children;
3131
if (Array.isArray(children))
3232
return children.map(getText).filter(Boolean).join(" ");
33-
if (React.isValidElement(children)) return getText(children.props.children);
33+
if (React.isValidElement(children))
34+
return getText((children.props as { children?: ReactNode }).children);
3435
return "";
3536
}
3637

src/pages/blog/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ const posts = Object.entries(modules).map(
1919
const preview = (
2020
<section>
2121
<Link
22-
href={path
23-
.match(/\.\/(?<name>.*)\.mdx$/u)!
22+
href={/\.\/(?<name>.*)\.mdx$/u
23+
.exec(path)!
2424
.groups!.name!.toLowerCase()
2525
.replace(/index$/u, "")}>
2626
<h2>{frontMatter.title}</h2>

src/pages/notes/random-color.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export default function RandomColor(): JSX.Element {
123123
const p = nextPixel.value;
124124
const [r, g, b] = Object.values(nextRGB.value).map((x) =>
125125
Math.floor(x * 255),
126-
);
126+
) as [number, number, number];
127127
ctx.fillStyle = `rgb(${r}, ${g}, ${b})`;
128128
ctx.fillRect(p.x * scale, p.y * scale, scale, scale);
129129
}

src/pages/tools/color-converter/index.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
import { useState, type ReactNode } from "react";
1+
import { useState, type ReactNode, type ReactElement } from "react";
22
import Color from "color";
33
import Link from "@/components/Link";
44
import CopyButton from "@/components/CopyButton";
55
import styles from "./index.module.css";
66

7-
function Tabs({ children }: { readonly children: JSX.Element[] }) {
7+
function Tabs({
8+
children,
9+
}: {
10+
readonly children: ReactElement<{ label: string }>[];
11+
}) {
812
const [selected, setSelected] = useState(0);
913
return (
1014
<div className={styles.colorInputs}>
@@ -80,7 +84,9 @@ function ColorInput({
8084
...Object.fromEntries(
8185
Array.from({ length: 11 }, (_, i) => [
8286
`--color-${i}`,
83-
(color[method]((max / 10) * i) as Color).rgb().toString(),
87+
color[method]((max / 10) * i)
88+
.rgb()
89+
.toString(),
8490
]),
8591
),
8692
// @ts-expect-error: custom CSS variables
@@ -90,7 +96,7 @@ function ColorInput({
9096
min={min}
9197
max={max}
9298
onInput={(e) => {
93-
setColor(color[method](Number(e.currentTarget.value)) as Color);
99+
setColor(color[method](Number(e.currentTarget.value)));
94100
}}
95101
/>
96102
</label>

src/pages/tools/keyboard-visualizer/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function Keys({
9797
styles.keyUnknown,
9898
key === "Dead" && styles.keyDead,
9999
)}>
100-
{["Dead", "Unidentified"].includes(key as string) ? null : key}
100+
{["Dead", "Unidentified"].includes(key!) ? null : key}
101101
</span>
102102
);
103103
});

src/routes.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React from "react";
2-
import { Helmet } from "react-helmet-async";
2+
import x from "react-helmet-async";
3+
4+
const { Helmet } = x;
35

46
// Auto generates routes from files under ./pages
57
// https://vitejs.dev/guide/features.html#glob-import
@@ -11,7 +13,7 @@ const pages = import.meta.glob<
1113

1214
export const routes = Object.entries(pages)
1315
.map(([path, module]) => {
14-
const name = path.match(/\.\/pages\/(?<name>.*)\.(?:tsx|mdx)$/u)!.groups!
16+
const name = /\.\/pages\/(?<name>.*)\.(?:tsx|mdx)$/u.exec(path)!.groups!
1517
.name!;
1618
return {
1719
path:

src/server-entry.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import React from "react";
22
import { renderToPipeableStream } from "react-dom/server";
33
import { StaticRouter } from "react-router-dom/server";
44
import { Writable } from "node:stream";
5-
import { HelmetProvider, type FilledContext } from "react-helmet-async";
5+
import x, { type HelmetServerState } from "react-helmet-async";
66
import App from "./App";
77
import { SSRContextProvider, type SSRContextValue } from "./context/SSRContext";
88

9+
const { HelmetProvider } = x;
10+
911
// Inspired by https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby/cache-dir/server-utils/writable-as-promise.js
1012
class WritableAsPromise extends Writable {
1113
#output: string;
@@ -34,7 +36,7 @@ class WritableAsPromise extends Writable {
3436
next();
3537
}
3638

37-
override _destroy(error: Error | null, next: (error?: Error | null) => void) {
39+
override _destroy(error: Error | null, next: (err?: Error | null) => void) {
3840
if (error instanceof Error) this.#deferred.reject(error);
3941
else next();
4042
}
@@ -85,7 +87,9 @@ export async function render(
8587
});
8688

8789
const body = await writableStream.getPromise();
88-
const { helmet } = helmetContext as FilledContext;
90+
const { helmet } = helmetContext as {
91+
helmet: HelmetServerState;
92+
};
8993

9094
const htmlAttributes = helmet.htmlAttributes.toString();
9195
const bodyAttributes = helmet.bodyAttributes.toString();

0 commit comments

Comments
 (0)