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
+18 -4
View File
@@ -1,17 +1,20 @@
import { describe, expect, test } from 'vitest'
import type { I18nConfig } from '../src/modules/i18n/types.js'
import { isHoneypotTripped } from '../src/modules/forms/honeypot.js'
import { isEmail } from '../src/modules/forms/validators.js'
import { buildLocalizedPath, switchLocalePath } from '../src/modules/i18n/localizedPath.js'
import { matchAcceptLanguage, negotiateLocale } from '../src/modules/i18n/negotiateLocale.js'
import { isHoneypotTripped } from '../src/modules/forms/honeypot.js'
const config = {
const config: I18nConfig = {
defaultLocale: 'pl',
locales: [
{ code: 'pl', label: 'Polski' },
{ code: 'en', label: 'English' },
],
}
const single = { defaultLocale: 'pl', locales: [{ code: 'pl', label: 'Polski' }] }
const single: I18nConfig = { defaultLocale: 'pl', locales: [{ code: 'pl', label: 'Polski' }] }
describe('negotiateLocale', () => {
test('cookie → Accept-Language → default', () => {
@@ -58,7 +61,7 @@ describe('buildLocalizedPath', () => {
describe('switchLocalePath', () => {
test('never dead-ends: falls back to archive, then locale root', () => {
expect(switchLocalePath({ config, slugs: { pl: 'post' }, targetLocale: 'en', prefix: { en: 'articles', pl: 'artykuly' } })).toBe(
expect(switchLocalePath({ config, prefix: { en: 'articles', pl: 'artykuly' }, slugs: { pl: 'post' }, targetLocale: 'en' })).toBe(
'/en/articles',
)
expect(switchLocalePath({ config, slugs: { pl: 'o-nas' }, targetLocale: 'en' })).toBe('/en')
@@ -72,3 +75,14 @@ describe('honeypot', () => {
expect(isHoneypotTripped({})).toBe(false)
})
})
describe('isEmail', () => {
test('accepts real addresses, rejects malformed ones', () => {
for (const ok of ['[email protected]', '[email protected]', '[email protected]']) {
expect(isEmail(ok)).toBe(true)
}
for (const bad of ['', 'a', 'a@b', 'a [email protected]', 'a@b c.pl', '@b.pl', '[email protected]', 'a@@b.pl']) {
expect(isEmail(bad)).toBe(false)
}
})
})
+3 -1
View File
@@ -2,9 +2,11 @@ import type { Config } from 'payload'
import { describe, expect, test, vi } from 'vitest'
import type { I18nConfig } from '../src/modules/i18n/types.js'
import { ipalKit } from '../src/plugin.js'
const i18n = {
const i18n: I18nConfig = {
defaultLocale: 'pl',
locales: [
{ code: 'pl', label: 'Polski' },
+1 -1
View File
@@ -14,7 +14,7 @@ const forms = {
],
},
}
const data = { consent: true, name: 'Ala' }
const data = { name: 'Ala', consent: true }
const keys = { turnstileSecretKey: 'secret', turnstileSiteKey: 'site' }
let ipCounter = 0
+11
View File
@@ -0,0 +1,11 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"composite": false,
"incremental": false,
"noEmit": true,
"emitDeclarationOnly": false,
"rootDir": ".."
},
"include": ["./**/*.ts", "../src/**/*.ts", "../src/**/*.tsx"]
}