From a5df6d04c034bd19cf7cdb9c9a311f51bcbf9ea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Valverd=C3=A9?= Date: Wed, 1 Oct 2025 18:58:25 +0200 Subject: [PATCH] Linter fixes --- .vscode/settings.json | 5 ++++- biome.json | 12 +++++++++--- packages/effect-fc/src/Async.ts | 1 + packages/effect-fc/src/Component.ts | 13 ++++++++----- packages/effect-fc/src/Form.ts | 3 ++- .../effect-fc/src/Hooks/useCallbackPromise.ts | 2 ++ packages/effect-fc/src/Hooks/useCallbackSync.ts | 2 ++ packages/effect-fc/src/Hooks/useEffect.ts | 3 ++- packages/effect-fc/src/Hooks/useFork.ts | 1 + packages/effect-fc/src/Hooks/useLayoutEffect.ts | 3 ++- packages/effect-fc/src/Hooks/useMemo.ts | 1 + packages/effect-fc/src/Hooks/useRefState.ts | 2 +- packages/effect-fc/src/Hooks/useScope.ts | 4 +++- .../effect-fc/src/Hooks/useSubscribeStream.ts | 1 + packages/effect-fc/src/Memoized.ts | 1 + packages/effect-fc/src/ReactRuntime.ts | 16 ++++++++-------- 16 files changed, 48 insertions(+), 22 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 72446f4..723e209 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,6 @@ { - "typescript.tsdk": "node_modules/typescript/lib" + "typescript.tsdk": "node_modules/typescript/lib", + "editor.codeActionsOnSave": { + "source.fixAll.biome": "explicit" + } } diff --git a/biome.json b/biome.json index c59f6d7..d76a607 100644 --- a/biome.json +++ b/biome.json @@ -9,13 +9,19 @@ "ignoreUnknown": false }, "formatter": { - "enabled": false, - "indentStyle": "tab" + "enabled": false }, "linter": { "enabled": true, "rules": { - "recommended": true + "recommended": true, + "style": { + "useShorthandFunctionType": "off" + }, + "suspicious": { + "noExplicitAny": "off", + "noShadowRestrictedNames": "off" + } } }, "javascript": { diff --git a/packages/effect-fc/src/Async.ts b/packages/effect-fc/src/Async.ts index 22fe2f1..19c1912 100644 --- a/packages/effect-fc/src/Async.ts +++ b/packages/effect-fc/src/Async.ts @@ -1,3 +1,4 @@ +/** biome-ignore-all lint/complexity/useArrowFunction: necessary for class prototypes */ import { Effect, Function, Predicate, Runtime, Scope } from "effect" import * as React from "react" import type * as Component from "./Component.js" diff --git a/packages/effect-fc/src/Component.ts b/packages/effect-fc/src/Component.ts index 061acad..297cd38 100644 --- a/packages/effect-fc/src/Component.ts +++ b/packages/effect-fc/src/Component.ts @@ -1,3 +1,5 @@ +/** biome-ignore-all lint/complexity/noBannedTypes: {} is the default type for React props */ +/** biome-ignore-all lint/complexity/useArrowFunction: necessary for class prototypes */ import { Context, Effect, Effectable, ExecutionStrategy, Function, Predicate, Runtime, Scope, Tracer, type Types, type Utils } from "effect" import * as React from "react" import * as Hooks from "./Hooks/index.js" @@ -12,12 +14,12 @@ extends Effect.Effect<(props: P) => A, never, Exclude>, Component.Options { - new(_: never): {} + new(_: never): Record readonly [TypeId]: TypeId - readonly ["~Props"]: P - readonly ["~Success"]: A - readonly ["~Error"]: E - readonly ["~Context"]: R + readonly "~Props": P + readonly "~Success": A + readonly "~Error": E + readonly "~Context": R /** @internal */ readonly body: (props: P) => Effect.Effect @@ -53,6 +55,7 @@ const ComponentProto = Object.freeze({ this: Component ) { const self = this + // biome-ignore lint/style/noNonNullAssertion: context initialization const runtimeRef = React.useRef>>(null!) runtimeRef.current = yield* Effect.runtime>() diff --git a/packages/effect-fc/src/Form.ts b/packages/effect-fc/src/Form.ts index 94d91b4..57ed027 100644 --- a/packages/effect-fc/src/Form.ts +++ b/packages/effect-fc/src/Form.ts @@ -1,5 +1,5 @@ import * as AsyncData from "@typed/async-data" -import { Array, Cause, Chunk, Duration, Effect, Equal, Exit, Fiber, flow, identity, Option, ParseResult, pipe, Pipeable, Predicate, Ref, Schema, Scope, Stream, Subscribable, SubscriptionRef } from "effect" +import { Array, Cause, Chunk, type Duration, Effect, Equal, Exit, Fiber, flow, identity, Option, ParseResult, Pipeable, Predicate, pipe, Ref, Schema, type Scope, Stream, type Subscribable, SubscriptionRef } from "effect" import type { NoSuchElementException } from "effect/Cause" import * as React from "react" import * as Hooks from "./Hooks/index.js" @@ -287,6 +287,7 @@ export const useField = , PropertyPath.ValueFromPath +// biome-ignore lint/correctness/useExhaustiveDependencies: individual path components need to be compared > => React.useMemo(() => field(self, path), [self, ...path]) export namespace useInput { diff --git a/packages/effect-fc/src/Hooks/useCallbackPromise.ts b/packages/effect-fc/src/Hooks/useCallbackPromise.ts index 51b99ec..0e2ce10 100644 --- a/packages/effect-fc/src/Hooks/useCallbackPromise.ts +++ b/packages/effect-fc/src/Hooks/useCallbackPromise.ts @@ -11,8 +11,10 @@ export const useCallbackPromise: { callback: (...args: Args) => Effect.Effect, deps: React.DependencyList, ) { + // biome-ignore lint/style/noNonNullAssertion: context initialization const runtimeRef = React.useRef>(null!) runtimeRef.current = yield* Effect.runtime() + // biome-ignore lint/correctness/useExhaustiveDependencies: use of React.DependencyList return React.useCallback((...args: Args) => Runtime.runPromise(runtimeRef.current)(callback(...args)), deps) }) diff --git a/packages/effect-fc/src/Hooks/useCallbackSync.ts b/packages/effect-fc/src/Hooks/useCallbackSync.ts index d3ae332..3f96641 100644 --- a/packages/effect-fc/src/Hooks/useCallbackSync.ts +++ b/packages/effect-fc/src/Hooks/useCallbackSync.ts @@ -11,8 +11,10 @@ export const useCallbackSync: { callback: (...args: Args) => Effect.Effect, deps: React.DependencyList, ) { + // biome-ignore lint/style/noNonNullAssertion: context initialization const runtimeRef = React.useRef>(null!) runtimeRef.current = yield* Effect.runtime() + // biome-ignore lint/correctness/useExhaustiveDependencies: use of React.DependencyList return React.useCallback((...args: Args) => Runtime.runSync(runtimeRef.current)(callback(...args)), deps) }) diff --git a/packages/effect-fc/src/Hooks/useEffect.ts b/packages/effect-fc/src/Hooks/useEffect.ts index b2de7e3..b325479 100644 --- a/packages/effect-fc/src/Hooks/useEffect.ts +++ b/packages/effect-fc/src/Hooks/useEffect.ts @@ -1,7 +1,7 @@ import { Effect, ExecutionStrategy, Runtime, Scope } from "effect" import * as React from "react" -import type { ScopeOptions } from "./ScopeOptions.js" import { closeScope } from "./internal.js" +import type { ScopeOptions } from "./ScopeOptions.js" export const useEffect: { @@ -24,5 +24,6 @@ export const useEffect: { () => closeScope(scope, runtime, options) ), Runtime.runSync(runtime), + // biome-ignore lint/correctness/useExhaustiveDependencies: use of React.DependencyList ), deps) }) diff --git a/packages/effect-fc/src/Hooks/useFork.ts b/packages/effect-fc/src/Hooks/useFork.ts index 3365c0b..0ce8a5c 100644 --- a/packages/effect-fc/src/Hooks/useFork.ts +++ b/packages/effect-fc/src/Hooks/useFork.ts @@ -27,5 +27,6 @@ export const useFork: { ...options, finalizerExecutionMode: options?.finalizerExecutionMode ?? "fork", }) + // biome-ignore lint/correctness/useExhaustiveDependencies: use of React.DependencyList }, deps) }) diff --git a/packages/effect-fc/src/Hooks/useLayoutEffect.ts b/packages/effect-fc/src/Hooks/useLayoutEffect.ts index 93f0302..6f8c438 100644 --- a/packages/effect-fc/src/Hooks/useLayoutEffect.ts +++ b/packages/effect-fc/src/Hooks/useLayoutEffect.ts @@ -1,7 +1,7 @@ import { Effect, ExecutionStrategy, Runtime, Scope } from "effect" import * as React from "react" -import type { ScopeOptions } from "./ScopeOptions.js" import { closeScope } from "./internal.js" +import type { ScopeOptions } from "./ScopeOptions.js" export const useLayoutEffect: { @@ -24,5 +24,6 @@ export const useLayoutEffect: { () => closeScope(scope, runtime, options) ), Runtime.runSync(runtime), + // biome-ignore lint/correctness/useExhaustiveDependencies: use of React.DependencyList ), deps) }) diff --git a/packages/effect-fc/src/Hooks/useMemo.ts b/packages/effect-fc/src/Hooks/useMemo.ts index c12dd02..43d4449 100644 --- a/packages/effect-fc/src/Hooks/useMemo.ts +++ b/packages/effect-fc/src/Hooks/useMemo.ts @@ -12,5 +12,6 @@ export const useMemo: { deps: React.DependencyList, ) { const runtime = yield* Effect.runtime() + // biome-ignore lint/correctness/useExhaustiveDependencies: use of React.DependencyList return yield* React.useMemo(() => Runtime.runSync(runtime)(Effect.cached(factory())), deps) }) diff --git a/packages/effect-fc/src/Hooks/useRefState.ts b/packages/effect-fc/src/Hooks/useRefState.ts index e6bae8b..9e55fbf 100644 --- a/packages/effect-fc/src/Hooks/useRefState.ts +++ b/packages/effect-fc/src/Hooks/useRefState.ts @@ -1,4 +1,4 @@ -import { Effect, Equivalence, Ref, Stream, SubscriptionRef } from "effect" +import { Effect, Equivalence, Ref, Stream, type SubscriptionRef } from "effect" import * as React from "react" import * as SetStateAction from "../SetStateAction.js" import { useCallbackSync } from "./useCallbackSync.js" diff --git a/packages/effect-fc/src/Hooks/useScope.ts b/packages/effect-fc/src/Hooks/useScope.ts index f475885..93212a0 100644 --- a/packages/effect-fc/src/Hooks/useScope.ts +++ b/packages/effect-fc/src/Hooks/useScope.ts @@ -1,7 +1,7 @@ import { Effect, ExecutionStrategy, Ref, Runtime, Scope } from "effect" import * as React from "react" -import type { ScopeOptions } from "./ScopeOptions.js" import { closeScope } from "./internal.js" +import type { ScopeOptions } from "./ScopeOptions.js" export const useScope: { @@ -12,6 +12,7 @@ export const useScope: { } = Effect.fnUntraced(function*(deps, options) { const runtime = yield* Effect.runtime() + // biome-ignore lint/correctness/useExhaustiveDependencies: no reactivity needed const [isInitialRun, initialScope] = React.useMemo(() => Runtime.runSync(runtime)(Effect.all([ Ref.make(true), Scope.make(options?.finalizerExecutionStrategy ?? ExecutionStrategy.sequential), @@ -30,6 +31,7 @@ export const useScope: { Effect.map(scope => () => closeScope(scope, runtime, options)), ), }) + // biome-ignore lint/correctness/useExhaustiveDependencies: use of React.DependencyList ), deps) return scope diff --git a/packages/effect-fc/src/Hooks/useSubscribeStream.ts b/packages/effect-fc/src/Hooks/useSubscribeStream.ts index d84b4ab..252054f 100644 --- a/packages/effect-fc/src/Hooks/useSubscribeStream.ts +++ b/packages/effect-fc/src/Hooks/useSubscribeStream.ts @@ -16,6 +16,7 @@ export const useSubscribeStream: { initialValue?: A, ) { const [reactStateValue, setReactStateValue] = React.useState( + // biome-ignore lint/correctness/useExhaustiveDependencies: no reactivity needed React.useMemo(() => initialValue ? Option.some(initialValue) : Option.none(), diff --git a/packages/effect-fc/src/Memoized.ts b/packages/effect-fc/src/Memoized.ts index c80a3e0..7ed205f 100644 --- a/packages/effect-fc/src/Memoized.ts +++ b/packages/effect-fc/src/Memoized.ts @@ -1,3 +1,4 @@ +/** biome-ignore-all lint/complexity/useArrowFunction: necessary for class prototypes */ import { type Equivalence, Function, Predicate } from "effect" import type * as Component from "./Component.js" diff --git a/packages/effect-fc/src/ReactRuntime.ts b/packages/effect-fc/src/ReactRuntime.ts index 7689275..64f1af9 100644 --- a/packages/effect-fc/src/ReactRuntime.ts +++ b/packages/effect-fc/src/ReactRuntime.ts @@ -1,3 +1,4 @@ +/** biome-ignore-all lint/complexity/useArrowFunction: necessary for class prototypes */ import { Effect, type Layer, ManagedRuntime, Predicate, type Runtime } from "effect" import * as React from "react" @@ -6,7 +7,7 @@ export const TypeId: unique symbol = Symbol.for("effect-fc/ReactRuntime") export type TypeId = typeof TypeId export interface ReactRuntime { - new(_: never): {} + new(_: never): Record readonly [TypeId]: TypeId readonly runtime: ManagedRuntime.ManagedRuntime readonly context: React.Context> @@ -23,6 +24,7 @@ export const make = ( ): ReactRuntime => Object.setPrototypeOf( Object.assign(function() {}, { runtime: ManagedRuntime.make(layer, memoMap), + // biome-ignore lint/style/noNonNullAssertion: context initialization context: React.createContext>(null!), }), ReactRuntimeProto, @@ -48,16 +50,14 @@ export const Provider = ( ) } -namespace ProviderInner { - export interface Props { - readonly runtime: ReactRuntime - readonly promise: Promise> - readonly children?: React.ReactNode - } +interface ProviderInnerProps { + readonly runtime: ReactRuntime + readonly promise: Promise> + readonly children?: React.ReactNode } const ProviderInner = ( - { runtime, promise, children }: ProviderInner.Props + { runtime, promise, children }: ProviderInnerProps ): React.ReactNode => React.createElement( runtime.context, { value: React.use(promise) },