Skip to content

Commit c181528

Browse files
committed
chore: resolve oxlint warnings
Made-with: Cursor
1 parent 90b7fd1 commit c181528

13 files changed

Lines changed: 59 additions & 92 deletions

File tree

packages/workshop-app/app/routes/og.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,7 @@ async function getOgImg(
135135
width: WIDTH,
136136
height: HEIGHT,
137137
debug: url.searchParams.get('debug') === 'true',
138-
fonts: await Promise.all([
139-
getFont({ font: 'Josefin Sans', request, timings }),
140-
]).then((fonts) => fonts.flat()),
138+
fonts: await getFont({ font: 'Josefin Sans', request, timings }),
141139
loadAdditionalAsset: async (code: string, segment: string) => {
142140
if (code === 'emoji') {
143141
const svg = await getEmoji(segment, { request, timings })

packages/workshop-cli/src/commands/admin/launch-readiness.test.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ import { expect, test, vi } from 'vitest'
77
vi.mock('@epic-web/workshop-utils/compile-mdx.server', async () => {
88
const fs = await import('node:fs/promises')
99
return {
10-
compileMdx: vi.fn(async (file: string) => {
10+
compileMdx: vi.fn<
11+
(file: string) => Promise<{
12+
code: string
13+
title: null
14+
epicVideoEmbeds: Array<string>
15+
}>
16+
>(async (file) => {
1117
const content = await fs.readFile(file, 'utf8').catch(() => '')
1218
const embeds = Array.from(
1319
content.matchAll(/<EpicVideo[^>]*\burl=["']([^"']+)["'][^>]*\/?>/g),
@@ -194,7 +200,7 @@ test('remote lesson check fails when product lesson slug not represented locally
194200

195201
vi.stubGlobal(
196202
'fetch',
197-
vi.fn(async () => {
203+
vi.fn<typeof fetch>(async () => {
198204
return new Response(
199205
JSON.stringify({
200206
resources: [
@@ -257,7 +263,7 @@ test('warns about extra embeds only for configured workshop (includes offending
257263

258264
vi.stubGlobal(
259265
'fetch',
260-
vi.fn(async () => {
266+
vi.fn<typeof fetch>(async () => {
261267
return new Response(
262268
JSON.stringify({
263269
resources: [
@@ -319,7 +325,7 @@ test('fails when an EpicVideo url does not return 200 to HEAD', async () => {
319325

320326
vi.stubGlobal(
321327
'fetch',
322-
vi.fn(async (input: any, init?: any) => {
328+
vi.fn<typeof fetch>(async (input, init) => {
323329
const url = typeof input === 'string' ? input : String(input)
324330
if (init?.method === 'HEAD' && url.includes('step-problem')) {
325331
return new Response(null, { status: 404, statusText: 'Not Found' })
@@ -349,7 +355,7 @@ test('accepts /tutorials embed paths and reports tutorial urls in remote mismatc
349355

350356
vi.stubGlobal(
351357
'fetch',
352-
vi.fn(async () => {
358+
vi.fn<typeof fetch>(async () => {
353359
return new Response(
354360
JSON.stringify({
355361
moduleType: 'tutorial',

packages/workshop-cli/src/commands/cleanup.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ test('cleanup removes caches and deletes data file when empty', async () => {
4444
})
4545

4646
expect(result.success).toBe(true)
47-
await expect(stat(cacheDir)).rejects.toThrow()
48-
await expect(stat(legacyCacheDir)).rejects.toThrow()
49-
await expect(stat(dataPath)).rejects.toThrow()
47+
await expect(stat(cacheDir)).rejects.toThrow('ENOENT')
48+
await expect(stat(legacyCacheDir)).rejects.toThrow('ENOENT')
49+
await expect(stat(dataPath)).rejects.toThrow('ENOENT')
5050
} finally {
5151
await rm(root, { recursive: true, force: true })
5252
}
@@ -79,7 +79,7 @@ test('cleanup removes CLI config file', async () => {
7979
})
8080

8181
expect(result.success).toBe(true)
82-
await expect(stat(configPath)).rejects.toThrow()
82+
await expect(stat(configPath)).rejects.toThrow('ENOENT')
8383
} finally {
8484
await rm(root, { recursive: true, force: true })
8585
}
@@ -117,7 +117,7 @@ test('cleanup removes workshops but keeps non-workshop entries', async () => {
117117
})
118118

119119
expect(result.success).toBe(true)
120-
await expect(stat(workshopDir)).rejects.toThrow()
120+
await expect(stat(workshopDir)).rejects.toThrow('ENOENT')
121121

122122
const remaining = await readdir(reposDir)
123123
expect(remaining).toContain('notes')
@@ -161,7 +161,7 @@ test('cleanup removes offline videos directory', async () => {
161161
})
162162

163163
expect(result.success).toBe(true)
164-
await expect(stat(offlineVideosDir)).rejects.toThrow()
164+
await expect(stat(offlineVideosDir)).rejects.toThrow('ENOENT')
165165
} finally {
166166
await rm(root, { recursive: true, force: true })
167167
}
@@ -236,7 +236,7 @@ test('cleanup defaults to current workshop when run inside one', async () => {
236236
})
237237

238238
expect(result.success).toBe(true)
239-
await expect(stat(workshopACache)).rejects.toThrow()
239+
await expect(stat(workshopACache)).rejects.toThrow('ENOENT')
240240
await expect(stat(workshopBCache)).resolves.toBeDefined()
241241
} finally {
242242
process.chdir(originalCwd)

packages/workshop-cli/src/commands/start.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ async function createRunnerFixture() {
197197
appDir,
198198
runnerPath,
199199
async [Symbol.asyncDispose]() {
200-
await rootDir[Symbol.asyncDispose]()
200+
await rm(rootDir.path, { recursive: true, force: true })
201201
},
202202
}
203203
}

packages/workshop-cli/src/commands/update.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { update } from './update.ts'
33

44
// Mock the dynamic import of updateLocalRepo
55
vi.mock('@epic-web/workshop-utils/git.server', () => ({
6-
updateLocalRepo: vi.fn(),
6+
updateLocalRepo: vi.fn<() => unknown>(),
77
}))
88

99
function setEnv(key: string, value: string | undefined) {

packages/workshop-cli/src/commands/warm.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,5 @@ test('warm function should handle errors gracefully', async () => {
7777
)
7878

7979
const result = await resultPromise
80-
if (!result.success) {
81-
expect(result.error).toBeInstanceOf(Error)
82-
}
80+
expect(result.success || result.error instanceof Error).toBe(true)
8381
})

packages/workshop-cli/src/commands/workshops.test.ts

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,26 @@ import path from 'node:path'
44
import { expect, test, vi } from 'vitest'
55

66
vi.mock('execa', () => ({
7-
execa: vi.fn(),
7+
execa: vi.fn<(...args: Array<unknown>) => unknown>(),
88
}))
99

1010
vi.mock('./setup.js', () => ({
11-
setup: vi.fn(async () => ({ success: true })),
11+
setup: vi.fn<() => Promise<{ success: boolean }>>(async () => ({
12+
success: true,
13+
})),
1214
}))
1315

1416
vi.mock('@epic-web/workshop-utils/workshops.server', () => ({
15-
getDefaultReposDir: vi.fn(() => '/tmp/epicshop-workshops'),
16-
getReposDirectory: vi.fn(() => '/tmp/epicshop-workshops'),
17-
getWorkshop: vi.fn(),
18-
isReposDirectoryConfigured: vi.fn(async () => true),
19-
listWorkshops: vi.fn(async () => []),
20-
setReposDirectory: vi.fn(async () => {}),
21-
workshopExists: vi.fn(async () => false),
22-
verifyReposDirectory: vi.fn(async () => ({ accessible: true })),
17+
getDefaultReposDir: vi.fn<() => string>(() => '/tmp/epicshop-workshops'),
18+
getReposDirectory: vi.fn<() => string>(() => '/tmp/epicshop-workshops'),
19+
getWorkshop: vi.fn<() => unknown>(),
20+
isReposDirectoryConfigured: vi.fn<() => Promise<boolean>>(async () => true),
21+
listWorkshops: vi.fn<() => Promise<Array<unknown>>>(async () => []),
22+
setReposDirectory: vi.fn<() => Promise<void>>(async () => {}),
23+
workshopExists: vi.fn<() => Promise<boolean>>(async () => false),
24+
verifyReposDirectory: vi.fn<() => Promise<{ accessible: boolean }>>(
25+
async () => ({ accessible: true }),
26+
),
2327
}))
2428

2529
const { execa } = await import('execa')

packages/workshop-cli/src/commands/workshops.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ async function fetchWorkshopPackageJson(
339339
ttl: 1000 * 60 * 60 * 6, // 6 hours
340340
swr: 1000 * 60 * 60 * 24 * 30, // 30 days stale-while-revalidate
341341
checkValue: PackageJsonSchema.nullable(),
342-
async getFreshValue(context) {
342+
async getFreshValue(_context) {
343343
const rawHeaders = getGitHubHeadersWithAccept(
344344
'application/vnd.github.raw',
345345
)

packages/workshop-mcp/src/utils.test.ts

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import {
88
} from './utils.ts'
99

1010
vi.mock('@epic-web/workshop-utils/apps.server', () => ({
11-
getWorkshopRoot: vi.fn(() => '/mock/workshop'),
12-
init: vi.fn(async () => {}),
11+
getWorkshopRoot: vi.fn<() => string>(() => '/mock/workshop'),
12+
init: vi.fn<() => Promise<void>>(async () => {}),
1313
}))
1414

1515
async function createWorkshopFixture() {
@@ -52,10 +52,7 @@ test('workshopDirectoryInputSchema should validate valid string', () => {
5252
const validInput = '/path/to/workshop'
5353
const result = workshopDirectoryInputSchema.safeParse(validInput)
5454

55-
expect(result.success).toBe(true)
56-
if (result.success) {
57-
expect(result.data).toBe(validInput)
58-
}
55+
expect(result).toEqual({ success: true, data: validInput })
5956
})
6057

6158
test('workshopDirectoryInputSchema should reject non-string input', () => {
@@ -71,20 +68,14 @@ test('workshopDirectoryInputSchema should accept empty string', () => {
7168
const emptyString = ''
7269
const result = workshopDirectoryInputSchema.safeParse(emptyString)
7370

74-
expect(result.success).toBe(true)
75-
if (result.success) {
76-
expect(result.data).toBe(emptyString)
77-
}
71+
expect(result).toEqual({ success: true, data: emptyString })
7872
})
7973

8074
test('workshopDirectoryInputSchema should accept string with spaces', () => {
8175
const inputWithSpaces = ' /path/with/spaces '
8276
const result = workshopDirectoryInputSchema.safeParse(inputWithSpaces)
8377

84-
expect(result.success).toBe(true)
85-
if (result.success) {
86-
expect(result.data).toBe(inputWithSpaces)
87-
}
78+
expect(result).toEqual({ success: true, data: inputWithSpaces })
8879
})
8980

9081
test('workshopDirectoryInputSchema should accept absolute paths', () => {
@@ -96,10 +87,7 @@ test('workshopDirectoryInputSchema should accept absolute paths', () => {
9687

9788
absolutePaths.forEach((path) => {
9889
const result = workshopDirectoryInputSchema.safeParse(path)
99-
expect(result.success).toBe(true)
100-
if (result.success) {
101-
expect(result.data).toBe(path)
102-
}
90+
expect(result).toEqual({ success: true, data: path })
10391
})
10492
})
10593

@@ -113,10 +101,7 @@ test('workshopDirectoryInputSchema should accept relative paths', () => {
113101

114102
relativePaths.forEach((path) => {
115103
const result = workshopDirectoryInputSchema.safeParse(path)
116-
expect(result.success).toBe(true)
117-
if (result.success) {
118-
expect(result.data).toBe(path)
119-
}
104+
expect(result).toEqual({ success: true, data: path })
120105
})
121106
})
122107

packages/workshop-presence/src/presence.test.ts

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ test('UserSchema should validate a valid user object', () => {
2626
}
2727

2828
const result = UserSchema.safeParse(validUser)
29-
expect(result.success).toBe(true)
30-
if (result.success) {
31-
expect(result.data).toEqual(validUser)
32-
}
29+
expect(result).toEqual({ success: true, data: validUser })
3330
})
3431

3532
test('UserSchema should validate minimal user object', () => {
@@ -38,10 +35,7 @@ test('UserSchema should validate minimal user object', () => {
3835
}
3936

4037
const result = UserSchema.safeParse(minimalUser)
41-
expect(result.success).toBe(true)
42-
if (result.success) {
43-
expect(result.data).toEqual(minimalUser)
44-
}
38+
expect(result).toEqual({ success: true, data: minimalUser })
4539
})
4640

4741
test('UserSchema should reject user without id', () => {
@@ -65,10 +59,7 @@ test('MessageSchema should validate add-user message', () => {
6559
}
6660

6761
const result = MessageSchema.safeParse(addUserMessage)
68-
expect(result.success).toBe(true)
69-
if (result.success) {
70-
expect(result.data).toEqual(addUserMessage)
71-
}
62+
expect(result).toEqual({ success: true, data: addUserMessage })
7263
})
7364

7465
test('MessageSchema should validate remove-user message', () => {
@@ -80,10 +71,7 @@ test('MessageSchema should validate remove-user message', () => {
8071
}
8172

8273
const result = MessageSchema.safeParse(removeUserMessage)
83-
expect(result.success).toBe(true)
84-
if (result.success) {
85-
expect(result.data).toEqual(removeUserMessage)
86-
}
74+
expect(result).toEqual({ success: true, data: removeUserMessage })
8775
})
8876

8977
test('MessageSchema should validate presence message', () => {
@@ -98,10 +86,7 @@ test('MessageSchema should validate presence message', () => {
9886
}
9987

10088
const result = MessageSchema.safeParse(presenceMessage)
101-
expect(result.success).toBe(true)
102-
if (result.success) {
103-
expect(result.data).toEqual(presenceMessage)
104-
}
89+
expect(result).toEqual({ success: true, data: presenceMessage })
10590
})
10691

10792
test('MessageSchema should reject invalid message type', () => {
@@ -123,10 +108,7 @@ test('PresenceSchema should validate presence object', () => {
123108
}
124109

125110
const result = PresenceSchema.safeParse(presence)
126-
expect(result.success).toBe(true)
127-
if (result.success) {
128-
expect(result.data).toEqual(presence)
129-
}
111+
expect(result).toEqual({ success: true, data: presence })
130112
})
131113

132114
test('PresenceSchema should validate empty users array', () => {
@@ -135,10 +117,7 @@ test('PresenceSchema should validate empty users array', () => {
135117
}
136118

137119
const result = PresenceSchema.safeParse(presence)
138-
expect(result.success).toBe(true)
139-
if (result.success) {
140-
expect(result.data).toEqual(presence)
141-
}
120+
expect(result).toEqual({ success: true, data: presence })
142121
})
143122

144123
test('User type should be correctly inferred', () => {

0 commit comments

Comments
 (0)