Skip to content

Commit b02e424

Browse files
committed
fix eslint config
1 parent 3d9abe3 commit b02e424

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

eslint.config.mjs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import { FlatCompat } from '@eslint/eslintrc';
1+
import { defineConfig, globalIgnores } from 'eslint/config';
2+
import nextVitals from 'eslint-config-next/core-web-vitals';
3+
import typescript from 'eslint-config-next/typescript';
4+
import prettier from 'eslint-config-prettier';
25

3-
const compat = new FlatCompat({
4-
baseDirectory: import.meta.dirname
5-
});
6-
7-
const eslintConfig = [
8-
...compat.extends('next/core-web-vitals', 'next/typescript', 'prettier'),
9-
{
10-
ignores: [
11-
'node_modules/**',
12-
'.next/**',
13-
'out/**',
14-
'build/**',
15-
'next-env.d.ts'
16-
]
17-
}
18-
];
6+
const eslintConfig = defineConfig([
7+
...nextVitals,
8+
...typescript,
9+
prettier,
10+
// eslint-config-nextのデフォルト無視設定をオーバーライドします。
11+
globalIgnores([
12+
'node_modules/**',
13+
'.next/**',
14+
'out/**',
15+
'build/**',
16+
'next-env.d.ts'
17+
])
18+
]);
1919

2020
export default eslintConfig;

package-lock.json

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/GameBoard.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import {
2020
useRef,
2121
useState,
2222
useImperativeHandle,
23-
type MouseEventHandler
23+
type MouseEventHandler,
24+
useMemo
2425
} from 'react';
2526
import { env } from 'process';
2627

@@ -53,19 +54,16 @@ export const GameBoard = forwardRef(function GameBoard(
5354
ref
5455
) {
5556
const canvasRef = useRef<HTMLCanvasElement>(null);
56-
const [distanceX, setDistanceX] = useState(
57-
(canvasWidth - 2 * paddingX) / (size - 1)
57+
const distanceX = useMemo(
58+
() => (canvasWidth - 2 * paddingX) / (size - 1),
59+
[canvasWidth, paddingX, size]
5860
);
59-
const [distanceY, setDistanceY] = useState(
60-
(canvasHeight - 2 * paddingY) / (size - 1)
61+
const distanceY = useMemo(
62+
() => (canvasHeight - 2 * paddingY) / (size - 1),
63+
[canvasHeight, paddingY, size]
6164
);
6265
const [gameRecord, setGameRecord] = useState<GoData>([]);
6366

64-
useEffect(() => {
65-
setDistanceX((canvasWidth - 2 * paddingX) / (size - 1));
66-
setDistanceY((canvasHeight - 2 * paddingY) / (size - 1));
67-
}, [canvasHeight, canvasWidth, paddingX, paddingY, size]);
68-
6967
const getCtx = (): CanvasRenderingContext2D => {
7068
const canvas: HTMLCanvasElement | null = canvasRef.current;
7169
if (!canvas?.getContext) throw new Error('Something may happen.');

0 commit comments

Comments
 (0)