Skip to content

Commit 7dd19c2

Browse files
authored
Merge pull request #90 from KeeghanM/linting-errors
Downgrade esLint and fixed errors
2 parents 904e8f4 + fa5b2af commit 7dd19c2

15 files changed

+62
-63
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,6 @@ yarn-error.log*
4747
.sentryclirc
4848

4949
# Sentry Config File
50-
.sentryclirc
50+
.sentryclirc
51+
# Sentry Config File
52+
.env.sentry-build-plugin

next.config.js

+27-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
// Next.js configuration
12
import { withSentryConfig } from '@sentry/nextjs'
23

3-
// Next.js configuration
44
/**
55
* @type {import('next').NextConfig}
66
*/
@@ -31,22 +31,39 @@ const nextConfig = {
3131
],
3232
}
3333

34-
// Sentry configuration options
35-
const sentryWebpackPluginOptions = {
34+
const config = withSentryConfig(nextConfig, {
35+
// For all available options, see:
36+
// https://github.com/getsentry/sentry-webpack-plugin#options
37+
3638
org: 'chesstraining',
3739
project: 'chesstrainingapp',
38-
// Suppresses source map uploading logs during build
39-
silent: true,
40+
41+
// Only print logs for uploading source maps in CI
42+
silent: !process.env.CI,
43+
44+
// For all available options, see:
45+
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
46+
4047
// Upload a larger set of source maps for prettier stack traces (increases build time)
4148
widenClientFileUpload: true,
49+
50+
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
51+
// This can increase your server load as well as your hosting bill.
52+
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
53+
// side errors will fail.
54+
tunnelRoute: '/monitoring',
55+
4256
// Hides source maps from generated client bundles
43-
hideSourceMaps: false,
57+
hideSourceMaps: true,
58+
4459
// Automatically tree-shake Sentry logger statements to reduce bundle size
4560
disableLogger: true,
46-
// Enables automatic instrumentation of Vercel Cron Monitors.
61+
62+
// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
63+
// See the following for more information:
64+
// https://docs.sentry.io/product/crons/
65+
// https://vercel.com/docs/cron-jobs
4766
automaticVercelMonitors: true,
48-
}
67+
})
4968

50-
// Wrap your config with Sentry's configuration
51-
const config = withSentryConfig(nextConfig, sentryWebpackPluginOptions)
5269
export default config

package.json

