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
+6 -2
View File
@@ -1031,9 +1031,13 @@ describe('useAdmin', () => {
await waitFor(() => expect(result.current.admin.isLoading).toBe(false));
expect(result.current.admin.activeTab).toBe('security');
act(() => void result.current.navigate('/admin?tab=services'));
await act(async () => {
await result.current.navigate('/admin?tab=services');
});
expect(result.current.admin.activeTab).toBe('services');
act(() => void result.current.navigate('/admin?tab=settings'));
await act(async () => {
await result.current.navigate('/admin?tab=settings');
});
expect(result.current.admin.activeTab).toBe('security');
act(() => result.current.admin.setActiveTab('audit'));
expect(result.current.admin.activeTab).toBe('audit');
@@ -49,8 +49,12 @@ async function writeEditedStop(
tripId: PlannerBase['tripId'],
assignments: TripStoreState['assignments'],
{ placeId, assignmentId, dwellMinutes: before }: { placeId: number; assignmentId?: number; dwellMinutes?: number },
{ stopType, dwellMinutes }: { stopType: RoadtripStopType | null; dwellMinutes: number },
{ mayEditVisit, refused }: { mayEditVisit: boolean; refused: string },
{
stopType,
dwellMinutes,
mayEditVisit,
refused,
}: { stopType: RoadtripStopType | null; dwellMinutes: number; mayEditVisit: boolean; refused: string },
): Promise<void> {
const visitDayId = savedVisitDayOf(assignments, assignmentId)
if (assignmentId == null || visitDayId === null) {
@@ -101,7 +105,9 @@ export function useRoadtripStopEdits(options: RoadtripStopEditsOptions) {
}
try {
if (stopDraft.editing) {
await writeEditedStop(tripActions, tripId, assignments, stopDraft.editing, { stopType, dwellMinutes }, {
await writeEditedStop(tripActions, tripId, assignments, stopDraft.editing, {
stopType,
dwellMinutes,
mayEditVisit: can('day_edit', trip),
refused: t('trip.journal.errorForbidden'),
})