Lint: fix all ESLint errors (391 -> 0), lint and typecheck tests

Mostly perfectionist import/key sorting and curly braces from --fix, plus:
- spread instead of .apply() in the Meta Pixel stub
- non-capturing group in the locale-code pattern
- React 19 use(Context) / <Context value> in TurnstileProvider
- email regex rewritten without super-linear backtracking (covered by a test)
- console.warn/error allowed (deliberate server diagnostics)
- test/tsconfig.json so the project service and tsc see test files

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-15 23:56:18 +02:00
co-authored by Claude Opus 5.5
parent ce0a390351
commit 4544cac69c
48 changed files with 642 additions and 589 deletions
+11 -10
View File
@@ -1,13 +1,14 @@
import type { PayloadEmailAdapter, SendEmailOptions } from 'payload'
import { type IntegrationStatus, recordIntegrationStatus } from '../integrations/status.js'
import { getSiteIntegrations } from '../payload/index.js'
import { recordIntegrationStatus, type IntegrationStatus } from '../integrations/status.js'
import { panelSmtpAdapter, type PanelSmtpAdapterArgs } from './panelSmtpAdapter.js'
import { graphAdapter, type GraphAdapterArgs } from './graphAdapter.js'
import { panelSmtpAdapter, type PanelSmtpAdapterArgs } from './panelSmtpAdapter.js'
type TransportIntegrations = {
/** 'smtp' | 'graph' — chosen by the editor in SiteIntegrations. */
emailTransport?: 'smtp' | 'graph' | null
emailStatus?: IntegrationStatus | null
/** 'smtp' | 'graph' — chosen by the editor in SiteIntegrations. */
emailTransport?: 'graph' | 'smtp' | null
}
const STATUS_FIELD = 'emailStatus'
@@ -16,10 +17,10 @@ const describe = (err: unknown) =>
(err instanceof Error ? err.message : String(err)).split('\n')[0].slice(0, 200)
export type MailAdapterArgs = {
smtp?: PanelSmtpAdapterArgs
graph?: GraphAdapterArgs
fallbackFromAddress?: string
fallbackFromName?: string
graph?: GraphAdapterArgs
smtp?: PanelSmtpAdapterArgs
}
/** True when the agency Graph credentials are present in the environment. */
@@ -94,21 +95,21 @@ export const mailAdapter =
result = await (useGraph ? graph : smtp).sendEmail(message)
} catch (err) {
await recordIntegrationStatus(payload, STATUS_FIELD, previous, {
state: 'degraded',
code,
message: `${transport}: ${describe(err)}`,
state: 'degraded',
})
throw err // callers (form-builder, Send test) still see the failure
}
// The delegates report failure as { sent: false, error, detail? } instead
// of throwing (a broken mailbox must not crash a form submission).
const failed = result as { sent?: boolean; error?: string; detail?: string } | null
const failed = result as { detail?: string; error?: string; sent?: boolean } | null
if (failed && typeof failed === 'object' && failed.sent === false) {
await recordIntegrationStatus(payload, STATUS_FIELD, previous, {
state: 'degraded',
code,
message: `${transport}: ${describe(failed.detail ?? failed.error ?? 'not sent')}`,
state: 'degraded',
})
return result
}
@@ -120,9 +121,9 @@ export const mailAdapter =
previous,
graphFallback
? {
state: 'degraded',
code: 'graph-unavailable',
message: 'Microsoft Graph is selected but not configured on the server — e-mails are sent over SMTP.',
state: 'degraded',
}
: { state: 'ok' },
)