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
+27 -27
View File
@@ -1,25 +1,25 @@
type MediaLike = { url?: string | null } | null | undefined
type MediaLike = { url?: null | string } | null | undefined
type ArticleJsonLdArgs = {
/** Article headline (the title). */
headline: string
/** Absolute URL of the article. */
url: string
description?: string
/** Cover/hero image. */
image?: MediaLike
/** ISO date the article was first published, e.g. '2026-01-15'. */
datePublished?: string
/** ISO date of the last modification. Defaults to datePublished. */
dateModified?: string
/** Author name (person or org). */
author?: string
/** Publisher (usually the site/organization) name. */
publisherName?: string
/** ISO date of the last modification. Defaults to datePublished. */
dateModified?: string
/** ISO date the article was first published, e.g. '2026-01-15'. */
datePublished?: string
description?: string
/** Article headline (the title). */
headline: string
/** Cover/hero image. */
image?: MediaLike
/** Publisher logo (for the Article rich result). */
publisherLogo?: MediaLike
/** Publisher (usually the site/organization) name. */
publisherName?: string
/** 'Article' (default), 'BlogPosting', or 'NewsArticle'. */
type?: 'Article' | 'BlogPosting' | 'NewsArticle'
/** Absolute URL of the article. */
url: string
}
/**
@@ -41,39 +41,39 @@ type ArticleJsonLdArgs = {
* and dates for the rich result; supply them from the post's real fields.
*/
export function buildArticleJsonLd({
headline,
url,
description,
image,
datePublished,
dateModified,
author,
publisherName,
publisherLogo,
type = 'Article',
author,
dateModified,
datePublished,
description,
headline,
image,
publisherLogo,
publisherName,
url,
}: ArticleJsonLdArgs) {
const imageUrl = image?.url
const logoUrl = publisherLogo?.url
const abs = (u: string | null | undefined): string | undefined =>
const abs = (u: null | string | undefined): string | undefined =>
u ? (u.startsWith('http') ? u : `${url.split('/').slice(0, 3).join('/')}${u}`) : undefined
return {
'@context': 'https://schema.org',
'@type': type,
headline,
mainEntityOfPage: { '@id': url, '@type': 'WebPage' },
url,
mainEntityOfPage: { '@type': 'WebPage', '@id': url },
...(description ? { description } : {}),
...(imageUrl ? { image: abs(imageUrl) } : {}),
...(datePublished ? { datePublished } : {}),
...(dateModified || datePublished ? { dateModified: dateModified ?? datePublished } : {}),
...(author ? { author: { '@type': 'Person', name: author } } : {}),
...(author ? { author: { name: author, '@type': 'Person' } } : {}),
...(publisherName
? {
publisher: {
'@type': 'Organization',
name: publisherName,
'@type': 'Organization',
...(logoUrl ? { logo: { '@type': 'ImageObject', url: abs(logoUrl) } } : {}),
},
}
+2 -2
View File
@@ -65,8 +65,8 @@ export function buildSitemapXml(
e.lastModified instanceof Date ? e.lastModified.toISOString() : String(e.lastModified)
parts.push(` <lastmod>${esc(iso)}</lastmod>`)
}
if (e.changeFrequency) parts.push(` <changefreq>${e.changeFrequency}</changefreq>`)
if (typeof e.priority === 'number') parts.push(` <priority>${e.priority}</priority>`)
if (e.changeFrequency) {parts.push(` <changefreq>${e.changeFrequency}</changefreq>`)}
if (typeof e.priority === 'number') {parts.push(` <priority>${e.priority}</priority>`)}
const alternates = e.alternates?.languages
if (alternates) {
for (const [lang, href] of Object.entries(alternates)) {
+9 -9
View File
@@ -2,14 +2,14 @@
export type TitleOrder = 'page-first' | 'site-first'
type ComposeTitleArgs = {
/** Page-specific title, e.g. 'About Us'. */
pageTitle?: string | null
/** Site name, e.g. 'Acme Inc'. */
siteName?: string | null
/** Separator between page title and site name. Defaults to ' | '. */
separator?: string
/** Defaults to 'page-first' — the page title is what a visitor scans for. */
order?: TitleOrder
/** Page-specific title, e.g. 'About Us'. */
pageTitle?: null | string
/** Separator between page title and site name. Defaults to ' | '. */
separator?: string
/** Site name, e.g. 'Acme Inc'. */
siteName?: null | string
}
/**
@@ -24,10 +24,10 @@ type ComposeTitleArgs = {
* Pure function — no dependency on Payload or request state.
*/
export function composeTitle({
pageTitle,
siteName,
separator = ' | ',
order = 'page-first',
pageTitle,
separator = ' | ',
siteName,
}: ComposeTitleArgs): string {
const page = pageTitle?.trim()
const site = siteName?.trim()
+1 -1
View File
@@ -20,7 +20,7 @@ type CreateMetadataGeneratorArgs = {
baseUrl?: string
config: I18nConfig
/** Home slug that collapses to the locale root. Defaults to 'home'. */
homeSlug?: string | Record<string, string>
homeSlug?: Record<string, string> | string
/**
* Resolves the document to build metadata for, given route params.
* The client supplies this (they own the collections and routing); it should
+8 -7
View File
@@ -1,20 +1,21 @@
import type { I18nConfig, LocalizedSlugs } from '../i18n/index.js'
import { buildLocalizedPath, getLocaleCodes } from '../i18n/index.js'
type BuildHreflangArgs = {
/** slug per locale for the current document, e.g. { pl: 'o-nas', en: 'about' } */
slugs: LocalizedSlugs
config: I18nConfig
/** Absolute site origin, e.g. 'https://example.com'. Omit for relative paths. */
baseUrl?: string
config: I18nConfig
/** Home slug that collapses to the locale root. Defaults to 'home'. */
homeSlug?: string | Record<string, string>
homeSlug?: Record<string, string> | string
/**
* Localized segment the document lives under (an archive page's slugs),
* e.g. { pl: 'artykuly', en: 'articles' }. Locales missing from the prefix
* are omitted — an entry with no archive in that language has no URL there.
*/
prefix?: LocalizedSlugs
/** slug per locale for the current document, e.g. { pl: 'o-nas', en: 'about' } */
slugs: LocalizedSlugs
}
/**
@@ -34,11 +35,11 @@ type BuildHreflangArgs = {
* // → { pl: 'https://example.com/pl/o-nas', en: 'https://example.com/en/about' }
*/
export function buildHreflangAlternates({
slugs,
config,
baseUrl,
config,
homeSlug = 'home',
prefix,
slugs,
}: BuildHreflangArgs): Record<string, string> {
const origin = baseUrl?.replace(/\/$/, '') ?? ''
const alternates: Record<string, string> = {}
@@ -52,7 +53,7 @@ export function buildHreflangAlternates({
}
for (const locale of getLocaleCodes(config)) {
const path = buildLocalizedPath({ slugs, locale, config, homeSlug, prefix })
const path = buildLocalizedPath({ config, homeSlug, locale, prefix, slugs })
if (path) {
alternates[locale] = `${origin}${path}`
}
+32 -32
View File
@@ -1,41 +1,41 @@
export type { SeoOption, SeoMeta } from './types.js'
export { composeTitle } from './composeTitle.js'
export type { TitleOrder } from './composeTitle.js'
export { buildHreflangAlternates } from './hreflang.js'
export { buildAutoFillMetaHook } from './autoFillMeta.js'
export type { AutoFillMapping } from './autoFillMeta.js'
export { buildArticleJsonLd } from './buildArticleJsonLd.js'
export { buildBreadcrumbJsonLd } from './buildBreadcrumbJsonLd.js'
export { buildFaqJsonLd } from './buildFaqJsonLd.js'
export { buildIconsMetadata } from './buildIconsMetadata.js'
export { buildLlmsTxt } from './buildLlmsTxt.js'
export { buildLocalBusinessJsonLd } from './buildLocalBusinessJsonLd.js'
export { createManifestHandler } from './buildManifest.js'
export { buildMetadata } from './buildMetadata.js'
export type { PageMetadata } from './buildMetadata.js'
export { buildSeoPlugin } from './seoPluginConfig.js'
export { buildAutoFillMetaHook } from './autoFillMeta.js'
export { injectAutoFillMeta } from './injectAutoFillMeta.js'
export { injectSeoTabs } from './injectSeoTabs.js'
export type { AutoFillMapping } from './autoFillMeta.js'
export { createMetadataGenerator } from './createMetadataGenerator.js'
export { createPageMetadata } from './createPageMetadata.js'
export { readSiteMetaConfig } from './readSiteMetaConfig.js'
export type { SiteMetaConfig } from './readSiteMetaConfig.js'
export { slugsAcrossLocales } from './slugsAcrossLocales.js'
export { buildSitemapEntries } from './buildSitemapEntries.js'
export { buildSitemapXml } from './buildSitemapXml.js'
export type { SitemapEntry } from './buildSitemapEntries.js'
export { buildRobots, AI_ASSISTANT_BOTS, AI_TRAINING_BOTS } from './buildRobots.js'
export type { RobotsRules, RobotsOptions } from './buildRobots.js'
export { buildIconsMetadata } from './buildIconsMetadata.js'
export { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js'
export { validateFaviconField } from './validateFavicon.js'
export { buildNoindexField } from './buildNoindexField.js'
export { buildOrganizationJsonLd } from './buildOrganizationJsonLd.js'
export { AI_ASSISTANT_BOTS, AI_TRAINING_BOTS, buildRobots } from './buildRobots.js'
export type { RobotsOptions, RobotsRules } from './buildRobots.js'
export { buildServiceJsonLd } from './buildServiceJsonLd.js'
export { buildSitemapEntries } from './buildSitemapEntries.js'
export type { SitemapEntry } from './buildSitemapEntries.js'
export { buildSitemapXml } from './buildSitemapXml.js'
export { buildSiteNavigationJsonLd } from './buildSiteNavigationJsonLd.js'
export { buildSpeakableJsonLd } from './buildSpeakableJsonLd.js'
export { buildSummaryField } from './buildSummaryField.js'
export { buildWebSiteJsonLd } from './buildWebSiteJsonLd.js'
export { buildBreadcrumbJsonLd } from './buildBreadcrumbJsonLd.js'
export { buildSiteNavigationJsonLd } from './buildSiteNavigationJsonLd.js'
export { buildLocalBusinessJsonLd } from './buildLocalBusinessJsonLd.js'
export { buildFaqJsonLd } from './buildFaqJsonLd.js'
export { buildServiceJsonLd } from './buildServiceJsonLd.js'
export { buildArticleJsonLd } from './buildArticleJsonLd.js'
export { buildLlmsTxt } from './buildLlmsTxt.js'
export { composeTitle } from './composeTitle.js'
export type { TitleOrder } from './composeTitle.js'
export { createMetadataGenerator } from './createMetadataGenerator.js'
export { createPageMetadata } from './createPageMetadata.js'
export { buildHreflangAlternates } from './hreflang.js'
export { injectAutoFillMeta } from './injectAutoFillMeta.js'
export { injectSeoTabs } from './injectSeoTabs.js'
export { JsonLdGraph } from './JsonLdGraph.js'
export { readSiteMetaConfig } from './readSiteMetaConfig.js'
export type { SiteMetaConfig } from './readSiteMetaConfig.js'
export { createLlmsTxtRoute, createSitemapRouteHandler } from './routeHandlers.js'
export type { SitemapRouteOptions } from './routeHandlers.js'
export { buildSitemapCss, SITEMAP_STYLE_PARAM, DEFAULT_SITEMAP_CREDIT } from './sitemapStyle.js'
export { buildSeoPlugin } from './seoPluginConfig.js'
export { buildSitemapCss, DEFAULT_SITEMAP_CREDIT, SITEMAP_STYLE_PARAM } from './sitemapStyle.js'
export type { SitemapStyleOptions } from './sitemapStyle.js'
export { createManifestHandler } from './buildManifest.js'
export { JsonLdGraph } from './JsonLdGraph.js'
export { slugsAcrossLocales } from './slugsAcrossLocales.js'
export type { SeoMeta, SeoOption } from './types.js'
export { validateFaviconField } from './validateFavicon.js'