chore(lint): keep the fixes within the lint ratchets

No promise in a condition, sequential awaits through a reduce instead of a loop, no non-null assertions or any in the new tests, an awaited act, one options object for a stop edit and a handled rejection for the offline copy.
This commit is contained in:
Maurice
2026-11-23 16:09:34 +01:00
parent f6d52727f7
commit 8a9f5367b1
15 changed files with 65 additions and 31 deletions
@@ -29,10 +29,15 @@ describe('HelpGuideView: links', () => {
})
it('takes an admin guide to the tab its settings sit under', () => {
const { unmount } = render(<HelpGuideView guide={getHelpGuide('instance-keys')!} />)
const guideOf = (id: string) => {
const guide = getHelpGuide(id)
if (!guide) throw new Error(`no guide ${id}`)
return guide
}
const { unmount } = render(<HelpGuideView guide={guideOf('instance-keys')} />)
expect(screen.getByRole('link', { name: /^Go to/ })).toHaveAttribute('href', '/admin?tab=services')
unmount()
render(<HelpGuideView guide={getHelpGuide('auth-methods')!} />)
render(<HelpGuideView guide={guideOf('auth-methods')} />)
expect(screen.getByRole('link', { name: /^Go to/ })).toHaveAttribute('href', '/admin?tab=settings')
})
})
+6 -1
View File
@@ -18,6 +18,11 @@ const prefersReducedMotion = (): boolean =>
const stepMedia = (guide: HelpGuide, n: number): string =>
guide.media.clips?.includes(n) && !prefersReducedMotion() ? helpMedia.clip(guide.id, n) : helpMedia.step(guide.id, n)
/** Where a guide's "go to" link leads: its own route, else its screen's. */
function routeOf(guide: HelpGuide, screen: ReturnType<typeof getHelpContext>): string | undefined {
return guide.route ?? screen?.route
}
/**
* One guide, top to bottom: a header card that says where you are and how big
* the task is, the steps as a numbered rail with a picture each, what the
@@ -38,7 +43,7 @@ export default function HelpGuideView({ guide }: { guide: HelpGuide }): React.Re
const related = (guide.related ?? []).map(getHelpGuide).filter((g): g is HelpGuide => g !== null)
const Icon = helpIcon(guide.icon)
const ScreenIcon = screen ? helpIcon(screen.icon) : Icon
const screenRoute = useScreenRoute(guide.route ?? screen?.route)
const screenRoute = useScreenRoute(routeOf(guide, screen))
return (
<div className="trek-help-view flex flex-col gap-6">