diff --git a/biome.json b/biome.json index 6393935..c92b2b4 100644 --- a/biome.json +++ b/biome.json @@ -33,22 +33,32 @@ } }, "linter": { - "domains": { - "test": "all" - }, "enabled": true, "rules": { - "complexity": { - "noExcessiveCognitiveComplexity": "off" - }, + "preset": "all", + "nursery": "on", "correctness": { - "noPrivateImports": "off" + "noNodejsModules": "off", + "useImportExtensions": { + "level": "on", + "options": { + "forceJsExtensions": true + } + }, + "useQwikValidLexicalScope": "off", + "useHookAtTopLevel": "off" }, - "performance": "on", - "security": "on", - "suspicious": "on", "style": { - "useFilenamingConvention": "off" + "useFilenamingConvention": { + "level": "on", + "options": { + "filenameCases": ["camelCase", "PascalCase"] + } + }, + "noContinue": "off" + }, + "security": { + "noSecrets": "off" } } }, @@ -58,5 +68,17 @@ "organizeImports": "on" } } - } + }, + "overrides": [ + { + "includes": ["**/*.test.ts"], + "linter": { + "rules": { + "style": { + "noMagicNumbers": "off" + } + } + } + } + ] } diff --git a/package-lock.json b/package-lock.json index 83864d0..ac5d7d8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,7 @@ "testcontainers": "12.0.3" }, "devDependencies": { - "@biomejs/biome": "2.4.16", + "@biomejs/biome": "2.5.0", "@types/node": "25.9.3", "get-port": "7.2.0", "tsdown": "0.22.3", @@ -95,9 +95,9 @@ "license": "Apache-2.0" }, "node_modules/@biomejs/biome": { - "version": "2.4.16", - "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-2.4.16.tgz", - "integrity": "sha512-x9ajFh1zChVybCiM3TN6OD4phAqLgtPZjFrZF+aTMYCPjwBO+k529TX7PPsAqtGNLeV4UgzwQnowEgS7bGmzcA==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-2.5.0.tgz", + "integrity": "sha512-4kURkd9hAPrdDM3C9n82ycYgx8hvQcW6MjKTEejruj8rK0N8P3OPpdy8BvI8kt3KWY4ycF5XtDOrktetEfhfuw==", "dev": true, "license": "MIT OR Apache-2.0", "bin": { @@ -111,20 +111,20 @@ "url": "https://opencollective.com/biome" }, "optionalDependencies": { - "@biomejs/cli-darwin-arm64": "2.4.16", - "@biomejs/cli-darwin-x64": "2.4.16", - "@biomejs/cli-linux-arm64": "2.4.16", - "@biomejs/cli-linux-arm64-musl": "2.4.16", - "@biomejs/cli-linux-x64": "2.4.16", - "@biomejs/cli-linux-x64-musl": "2.4.16", - "@biomejs/cli-win32-arm64": "2.4.16", - "@biomejs/cli-win32-x64": "2.4.16" + "@biomejs/cli-darwin-arm64": "2.5.0", + "@biomejs/cli-darwin-x64": "2.5.0", + "@biomejs/cli-linux-arm64": "2.5.0", + "@biomejs/cli-linux-arm64-musl": "2.5.0", + "@biomejs/cli-linux-x64": "2.5.0", + "@biomejs/cli-linux-x64-musl": "2.5.0", + "@biomejs/cli-win32-arm64": "2.5.0", + "@biomejs/cli-win32-x64": "2.5.0" } }, "node_modules/@biomejs/cli-darwin-arm64": { - "version": "2.4.16", - "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-2.4.16.tgz", - "integrity": "sha512-wxPvu4XOA85YJk9ixSWUmq/QBHbid85BISbOAqqBM/5xQpPk9ayjk5375tOlSC0BeCwNSbPFafQBm+vBumXq0A==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-2.5.0.tgz", + "integrity": "sha512-Mn3Fwi3SA5fgmfCPqmzpWF2DLZnms3BVAhM088nTnGrTZmHS3wwIjcoZPqpXeNgd3DrrLH6xp8vTLIBuJoZiXw==", "cpu": [ "arm64" ], @@ -139,9 +139,9 @@ } }, "node_modules/@biomejs/cli-darwin-x64": { - "version": "2.4.16", - "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-2.4.16.tgz", - "integrity": "sha512-xFCqGPwYusQJp4N4NJLi1XJiZqjwFdjhT+KqtNy+Ug3qgfczqnTa6MSDvxJF6TkuDLoYJItMapz6tAf7kCekFw==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-2.5.0.tgz", + "integrity": "sha512-rg3VPL5P8mYro6pqlXYXuJWph21slVp3SZtAqWSrkZs40d2gTzYmHF8E/X1iTID25btmNKltNDJ926sqVBp7DQ==", "cpu": [ "x64" ], @@ -156,13 +156,16 @@ } }, "node_modules/@biomejs/cli-linux-arm64": { - "version": "2.4.16", - "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-2.4.16.tgz", - "integrity": "sha512-2kFb4//jxfZaP6D+Rj5VkHkxgyD9EoRAVBEQb8PKRv+s4NO2zYNJKXFaJmK1CmhufJOWEfpHKaRbOja7qjmdhQ==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-2.5.0.tgz", + "integrity": "sha512-tl+LW8fdD96/xdeWtWwc82LIOc5CoY7N2AsogLTp5R4ECErYt+8Jl/N68ezN9vzSiqPTxw6vjcihoLPYKZHrlw==", "cpu": [ "arm64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT OR Apache-2.0", "optional": true, "os": [ @@ -173,13 +176,16 @@ } }, "node_modules/@biomejs/cli-linux-arm64-musl": { - "version": "2.4.16", - "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.4.16.tgz", - "integrity": "sha512-oYxnW0ARfJkr72ezzF2OR8N/rtkgLUQeYtF8cFhVswbknHxtTcmzSsanVJP8yQKnGpGpc2ck6c5zLvHahL6Cbg==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.5.0.tgz", + "integrity": "sha512-vQdM4oSGaf7ZNeGO9w5+Y8SBtyser9M6znxYbm7Ec8wInxJu1WiKxFYZW5Auj2d80bcVvefuGGRxoFOE0eee8g==", "cpu": [ "arm64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT OR Apache-2.0", "optional": true, "os": [ @@ -190,13 +196,16 @@ } }, "node_modules/@biomejs/cli-linux-x64": { - "version": "2.4.16", - "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-2.4.16.tgz", - "integrity": "sha512-NbcBbi/nJqn5baae6wqRXdS7Gadf2uRpehSh6vMSYpG8OhkXl/Xg8aorWrJ+9VWqAT5ml90alLvorkpMW0nBwQ==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-2.5.0.tgz", + "integrity": "sha512-zpEGf4RQbFEh8Vt7OmavLyyOzRbtcE9osCqrS1kfvt8jDvxwhKXLSf7n0ebr/ov0RJ9ssP+lhs6C8a9WwFvrQA==", "cpu": [ "x64" ], "dev": true, + "libc": [ + "glibc" + ], "license": "MIT OR Apache-2.0", "optional": true, "os": [ @@ -207,13 +216,16 @@ } }, "node_modules/@biomejs/cli-linux-x64-musl": { - "version": "2.4.16", - "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-2.4.16.tgz", - "integrity": "sha512-iHDS+MCM65DPqWGu+ECC3uoALyj2H7F4nVUPxIPjz/PIl94EUu+EDfGZDzFP+NY1EOPVt9NQvwFqq7HdMmowdg==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-2.5.0.tgz", + "integrity": "sha512-+9hIcMngJ+yGUahXqZuZ8CoWKJE9SAZsFsM3QDvXpNsLbXZ9lqVzgBhOk/jTSYkOA0GLP9eu3teukqpLUojHMg==", "cpu": [ "x64" ], "dev": true, + "libc": [ + "musl" + ], "license": "MIT OR Apache-2.0", "optional": true, "os": [ @@ -224,9 +236,9 @@ } }, "node_modules/@biomejs/cli-win32-arm64": { - "version": "2.4.16", - "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-2.4.16.tgz", - "integrity": "sha512-0rgImMsNb5v/chhkIFe3wu7PEFClS6RBAYUijGL9UsYN3PanSaoK24HSSuSJb1pYbYYVjzAyZTl3gtjJ84BM8A==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-2.5.0.tgz", + "integrity": "sha512-jB0wAvTLI4itx5VidqVUejPQFhRUxiZ9l9FvZ26D5fl6t3qme+ZB4PD3bTSeL1vZ8NI2Rx/zj6H9zcESuGHKGw==", "cpu": [ "arm64" ], @@ -241,9 +253,9 @@ } }, "node_modules/@biomejs/cli-win32-x64": { - "version": "2.4.16", - "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-2.4.16.tgz", - "integrity": "sha512-Kp85jgoBHa05gix6UIRjfCDiUV3w/8VIdZ247VyyO2gEjaw12WEVhdIjlxp/AMzXxqxQwbxNTDVZ3Mwd2RG5rw==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-2.5.0.tgz", + "integrity": "sha512-VT/lF+GId+67j8aDfLkxdxNoVApsPSTbyAtB3jJq0IWTrY77WXfbPfpngxq0bA6JCEv/7k8C9qWjDRKRznDlyw==", "cpu": [ "x64" ], diff --git a/package.json b/package.json index d38e89e..c847c0a 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "testcontainers": "12.0.3" }, "devDependencies": { - "@biomejs/biome": "2.4.16", + "@biomejs/biome": "2.5.0", "@types/node": "25.9.3", "get-port": "7.2.0", "tsdown": "0.22.3", diff --git a/src/Client.ts b/src/Client.ts index 75d8115..cf81ce7 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -32,8 +32,8 @@ interface ResponseBodyReadEventType { } class Client { - #url: URL; - #apiToken: string; + readonly #url: URL; + readonly #apiToken: string; #getUrl(path: string): string { return new URL(path, this.#url).toString(); @@ -160,7 +160,7 @@ class Client { const url = this.#getUrl('/api/v1/read-events'); const apiToken = this.#apiToken; - return (async function* () { + return (async function* (): AsyncGenerator { const internalAbortController = new AbortController(); const combinedSignal = signal ?? internalAbortController.signal; const shouldAbortInternally = !signal; @@ -168,9 +168,9 @@ class Client { let removeAbortListener: (() => void) | undefined; if (signal && !signal.aborted) { - const onAbort = () => internalAbortController.abort(); + const onAbort = (): void => internalAbortController.abort(); signal.addEventListener('abort', onAbort, { once: true }); - removeAbortListener = () => signal.removeEventListener('abort', onAbort); + removeAbortListener = (): void => signal.removeEventListener('abort', onAbort); } try { @@ -236,7 +236,7 @@ class Client { const url = this.#getUrl('/api/v1/run-eventql-query'); const apiToken = this.#apiToken; - return (async function* () { + return (async function* (): AsyncGenerator { const internalAbortController = new AbortController(); const combinedSignal = signal ?? internalAbortController.signal; const shouldAbortInternally = !signal; @@ -244,9 +244,9 @@ class Client { let removeAbortListener: (() => void) | undefined; if (signal && !signal.aborted) { - const onAbort = () => internalAbortController.abort(); + const onAbort = (): void => internalAbortController.abort(); signal.addEventListener('abort', onAbort, { once: true }); - removeAbortListener = () => signal.removeEventListener('abort', onAbort); + removeAbortListener = (): void => signal.removeEventListener('abort', onAbort); } try { @@ -316,7 +316,7 @@ class Client { const url = this.#getUrl('/api/v1/observe-events'); const apiToken = this.#apiToken; - return (async function* () { + return (async function* (): AsyncGenerator { const internalAbortController = new AbortController(); const combinedSignal = signal ?? internalAbortController.signal; const shouldAbortInternally = !signal; @@ -324,9 +324,9 @@ class Client { let removeAbortListener: (() => void) | undefined; if (signal && !signal.aborted) { - const onAbort = () => internalAbortController.abort(); + const onAbort = (): void => internalAbortController.abort(); signal.addEventListener('abort', onAbort, { once: true }); - removeAbortListener = () => signal.removeEventListener('abort', onAbort); + removeAbortListener = (): void => signal.removeEventListener('abort', onAbort); } try { @@ -426,7 +426,7 @@ class Client { const url = this.#getUrl('/api/v1/read-subjects'); const apiToken = this.#apiToken; - return (async function* () { + return (async function* (): AsyncGenerator { const internalAbortController = new AbortController(); const combinedSignal = signal ?? internalAbortController.signal; const shouldAbortInternally = !signal; @@ -434,9 +434,9 @@ class Client { let removeAbortListener: (() => void) | undefined; if (signal && !signal.aborted) { - const onAbort = () => internalAbortController.abort(); + const onAbort = (): void => internalAbortController.abort(); signal.addEventListener('abort', onAbort, { once: true }); - removeAbortListener = () => signal.removeEventListener('abort', onAbort); + removeAbortListener = (): void => signal.removeEventListener('abort', onAbort); } try { @@ -535,7 +535,7 @@ class Client { const url = this.#getUrl('/api/v1/read-event-types'); const apiToken = this.#apiToken; - return (async function* () { + return (async function* (): AsyncGenerator { const internalAbortController = new AbortController(); const combinedSignal = signal ?? internalAbortController.signal; const shouldAbortInternally = !signal; @@ -543,9 +543,9 @@ class Client { let removeAbortListener: (() => void) | undefined; if (signal && !signal.aborted) { - const onAbort = () => internalAbortController.abort(); + const onAbort = (): void => internalAbortController.abort(); signal.addEventListener('abort', onAbort, { once: true }); - removeAbortListener = () => signal.removeEventListener('abort', onAbort); + removeAbortListener = (): void => signal.removeEventListener('abort', onAbort); } try { diff --git a/src/Container.ts b/src/Container.ts index 40b83aa..bb1f093 100644 --- a/src/Container.ts +++ b/src/Container.ts @@ -3,14 +3,14 @@ import type { Content, StartedTestContainer } from 'testcontainers'; import { GenericContainer, Wait } from 'testcontainers'; import { Client } from './Client.js'; -type ContentToCopy = { +interface ContentToCopy { content: Content; target: string; mode?: number; -}; +} class Container { - #imageName = 'thenativeweb/eventsourcingdb'; + readonly #imageName = 'thenativeweb/eventsourcingdb'; #imageTag = 'latest'; #internalPort = 3000; #apiToken = 'secret'; diff --git a/src/convertCloudEventToEvent.ts b/src/convertCloudEventToEvent.ts index b8fbad5..241a3b0 100644 --- a/src/convertCloudEventToEvent.ts +++ b/src/convertCloudEventToEvent.ts @@ -1,8 +1,8 @@ import type { CloudEvent } from './CloudEvent.js'; import { Event } from './Event.js'; -const convertCloudEventToEvent = (cloudEvent: CloudEvent): Event => { - return new Event({ +const convertCloudEventToEvent = (cloudEvent: CloudEvent): Event => + new Event({ specversion: cloudEvent.specversion, id: cloudEvent.id, time: new Date(cloudEvent.time), @@ -18,6 +18,5 @@ const convertCloudEventToEvent = (cloudEvent: CloudEvent): Event => { tracestate: cloudEvent.tracestate, signature: cloudEvent.signature, }); -}; export { convertCloudEventToEvent }; diff --git a/src/getImageVersionFromDockerfile.ts b/src/getImageVersionFromDockerfile.ts index e9236b0..fda0d56 100644 --- a/src/getImageVersionFromDockerfile.ts +++ b/src/getImageVersionFromDockerfile.ts @@ -1,10 +1,10 @@ import fs from 'node:fs'; import path from 'node:path'; -const versionRegex = /^FROM\sthenativeweb\/eventsourcingdb:(.+)$/m; +const versionRegex = /^FROM\sthenativeweb\/eventsourcingdb:(.+)$/mu; const getImageVersionFromDockerfile = (): string => { - const dockerfile = path.join(__dirname, '..', 'docker', 'Dockerfile'); + const dockerfile = path.join(import.meta.dirname, '..', 'docker', 'Dockerfile'); const data = fs.readFileSync(dockerfile, 'utf-8'); const matches = data.match(versionRegex); diff --git a/src/isCloudEvent.ts b/src/isCloudEvent.ts index 880d6de..4551717 100644 --- a/src/isCloudEvent.ts +++ b/src/isCloudEvent.ts @@ -5,8 +5,8 @@ import { isString } from './types/isString.js'; import { isStringOrNull } from './types/isStringOrNull.js'; import { isStringOrUndefined } from './types/isStringOrUndefined.js'; -const isCloudEvent = (value: unknown): value is CloudEvent => { - return hasShapeOf(value, { +const isCloudEvent = (value: unknown): value is CloudEvent => + hasShapeOf(value, { specversion: isString, id: isString, time: isString, @@ -21,6 +21,5 @@ const isCloudEvent = (value: unknown): value is CloudEvent => { tracestate: isStringOrUndefined, signature: isStringOrNull, }); -}; export { isCloudEvent }; diff --git a/src/isEventQlQueryTrue.ts b/src/isEventQlQueryTrue.ts index 5cdb5b4..b542e94 100644 --- a/src/isEventQlQueryTrue.ts +++ b/src/isEventQlQueryTrue.ts @@ -1,10 +1,8 @@ import type { Precondition } from './Precondition.js'; -const isEventQlQueryTrue = (query: string): Precondition => { - return { - type: 'isEventQlQueryTrue', - payload: { query }, - }; -}; +const isEventQlQueryTrue = (query: string): Precondition => ({ + type: 'isEventQlQueryTrue', + payload: { query }, +}); export { isEventQlQueryTrue }; diff --git a/src/isSubjectOnEventId.ts b/src/isSubjectOnEventId.ts index d453c39..bdb88bd 100644 --- a/src/isSubjectOnEventId.ts +++ b/src/isSubjectOnEventId.ts @@ -1,10 +1,8 @@ import type { Precondition } from './Precondition.js'; -const isSubjectOnEventId = (subject: string, eventId: string): Precondition => { - return { - type: 'isSubjectOnEventId', - payload: { subject, eventId }, - }; -}; +const isSubjectOnEventId = (subject: string, eventId: string): Precondition => ({ + type: 'isSubjectOnEventId', + payload: { subject, eventId }, +}); export { isSubjectOnEventId }; diff --git a/src/isSubjectPopulated.ts b/src/isSubjectPopulated.ts index d0b370b..571a7b0 100644 --- a/src/isSubjectPopulated.ts +++ b/src/isSubjectPopulated.ts @@ -1,10 +1,8 @@ import type { Precondition } from './Precondition.js'; -const isSubjectPopulated = (subject: string): Precondition => { - return { - type: 'isSubjectPopulated', - payload: { subject }, - }; -}; +const isSubjectPopulated = (subject: string): Precondition => ({ + type: 'isSubjectPopulated', + payload: { subject }, +}); export { isSubjectPopulated }; diff --git a/src/isSubjectPristine.ts b/src/isSubjectPristine.ts index 6424241..5e74179 100644 --- a/src/isSubjectPristine.ts +++ b/src/isSubjectPristine.ts @@ -1,10 +1,8 @@ import type { Precondition } from './Precondition.js'; -const isSubjectPristine = (subject: string): Precondition => { - return { - type: 'isSubjectPristine', - payload: { subject }, - }; -}; +const isSubjectPristine = (subject: string): Precondition => ({ + type: 'isSubjectPristine', + payload: { subject }, +}); export { isSubjectPristine }; diff --git a/src/ndjson/readNdJsonStream.test.ts b/src/ndjson/readNdJsonStream.test.ts index 263057f..bb38e11 100644 --- a/src/ndjson/readNdJsonStream.test.ts +++ b/src/ndjson/readNdJsonStream.test.ts @@ -5,7 +5,7 @@ import { readNdJsonStream } from './readNdJsonStream.js'; function convertStreamToWebStream(stream: Readable): ReadableStream { return new ReadableStream({ - start(controller) { + start(controller: ReadableStreamDefaultController): void { stream.on('data', chunk => { controller.enqueue(new Uint8Array(chunk)); }); diff --git a/src/ndjson/readNdJsonStream.ts b/src/ndjson/readNdJsonStream.ts index e41533f..1ca4e08 100644 --- a/src/ndjson/readNdJsonStream.ts +++ b/src/ndjson/readNdJsonStream.ts @@ -6,7 +6,7 @@ const readNdJsonStream = async function* ( const decoder = new TextDecoder('utf-8'); let buffer = ''; - const onAbort = () => { + const onAbort = (): void => { reader.cancel().catch(() => { // Intentionally left blank. }); @@ -22,11 +22,7 @@ const readNdJsonStream = async function* ( signal.addEventListener('abort', onAbort); try { - while (true) { - if (signal.aborted) { - break; - } - + while (!signal.aborted) { // biome-ignore lint/performance/noAwaitInLoops: Awaiting the result is fine here, although we are in a loop. const { done, value } = await reader.read(); if (done) { @@ -35,19 +31,16 @@ const readNdJsonStream = async function* ( buffer += decoder.decode(value, { stream: true }); - let index: number; - while (true) { - index = buffer.indexOf('\n'); - if (index === -1) { - break; - } - + let index = buffer.indexOf('\n'); + while (index !== -1) { const line = buffer.slice(0, index).trim(); buffer = buffer.slice(index + 1); if (line) { yield JSON.parse(line); } + + index = buffer.indexOf('\n'); } } } finally { diff --git a/src/readEventTypes.test.ts b/src/readEventTypes.test.ts index d567f79..5bf46e1 100644 --- a/src/readEventTypes.test.ts +++ b/src/readEventTypes.test.ts @@ -87,8 +87,8 @@ suite('readEventTypes', { timeout: 20_000 }, () => { await client.registerEventSchema(eventType, schema); const eventTypesRead: EventType[] = []; - for await (const eventType of client.readEventTypes()) { - eventTypesRead.push(eventType); + for await (const eventTypeRead of client.readEventTypes()) { + eventTypesRead.push(eventTypeRead); } assert.deepEqual(eventTypesRead, [ diff --git a/src/stream/isStreamCloudEvent.ts b/src/stream/isStreamCloudEvent.ts index 599097f..4d850d3 100644 --- a/src/stream/isStreamCloudEvent.ts +++ b/src/stream/isStreamCloudEvent.ts @@ -5,9 +5,9 @@ import { isStringOrNull } from '../types/isStringOrNull.js'; import { isStringOrUndefined } from '../types/isStringOrUndefined.js'; import type { StreamCloudEvent } from './StreamCloudEvent.js'; -const isStreamCloudEvent = (line: unknown): line is StreamCloudEvent => { - return hasShapeOf(line, { - type: value => value === 'event', +const isStreamCloudEvent = (line: unknown): line is StreamCloudEvent => + hasShapeOf(line, { + type: (value: unknown): value is 'event' => value === 'event', payload: { specversion: isString, id: isString, @@ -24,6 +24,5 @@ const isStreamCloudEvent = (line: unknown): line is StreamCloudEvent => { signature: isStringOrNull, }, }); -}; export { isStreamCloudEvent }; diff --git a/src/stream/isStreamError.ts b/src/stream/isStreamError.ts index c2b7092..9e0b090 100644 --- a/src/stream/isStreamError.ts +++ b/src/stream/isStreamError.ts @@ -2,13 +2,12 @@ import { hasShapeOf } from '../types/hasShapeOf.js'; import { isString } from '../types/isString.js'; import type { StreamError } from './StreamError.js'; -const isStreamError = (line: unknown): line is StreamError => { - return hasShapeOf(line, { - type: value => value === 'error', +const isStreamError = (line: unknown): line is StreamError => + hasShapeOf(line, { + type: (value: unknown): value is 'error' => value === 'error', payload: { error: isString, }, }); -}; export { isStreamError }; diff --git a/src/stream/isStreamEventType.ts b/src/stream/isStreamEventType.ts index eb0a16a..1a3ef8d 100644 --- a/src/stream/isStreamEventType.ts +++ b/src/stream/isStreamEventType.ts @@ -3,14 +3,13 @@ import { isBoolean } from '../types/isBoolean.js'; import { isString } from '../types/isString.js'; import type { StreamEventType } from './StreamEventType.js'; -const isStreamEventType = (line: unknown): line is StreamEventType => { - return hasShapeOf(line, { - type: value => value === 'eventType', +const isStreamEventType = (line: unknown): line is StreamEventType => + hasShapeOf(line, { + type: (value: unknown): value is 'eventType' => value === 'eventType', payload: { eventType: isString, isPhantom: isBoolean, }, }); -}; export { isStreamEventType }; diff --git a/src/stream/isStreamHeartbeat.ts b/src/stream/isStreamHeartbeat.ts index 32eaa3a..3e80965 100644 --- a/src/stream/isStreamHeartbeat.ts +++ b/src/stream/isStreamHeartbeat.ts @@ -1,10 +1,9 @@ import { hasShapeOf } from '../types/hasShapeOf.js'; import type { StreamHeartbeat } from './StreamHeartbeat.js'; -const isStreamHeartbeat = (line: unknown): line is StreamHeartbeat => { - return hasShapeOf(line, { - type: value => value === 'heartbeat', +const isStreamHeartbeat = (line: unknown): line is StreamHeartbeat => + hasShapeOf(line, { + type: (value: unknown): value is 'heartbeat' => value === 'heartbeat', }); -}; export { isStreamHeartbeat }; diff --git a/src/stream/isStreamRow.ts b/src/stream/isStreamRow.ts index 8a1214f..9b30718 100644 --- a/src/stream/isStreamRow.ts +++ b/src/stream/isStreamRow.ts @@ -1,11 +1,10 @@ import { hasShapeOf } from '../types/hasShapeOf.js'; import type { StreamRow } from './StreamRow.js'; -const isStreamRow = (line: unknown): line is StreamRow => { - return hasShapeOf(line, { - type: value => value === 'row', +const isStreamRow = (line: unknown): line is StreamRow => + hasShapeOf(line, { + type: (value: unknown): value is 'row' => value === 'row', payload: (value: unknown): value is unknown => value !== undefined, }); -}; export { isStreamRow }; diff --git a/src/stream/isStreamSubject.ts b/src/stream/isStreamSubject.ts index 048e51f..4a23d18 100644 --- a/src/stream/isStreamSubject.ts +++ b/src/stream/isStreamSubject.ts @@ -2,13 +2,12 @@ import { hasShapeOf } from '../types/hasShapeOf.js'; import { isString } from '../types/isString.js'; import type { StreamSubject } from './StreamSubject.js'; -const isStreamSubject = (line: unknown): line is StreamSubject => { - return hasShapeOf(line, { - type: value => value === 'subject', +const isStreamSubject = (line: unknown): line is StreamSubject => + hasShapeOf(line, { + type: (value: unknown): value is 'subject' => value === 'subject', payload: { subject: isString, }, }); -}; export { isStreamSubject }; diff --git a/tsconfig.json b/tsconfig.json index c257442..18785ad 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,8 @@ "declaration": true, "esModuleInterop": true, "lib": ["ES2023"], - "module": "CommonJS", + "module": "esnext", + "moduleResolution": "bundler", "outDir": "dist", "resolveJsonModule": true, "strict": true,