chore: apply prettier on the entire project

This commit is contained in:
jubnl
2026-05-25 21:59:42 +02:00
parent c130ed41be
commit 6bcdfbc34b
488 changed files with 82986 additions and 45830 deletions
@@ -1,7 +1,8 @@
import { describe, it, expect } from 'vitest';
import { evaluate } from '../../../src/systemNotices/conditions.js';
import type { SystemNotice } from '../../../src/systemNotices/types.js';
import { describe, it, expect } from 'vitest';
const baseNotice: SystemNotice = {
id: 'test',
display: 'modal',
@@ -50,7 +51,10 @@ describe('existingUserBeforeVersion', () => {
describe('dateWindow', () => {
it('passes when now is inside window', () => {
const notice = { ...baseNotice, conditions: [{ kind: 'dateWindow' as const, startsAt: '2026-05-01T00:00:00Z', endsAt: '2026-07-01T00:00:00Z' }] };
const notice = {
...baseNotice,
conditions: [{ kind: 'dateWindow' as const, startsAt: '2026-05-01T00:00:00Z', endsAt: '2026-07-01T00:00:00Z' }],
};
expect(evaluate(notice, baseCtx)).toBe(true);
});
it('fails when now is before start', () => {
@@ -76,10 +80,10 @@ describe('role', () => {
describe('AND logic', () => {
it('requires all conditions to pass', () => {
const notice = { ...baseNotice, conditions: [
{ kind: 'firstLogin' as const },
{ kind: 'role' as const, roles: ['user'] },
]};
const notice = {
...baseNotice,
conditions: [{ kind: 'firstLogin' as const }, { kind: 'role' as const, roles: ['user'] }],
};
// login_count=1 passes firstLogin, role=user passes role → true
expect(evaluate(notice, { ...baseCtx, user: { ...baseCtx.user, login_count: 1 } })).toBe(true);
// login_count=2 fails firstLogin → false
@@ -1,8 +1,9 @@
import { describe, it, expect } from 'vitest';
import { SYSTEM_NOTICES } from '../../../src/systemNotices/registry.js';
import fs from 'node:fs';
import path from 'node:path';
import semver from 'semver';
import { SYSTEM_NOTICES } from '../../../src/systemNotices/registry.js';
import { describe, it, expect } from 'vitest';
/** Collect all actionIds registered via registerNoticeAction() in client source files. */
function collectRegisteredActionIds(): Set<string> {
@@ -13,7 +14,10 @@ function collectRegisteredActionIds(): Set<string> {
const dir = queue.pop()!;
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
const full = path.join(dir, entry.name);
if (entry.isDirectory()) { queue.push(full); continue; }
if (entry.isDirectory()) {
queue.push(full);
continue;
}
if (!entry.name.endsWith('noticeActions.ts') && !entry.name.endsWith('noticeActions.js')) continue;
const src = fs.readFileSync(full, 'utf8');
for (const m of src.matchAll(/registerNoticeAction\(\s*['"]([^'"]+)['"]/g)) {
@@ -26,15 +30,15 @@ function collectRegisteredActionIds(): Set<string> {
describe('registry integrity', () => {
it('has no duplicate ids', () => {
const ids = SYSTEM_NOTICES.map(n => n.id);
const ids = SYSTEM_NOTICES.map((n) => n.id);
expect(new Set(ids).size).toBe(ids.length);
});
it('all action CTAs reference a registered actionId', () => {
const registeredActionIds = collectRegisteredActionIds();
const actionCtaIds = SYSTEM_NOTICES
.filter(n => n.cta?.kind === 'action')
.map(n => (n.cta as { actionId: string }).actionId);
const actionCtaIds = SYSTEM_NOTICES.filter((n) => n.cta?.kind === 'action').map(
(n) => (n.cta as { actionId: string }).actionId,
);
for (const id of actionCtaIds) {
expect(registeredActionIds, `actionId "${id}" not found in any client noticeActions.ts`).toContain(id);
@@ -58,7 +62,7 @@ describe('registry integrity', () => {
if (n.minVersion && n.maxVersion) {
expect(
semver.lte(n.minVersion, n.maxVersion),
`notice "${n.id}": minVersion ${n.minVersion} > maxVersion ${n.maxVersion}`
`notice "${n.id}": minVersion ${n.minVersion} > maxVersion ${n.maxVersion}`,
).toBe(true);
}
}
@@ -1,7 +1,8 @@
import { describe, it, expect } from 'vitest';
import { isNoticeVersionActive } from '../../../src/systemNotices/service.js';
import type { SystemNotice } from '../../../src/systemNotices/types.js';
import { describe, it, expect } from 'vitest';
const base: SystemNotice = {
id: 'test-notice',
display: 'modal',