From 274f7e9fde1ebe2acd11c47416a9c68d9b85365e Mon Sep 17 00:00:00 2001 From: Kjell Kind Date: Mon, 26 Oct 2026 22:03:00 +0100 Subject: [PATCH] chore: clear the lint warnings in tests and commit-thread Co-Authored-By: Claude Opus 5.5 --- resources/js/components/commit-thread.tsx | 2 +- tests/Unit/ConversationSearch.test.ts | 6 ++-- tests/Unit/IssueCommands.test.ts | 6 ++-- tests/Unit/ThreadHistory.test.tsx | 44 ++++++++++++++--------- tests/Unit/ThreadMutationHistory.test.tsx | 44 ++++++++++++++++------- tests/Unit/TranslationLanguages.test.ts | 6 ++-- 6 files changed, 69 insertions(+), 39 deletions(-) diff --git a/resources/js/components/commit-thread.tsx b/resources/js/components/commit-thread.tsx index a3a5d516e..0b5c32eba 100644 --- a/resources/js/components/commit-thread.tsx +++ b/resources/js/components/commit-thread.tsx @@ -85,7 +85,7 @@ import { } from '@/lib/commit'; import { commitStateKey } from '@/lib/commit-state'; import { hasModKey } from '@/lib/keyboard'; -import { exactCountTitle, formatCount, formatExactCount } from '@/lib/numbers'; +import { exactCountTitle, formatCount } from '@/lib/numbers'; import { characterCount, cn, diff --git a/tests/Unit/ConversationSearch.test.ts b/tests/Unit/ConversationSearch.test.ts index 021020213..c0338a95d 100644 --- a/tests/Unit/ConversationSearch.test.ts +++ b/tests/Unit/ConversationSearch.test.ts @@ -15,7 +15,7 @@ const org = (id: string, name: string | null, users: User[]) => const ids = (conversations: ConversationSummary[]) => conversations.map(({ id }) => id); -test('finds loaded conversations by a partner or member handle or name, or an org name, ignoring case', () => { +void test('finds loaded conversations by a partner or member handle or name, or an org name, ignoring case', () => { const loaded = [direct(ana), direct(ben), org('core', 'Core Team', [ana]), org('crew', null, [ben])]; assert.deepEqual(ids(conversationsMatching('ANA', loaded)), ['direct-ana', 'core']); @@ -24,7 +24,7 @@ test('finds loaded conversations by a partner or member handle or name, or an or assert.deepEqual(conversationsMatching('nobody', loaded), []); }); -test('keeps the first matching copy of a conversation found in several lists', () => { +void test('keeps the first matching copy of a conversation found in several lists', () => { const fresh = direct(ana, { ahead: 2 }); const renamed = org('core', 'Core', [ben]); @@ -34,7 +34,7 @@ test('keeps the first matching copy of a conversation found in several lists', ( ]); }); -test('keeps every conversation the server found for the term, ahead of stale copies on hand', () => { +void test('keeps every conversation the server found for the term, ahead of stale copies on hand', () => { const found = [org('core', 'Review Renamed Team', [ben]), direct(ana)]; assert.deepEqual(conversationsMatching('review', [org('core', 'Core', [ben])], found), [...found]); diff --git a/tests/Unit/IssueCommands.test.ts b/tests/Unit/IssueCommands.test.ts index 82f553b67..dcfb9511c 100644 --- a/tests/Unit/IssueCommands.test.ts +++ b/tests/Unit/IssueCommands.test.ts @@ -6,7 +6,7 @@ import { typedCommand, } from '../../resources/js/lib/issue-commands.ts'; -test('suggests commands only while the draft is a slash and the start of a name', () => { +void test('suggests commands only while the draft is a slash and the start of a name', () => { const names = (body: string) => suggestedCommands(body).map((command) => command.name); @@ -19,7 +19,7 @@ test('suggests commands only while the draft is a slash and the start of a name' assert.deepEqual(names(''), []); }); -test('a complete command and a space or new line becomes an issue without the command', () => { +void test('a complete command and a space or new line becomes an issue without the command', () => { assert.deepEqual(typedCommand('/bug '), { kind: 'bug', body: '' }); assert.deepEqual(typedCommand('/feature Dark mode'), { kind: 'feature', @@ -34,7 +34,7 @@ test('a complete command and a space or new line becomes an issue without the co assert.equal(typedCommand('Fixed a /bug today'), null); }); -test('hints the command a plain draft mentions', () => { +void test('hints the command a plain draft mentions', () => { const name = (body: string) => hintedCommand(body)?.name ?? null; assert.equal(name('The search has a bug'), '/bug'); diff --git a/tests/Unit/ThreadHistory.test.tsx b/tests/Unit/ThreadHistory.test.tsx index e56c07774..6eb8b1ee8 100644 --- a/tests/Unit/ThreadHistory.test.tsx +++ b/tests/Unit/ThreadHistory.test.tsx @@ -25,16 +25,22 @@ function restoredThread(saved: unknown, except?: string) { key === `thread:root:${except ?? ''}` ? (saved as never) : undefined, ); let thread: ReturnType | undefined; - function Probe() { - thread = useThread( - { ...reply('root'), replies_count: 18 }, - initial, - false, - except, + function Probe({ + onRender, + }: { + onRender: (rendered: typeof thread) => void; + }) { + onRender( + useThread( + { ...reply('root'), replies_count: 18 }, + initial, + false, + except, + ), ); return null; } - renderToString(); + renderToString( (thread = rendered)} />); assert.ok(thread); return thread; } @@ -72,17 +78,23 @@ test('restores loaded continuation pages and their next cursor', () => { : undefined, ); let result: ReturnType | undefined; - function Probe() { - result = useContinuation({ - data: [], - next_id: 'next', - position: 1, - length: 3, - is_capped: false, - }); + function Probe({ + onRender, + }: { + onRender: (rendered: typeof result) => void; + }) { + onRender( + useContinuation({ + data: [], + next_id: 'next', + position: 1, + length: 3, + is_capped: false, + }), + ); return null; } - renderToString(); + renderToString( (result = rendered)} />); assert.ok(result); assert.deepEqual(result.shown, shown); assert.equal(result.nextId, 'more'); diff --git a/tests/Unit/ThreadMutationHistory.test.tsx b/tests/Unit/ThreadMutationHistory.test.tsx index a54141b6f..033bd686a 100644 --- a/tests/Unit/ThreadMutationHistory.test.tsx +++ b/tests/Unit/ThreadMutationHistory.test.tsx @@ -36,14 +36,24 @@ const reply = (id: string) => ({ id, replies_count: 0, deleted_at: null }) as ThreadCommit; function mount(id: string) { let thread: ReturnType | undefined; - function Probe() { - thread = useThread( - { ...reply(id), replies_count: 5 }, - { data: [reply('one')], next_cursor: 'next', prev_cursor: null }, + function Probe({ + onRender, + }: { + onRender: (rendered: typeof thread) => void; + }) { + onRender( + useThread( + { ...reply(id), replies_count: 5 }, + { + data: [reply('one')], + next_cursor: 'next', + prev_cursor: null, + }, + ), ); return null; } - renderToString(); + renderToString( (thread = rendered)} />); assert.ok(thread); return thread; } @@ -242,21 +252,29 @@ for (const isOpen of [true, false]) { prev_cursor: null, }; let thread: ReturnType | undefined; - function Probe() { + function Probe({ + onRender, + }: { + onRender: (rendered: typeof thread) => void; + }) { const [posted, setPosted] = React.useState(false); - thread = useThread( - { - ...reply(`quoted-${isOpen}-${hasReplies}`), - replies_count: refreshed.data.length, - }, - posted ? refreshed : initial, + onRender( + useThread( + { + ...reply(`quoted-${isOpen}-${hasReplies}`), + replies_count: refreshed.data.length, + }, + posted ? refreshed : initial, + ), ); if (!posted) { setPosted(true); } return null; } - renderToString(); + renderToString( + (thread = rendered)} />, + ); assert.ok(thread); assert.deepEqual( thread.replies?.map((row) => row.id), diff --git a/tests/Unit/TranslationLanguages.test.ts b/tests/Unit/TranslationLanguages.test.ts index 699fc6a5e..5330792d4 100644 --- a/tests/Unit/TranslationLanguages.test.ts +++ b/tests/Unit/TranslationLanguages.test.ts @@ -9,16 +9,16 @@ const languages = [ ]; for (const query of ['Hungarian', 'magyar', ' MAGYAR ', 'hung', 'hu']) { - test(`finds Hungarian by ${JSON.stringify(query)}`, () => { + void test(`finds Hungarian by ${JSON.stringify(query)}`, () => { assert.deepEqual(searchTranslationLanguages(languages, query), [languages[0]]); }); } -test('finds languages in their native script', () => { +void test('finds languages in their native script', () => { assert.deepEqual(searchTranslationLanguages(languages, '日本語'), [languages[1]]); }); -test('returns every language for an empty search and none for an unknown name', () => { +void test('returns every language for an empty search and none for an unknown name', () => { assert.deepEqual(searchTranslationLanguages(languages, ''), languages); assert.deepEqual(searchTranslationLanguages(languages, 'not-a-language'), []); });