+5-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "chess-trainer-2",
3-
"version": "0.1.0",
2+
"name": "chesstraining-app",
3+
"version": "2.0.0",
44
"private": true,
55
"type": "module",
66
"scripts": {
@@ -21,7 +21,6 @@
2121
"@formkit/auto-animate": "^0.8.2",
2222
"@frigade/react": "^2.4.6",
2323
"@kinde-oss/kinde-auth-nextjs": "^2.3.4",
24-
"@million/lint": "^1.0.0-rc.76",
2524
"@mliebelt/pgn-parser": "^1.4.15",
2625
"@prisma/client": "^5.16.2",
2726
"@prismicio/client": "^7.6.0",
@@ -36,7 +35,6 @@
3635
"@uidotdev/usehooks": "^2.4.1",
3736
"chess.js": "^1.0.0-beta.8",
3837
"javascript-time-ago": "^2.5.10",
39-
"million": "^3.1.11",
4038
"next": "^14.2.5",
4139
"next-themes": "^0.3.0",
4240
"nodemailer": "^6.9.14",
@@ -65,18 +63,17 @@
6563
"@types/react-dom": "^18.3.0",
6664
"@types/react-toggle": "^4.0.5",
6765
"@types/uuid": "^10.0.0",
68-
"@typescript-eslint/eslint-plugin": "^7.16.0",
69-
"@typescript-eslint/parser": "^7.16.0",
7066
"autoprefixer": "^10.4.19",
71-
"eslint": "^9.7.0",
67+
"eslint": "^8.57.0",
7268
"postcss": "^8.4.39",
7369
"prettier": "^3.3.2",
7470
"prettier-plugin-tailwindcss": "^0.6.5",
7571
"prisma": "^5.16.2",
7672
"slice-machine-ui": "^2.2.1",
7773
"tailwindcss": "^3.4.4",
7874
"ts-node": "^10.9.2",
79-
"typescript": "^5.5.3"
75+
"typescript": "^5.5.3",
76+
"typescript-eslint": "7.16.1"
8077
},
8178
"ct3aMetadata": {
8279
"initVersion": "7.24.0"

sentry.client.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Sentry.init({
2020

2121
// You can remove this option if you're not planning to use the Sentry Session Replay feature:
2222
integrations: [
23-
new Sentry.Replay({
23+
Sentry.replayIntegration({
2424
// Additional Replay configuration goes in here, for example:
2525
maskAllText: true,
2626
blockAllMedia: true,

src/app/_util/isFlagEnabledServer.tsx

-20
This file was deleted.

src/app/_util/trackEventOnServer.ts

-1
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,4 @@ export async function trackEventOnServer(
3939

4040
posthog.capture(captureData)
4141
}
42-
await posthog.shutdownAsync()
4342
}

src/app/components/training/courses/CourseTrainer.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import type { Move as ChessMove } from 'chess.js'
1414
import type { Arrow } from 'react-chessboard/dist/chessboard/types'
1515
import Toggle from 'react-toggle'
1616
import 'react-toggle/style.css'
17-
// @ts-expect-error - No types available
1817
import useSound from 'use-sound'
1918
import type { ResponseJson } from '~/app/api/responses'
2019
import type { PrismaUserLine } from '~/app/training/courses/[userCourseId]/page'
@@ -57,7 +56,7 @@ export default function CourseTrainer(props: {
5756
.filter((comment) => comment != null)
5857
})
5958
.flat()
60-
.filter((comment) => comment != null) as Comment[],
59+
.filter((comment) => comment != null),
6160
)
6261
const [currentLine, setCurrentLine] = useState<PrismaUserLine>()
6362
const [nextLine, setNextLine] = useState<PrismaUserLine | null>(null)
@@ -108,8 +107,8 @@ export default function CourseTrainer(props: {
108107
const [error, setError] = useState('')
109108

110109
// SFX
111-
const [incorrectSound] = useSound('/sfx/incorrect.mp3') as [() => void]
112-
const [correctSound] = useSound('/sfx/correct.mp3') as [() => void]
110+
const [incorrectSound] = useSound('/sfx/incorrect.mp3')
111+
const [correctSound] = useSound('/sfx/correct.mp3')
113112

114113
const getNextLine = (lines: PrismaUserLine[]) => {
115114
// Sorts the lines in order of priority
@@ -680,7 +679,8 @@ export default function CourseTrainer(props: {
680679
const handleKeyPress = (e: KeyboardEvent) => {
681680
if (e.key === ' ') {
682681
e.preventDefault()
683-
if (nextLine && !autoNext) startNextLine()
682+
if (nextLine && !autoNext)
683+
startNextLine().catch((e) => Sentry.captureException(e))
684684
if (teaching) resetTeachingMove()
685685
}
686686
}

src/app/components/training/courses/admin/AddLines.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ import trackEventOnClient from '~/app/_util/trackEventOnClient'
1616

1717
import GroupSelector from '../create/GroupSelector'
1818
import PgnToLinesForm from '../create/PgnToLinesForm'
19-
import type { Line } from '../create/parse/ParsePGNtoLineData'
19+
import type { Line, Tags } from '../create/parse/ParsePGNtoLineData'
2020

2121
type FullCourseData = Course & {
22-
lines: (Line & { moves: Move[] })[]
22+
lines: { tags: Tags[]; moves: Move[] }[]
2323
}
2424

2525
export default function AddLines(props: { courseId: string }) {
@@ -84,7 +84,6 @@ export default function AddLines(props: { courseId: string }) {
8484
(line) =>
8585
!existingCourseData.lines.some(
8686
(existingLine) =>
87-
// @ts-expect-error : This is a bug in the types, dunno why it's expecting a CleanMove when the moves is a Move[]
8887
existingLine.moves.map((move) => move.move).join('') ===
8988
line.moves.map((move) => move.notation).join(''),
9089
),

src/app/components/training/courses/create/parse/ParsePGNtoLineData.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface CleanMove {
1010
comment?: string
1111
arrows?: string
1212
}
13-
type Tags = Record<string, string>
13+
export type Tags = Record<string, string>
1414

1515
export interface Line {
1616
tags: Tags

src/app/components/training/courses/schedule/ResetButtons.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
import { useState } from 'react'
44

55
import * as AlertDialog from '@radix-ui/react-alert-dialog'
6-
import { ResponseJson } from '~/app/api/responses'
6+
import type { ResponseJson } from '~/app/api/responses'
77

88
import Button from '~/app/components/_elements/button'
9-
import Heading from '~/app/components/_elements/heading'
109
import Spinner from '~/app/components/general/Spinner'
1110

1211
type ResetButtonProps = {

src/app/components/training/endgames/EndgameTrainer.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { Chess } from 'chess.js'
1111
import type { Move } from 'chess.js'
1212
import Toggle from 'react-toggle'
1313
import 'react-toggle/style.css'
14-
// @ts-expect-error - No types available
1514
import useSound from 'use-sound'
1615
import type { ResponseJson } from '~/app/api/responses'
1716

src/app/components/training/recall/RecallTrainer.tsx

+5-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import type { Color, PieceSymbol, Square } from 'chess.js'
1212
import { Chessboard } from 'react-chessboard'
1313
import 'react-toggle/style.css'
1414
import 'tippy.js/dist/tippy.css'
15-
// @ts-expect-error - No types available
1615
import useSound from 'use-sound'
1716
import type { ResponseJson } from '~/app/api/responses'
1817

@@ -633,16 +632,16 @@ export default function RecallTrainer() {
633632
<p id="tooltip-3">
634633
Where is a{' '}
635634
<span className="font-bold underline">
636-
{correctSquares[counter]!.color == 'w'
635+
{correctSquares[counter].color == 'w'
637636
? 'White'
638637
: 'Black'}{' '}
639-
{correctSquares[counter]!.type == 'b'
638+
{correctSquares[counter].type == 'b'
640639
? 'Bishop'
641-
: correctSquares[counter]!.type == 'k'
640+
: correctSquares[counter].type == 'k'
642641
? 'King'
643-
: correctSquares[counter]!.type == 'n'
642+
: correctSquares[counter].type == 'n'
644643
? 'Knight'
645-
: correctSquares[counter]!.type == 'q'
644+
: correctSquares[counter].type == 'q'
646645
? 'Queen'
647646
: 'Rook'}
648647
</span>

src/app/components/training/tactics/TacticsTrainer.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import type { Move } from 'chess.js'
1313
import { Chess } from 'chess.js'
1414
import Toggle from 'react-toggle'
1515
import 'react-toggle/style.css'
16-
// @ts-expect-error - No types available
1716
import useSound from 'use-sound'
1817
import type { ResponseJson } from '~/app/api/responses'
1918

@@ -455,7 +454,8 @@ export default function TacticsTrainer(props: {
455454
const handleKeyPress = (e: KeyboardEvent) => {
456455
if (e.key === ' ') {
457456
e.preventDefault()
458-
if (puzzleFinished && puzzleStatus == 'correct') goToNextPuzzle()
457+
if (puzzleFinished && puzzleStatus == 'correct')
458+
goToNextPuzzle().catch((e) => Sentry.captureException(e))
459459
}
460460
}
461461
window.addEventListener('keydown', handleKeyPress)

src/app/components/training/visualisation/VisualisationTrainer.tsx

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { Chessboard } from 'react-chessboard'
1515
import Toggle from 'react-toggle'
1616
import 'react-toggle/style.css'
1717
import 'tippy.js/dist/tippy.css'
18-
// @ts-expect-error - No types available
1918
import useSound from 'use-sound'
2019
import type { ResponseJson } from '~/app/api/responses'
2120

@@ -432,7 +431,7 @@ export default function VisualisationTrainer() {
432431
</div>
433432
<p
434433
onClick={async () => {
435-
await flow.restart()
434+
await flow?.restart()
436435
setMode('settings')
437436
}}
438437
className="cursor-pointer underline hover:no-underline"

src/instrumentation.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export async function register() {
2+
if (process.env.NEXT_RUNTIME === 'nodejs') {
3+
await import('../sentry.server.config');
4+
}
5+
6+
if (process.env.NEXT_RUNTIME === 'edge') {
7+
await import('../sentry.edge.config');
8+
}
9+
}

0 commit comments

Comments
 (0)