From de8abf392aa45f1fe0acd8dfae4621390bff871e Mon Sep 17 00:00:00 2001 From: systemfsoftware-bot Date: Thu, 29 Oct 2026 15:24:30 -0400 Subject: [PATCH] refactor(schema): conform to the effect-tsgo 0.54 lint rules Claude-Session: https://claude.ai/code/session_017rX35xUAHEjVVaDKVVzubW --- .../src/MemoryFileSystemError.schema.ts | 20 ++++++++------ .../src/decode-watch-event.schema.ts | 18 +++++++------ packages/effect-memfs/src/open-file.handle.ts | 4 +-- .../src/plan-read-slice.schema.ts | 10 ++++--- .../src/plan-seek-position.schema.ts | 16 +++++++----- .../src/plan-seek-position.workflow.ts | 8 ++++-- .../src/plan-truncate-cursor.schema.ts | 20 ++++++++------ .../src/plan-write-continuation.schema.ts | 26 ++++++++++++------- .../tests/__fixtures__/open-file.model.ts | 8 +++--- ...ean-up-temporary-files.integration.test.ts | 4 +-- 10 files changed, 79 insertions(+), 55 deletions(-) diff --git a/packages/effect-memfs/src/MemoryFileSystemError.schema.ts b/packages/effect-memfs/src/MemoryFileSystemError.schema.ts index 3a3ef76..1b8516b 100644 --- a/packages/effect-memfs/src/MemoryFileSystemError.schema.ts +++ b/packages/effect-memfs/src/MemoryFileSystemError.schema.ts @@ -1,19 +1,23 @@ import { Predicate, Schema } from 'effect' import * as Error from 'effect/PlatformError' -export class ShapeRefusal extends Schema.TaggedError()('ShapeRefusal', { - method: Schema.String, - cause: Schema.optional(Schema.Unknown), -}) { +export class ShapeRefusal + extends Schema.TaggedError()('ShapeRefusal', { + method: Schema.String, + cause: Schema.optional(Schema.Unknown), + }) +{ override get message(): string { return `The "${this.method}" call was given a value that is not a memory file system driver` } } -export class CursorRefusal extends Schema.TaggedError()('CursorRefusal', { - method: Schema.String, - cause: Schema.optional(Schema.Unknown), -}) { +export class CursorRefusal + extends Schema.TaggedError()('CursorRefusal', { + method: Schema.String, + cause: Schema.optional(Schema.Unknown), + }) +{ override get message(): string { return `The "${this.method}" call would move the cursor before the start of the file` } diff --git a/packages/effect-memfs/src/decode-watch-event.schema.ts b/packages/effect-memfs/src/decode-watch-event.schema.ts index 5ae2721..2ee1383 100644 --- a/packages/effect-memfs/src/decode-watch-event.schema.ts +++ b/packages/effect-memfs/src/decode-watch-event.schema.ts @@ -6,19 +6,19 @@ const WatchEventDecisionTypeId: unique symbol = Symbol.for( ) type WatchEventDecisionTypeId = typeof WatchEventDecisionTypeId -export class WatchCreate extends Schema.TaggedClass()('WatchCreate', { +export class WatchCreate extends Schema.TaggedClass()('WatchCreate', { path: Schema.String, }) { readonly [WatchEventDecisionTypeId] = WatchEventDecisionTypeId } -export class WatchUpdate extends Schema.TaggedClass()('WatchUpdate', { +export class WatchUpdate extends Schema.TaggedClass()('WatchUpdate', { path: Schema.String, }) { readonly [WatchEventDecisionTypeId] = WatchEventDecisionTypeId } -export class WatchRemove extends Schema.TaggedClass()('WatchRemove', { +export class WatchRemove extends Schema.TaggedClass()('WatchRemove', { path: Schema.String, }) { readonly [WatchEventDecisionTypeId] = WatchEventDecisionTypeId @@ -30,10 +30,12 @@ export type WatchEventDecision = typeof WatchEventDecision.Type export const DriverWatchEventType = Schema.Literals(['rename', 'change']) export type DriverWatchEventType = typeof DriverWatchEventType.Type -export class DriverWatchEvent extends Schema.TaggedClass()('DriverWatchEvent', { - eventType: DriverWatchEventType, - filename: Schema.String, - exists: Schema.Boolean, -}) { +export class DriverWatchEvent + extends Schema.TaggedClass()('DriverWatchEvent', { + eventType: DriverWatchEventType, + filename: Schema.String, + exists: Schema.Boolean, + }) +{ static readonly [Workflow.InstrumentationBrand] = {} as const } diff --git a/packages/effect-memfs/src/open-file.handle.ts b/packages/effect-memfs/src/open-file.handle.ts index bfaa2af..afbd1a1 100644 --- a/packages/effect-memfs/src/open-file.handle.ts +++ b/packages/effect-memfs/src/open-file.handle.ts @@ -316,9 +316,7 @@ const writeChunk = (self: OpenFile, pending: Uint8Array): Effect.Effect - advance(self, BigInt(writtenOf(decision, pending.length))).pipe(Effect.as(decision)) - ), + Effect.tap((decision) => advance(self, BigInt(writtenOf(decision, pending.length)))), ) ), ) diff --git a/packages/effect-memfs/src/plan-read-slice.schema.ts b/packages/effect-memfs/src/plan-read-slice.schema.ts index 07d2265..6878a9f 100644 --- a/packages/effect-memfs/src/plan-read-slice.schema.ts +++ b/packages/effect-memfs/src/plan-read-slice.schema.ts @@ -6,24 +6,26 @@ const ReadSliceDecisionTypeId: unique symbol = Symbol.for( ) type ReadSliceDecisionTypeId = typeof ReadSliceDecisionTypeId -export class ReadWhole extends Schema.TaggedClass()('ReadWhole', {}) { +export class ReadWhole extends Schema.TaggedClass()('ReadWhole', {}) { readonly [ReadSliceDecisionTypeId] = ReadSliceDecisionTypeId } -export class ReadPartial extends Schema.TaggedClass()('ReadPartial', { +export class ReadPartial extends Schema.TaggedClass()('ReadPartial', { bytesRead: Schema.Finite, }) { readonly [ReadSliceDecisionTypeId] = ReadSliceDecisionTypeId } -export class ReadExhausted extends Schema.TaggedClass()('ReadExhausted', {}) { +export class ReadExhausted + extends Schema.TaggedClass()('ReadExhausted', {}) +{ readonly [ReadSliceDecisionTypeId] = ReadSliceDecisionTypeId } export const ReadSliceDecision = Schema.Union([ReadWhole, ReadPartial, ReadExhausted]) export type ReadSliceDecision = typeof ReadSliceDecision.Type -export class ReadSlice extends Schema.TaggedClass()('ReadSlice', { +export class ReadSlice extends Schema.TaggedClass()('ReadSlice', { bytesRead: Schema.Finite, requested: Schema.Finite, }) { diff --git a/packages/effect-memfs/src/plan-seek-position.schema.ts b/packages/effect-memfs/src/plan-seek-position.schema.ts index 38d8d75..83e1220 100644 --- a/packages/effect-memfs/src/plan-seek-position.schema.ts +++ b/packages/effect-memfs/src/plan-seek-position.schema.ts @@ -6,13 +6,13 @@ const SeekPositionDecisionTypeId: unique symbol = Symbol.for( ) type SeekPositionDecisionTypeId = typeof SeekPositionDecisionTypeId -export class SeekMoved extends Schema.TaggedClass()('SeekMoved', { +export class SeekMoved extends Schema.TaggedClass()('SeekMoved', { position: Schema.BigInt, }) { readonly [SeekPositionDecisionTypeId] = SeekPositionDecisionTypeId } -export class SeekRefused extends Schema.TaggedClass()('SeekRefused', { +export class SeekRefused extends Schema.TaggedClass()('SeekRefused', { position: Schema.BigInt, }) { readonly [SeekPositionDecisionTypeId] = SeekPositionDecisionTypeId @@ -21,10 +21,12 @@ export class SeekRefused extends Schema.TaggedClass()('SeekRefused' export const SeekPositionDecision = Schema.Union([SeekMoved, SeekRefused]) export type SeekPositionDecision = typeof SeekPositionDecision.Type -export class PlanSeekPosition extends Schema.TaggedClass()('PlanSeekPosition', { - position: Schema.BigInt, - offset: Schema.BigInt, - from: Schema.Literals(['start', 'current']), -}) { +export class PlanSeekPosition + extends Schema.TaggedClass()('PlanSeekPosition', { + position: Schema.BigInt, + offset: Schema.BigInt, + from: Schema.Literals(['start', 'current']), + }) +{ static readonly [Workflow.InstrumentationBrand] = {} as const } diff --git a/packages/effect-memfs/src/plan-seek-position.workflow.ts b/packages/effect-memfs/src/plan-seek-position.workflow.ts index 9a333ec..d1767a0 100644 --- a/packages/effect-memfs/src/plan-seek-position.workflow.ts +++ b/packages/effect-memfs/src/plan-seek-position.workflow.ts @@ -3,8 +3,12 @@ import { Match, Schema } from 'effect' import * as Result from 'effect/Result' import { PlanSeekPosition, SeekMoved, SeekPositionDecision, SeekRefused } from './plan-seek-position.schema.js' -class SeekBeforeStart extends Schema.TaggedClass()('SeekBeforeStart', {}) {} -class SeekWithinFile extends Schema.TaggedClass()('SeekWithinFile', {}) {} +class SeekBeforeStart + extends Schema.TaggedClass()('SeekBeforeStart', {}) +{} +class SeekWithinFile + extends Schema.TaggedClass()('SeekWithinFile', {}) +{} type SeekStepOutcome = SeekBeforeStart | SeekWithinFile diff --git a/packages/effect-memfs/src/plan-truncate-cursor.schema.ts b/packages/effect-memfs/src/plan-truncate-cursor.schema.ts index 9b169fb..c04a600 100644 --- a/packages/effect-memfs/src/plan-truncate-cursor.schema.ts +++ b/packages/effect-memfs/src/plan-truncate-cursor.schema.ts @@ -6,24 +6,28 @@ const TruncateCursorDecisionTypeId: unique symbol = Symbol.for( ) type TruncateCursorDecisionTypeId = typeof TruncateCursorDecisionTypeId -export class CursorKept extends Schema.TaggedClass()('CursorKept', { +export class CursorKept extends Schema.TaggedClass()('CursorKept', { position: Schema.BigInt, }) { readonly [TruncateCursorDecisionTypeId] = TruncateCursorDecisionTypeId } -export class CursorClamped extends Schema.TaggedClass()('CursorClamped', { - position: Schema.BigInt, -}) { +export class CursorClamped + extends Schema.TaggedClass()('CursorClamped', { + position: Schema.BigInt, + }) +{ readonly [TruncateCursorDecisionTypeId] = TruncateCursorDecisionTypeId } export const TruncateCursorDecision = Schema.Union([CursorKept, CursorClamped]) export type TruncateCursorDecision = typeof TruncateCursorDecision.Type -export class PlanTruncateCursor extends Schema.TaggedClass()('PlanTruncateCursor', { - position: Schema.BigInt, - length: Schema.Int, -}) { +export class PlanTruncateCursor + extends Schema.TaggedClass()('PlanTruncateCursor', { + position: Schema.BigInt, + length: Schema.Int, + }) +{ static readonly [Workflow.InstrumentationBrand] = {} as const } diff --git a/packages/effect-memfs/src/plan-write-continuation.schema.ts b/packages/effect-memfs/src/plan-write-continuation.schema.ts index 95af118..41df36b 100644 --- a/packages/effect-memfs/src/plan-write-continuation.schema.ts +++ b/packages/effect-memfs/src/plan-write-continuation.schema.ts @@ -6,17 +6,21 @@ const WriteAllChunkDecisionTypeId: unique symbol = Symbol.for( ) type WriteAllChunkDecisionTypeId = typeof WriteAllChunkDecisionTypeId -export class WriteContinued extends Schema.TaggedClass()('WriteContinued', { - skip: Schema.Finite, -}) { +export class WriteContinued + extends Schema.TaggedClass()('WriteContinued', { + skip: Schema.Finite, + }) +{ readonly [WriteAllChunkDecisionTypeId] = WriteAllChunkDecisionTypeId } -export class WriteDrained extends Schema.TaggedClass()('WriteDrained', {}) { +export class WriteDrained + extends Schema.TaggedClass()('WriteDrained', {}) +{ readonly [WriteAllChunkDecisionTypeId] = WriteAllChunkDecisionTypeId } -export class WriteZero extends Schema.TaggedError()('WriteZero', { +export class WriteZero extends Schema.TaggedError()('WriteZero', { fd: Schema.Finite, message: Schema.String, cause: Schema.optional(Schema.Unknown), @@ -27,10 +31,12 @@ export class WriteZero extends Schema.TaggedError()('WriteZero', { export const WriteAllChunkDecision = Schema.Union([WriteContinued, WriteDrained]) export type WriteAllChunkDecision = typeof WriteAllChunkDecision.Type -export class WriteAllChunk extends Schema.TaggedClass()('WriteAllChunk', { - fd: Schema.Finite, - written: Schema.Finite, - remaining: Schema.Finite, -}) { +export class WriteAllChunk + extends Schema.TaggedClass()('WriteAllChunk', { + fd: Schema.Finite, + written: Schema.Finite, + remaining: Schema.Finite, + }) +{ static readonly [Workflow.InstrumentationBrand] = {} as const } diff --git a/packages/effect-memfs/tests/__fixtures__/open-file.model.ts b/packages/effect-memfs/tests/__fixtures__/open-file.model.ts index 901382e..756d6f9 100644 --- a/packages/effect-memfs/tests/__fixtures__/open-file.model.ts +++ b/packages/effect-memfs/tests/__fixtures__/open-file.model.ts @@ -3,9 +3,11 @@ import { Match, Schema } from 'effect' /** A note of five letters, opened for reading and writing, is the subject. */ export const OpenedNoteText = 'hello' -export class HandleLeftOpen extends Schema.TaggedError()('HandleLeftOpen', { - reason: Schema.String, -}) {} +export class HandleLeftOpen + extends Schema.TaggedError()('HandleLeftOpen', { + reason: Schema.String, + }) +{} const Written = Schema.Literals(['a', 'bc', 'def']) const Size = Schema.Literals([1, 2, 3, 5, 8]) diff --git a/packages/effect-memfs/tests/clean-up-temporary-files.integration.test.ts b/packages/effect-memfs/tests/clean-up-temporary-files.integration.test.ts index 06a77fe..ddc0496 100644 --- a/packages/effect-memfs/tests/clean-up-temporary-files.integration.test.ts +++ b/packages/effect-memfs/tests/clean-up-temporary-files.integration.test.ts @@ -93,9 +93,9 @@ Feature('Handing back scratch space when the work using it is over') When('a piece of work borrows scratch space and then finishes')('outcome', (s) => Effect.gen(function*() { const borrowed = yield* Effect.scoped( - Effect.flatMap( + Effect.tap( Effect.flatMap(filesystem, row.borrow), - (path) => Effect.as(s.fs.stat(path), path), + (path) => s.fs.stat(path), ), ) return yield* Effect.flip(s.fs.stat(borrowed))