Linter fixes
Some checks failed
Lint / lint (push) Failing after 12s

This commit is contained in:
Julien Valverdé
2025-10-01 18:58:25 +02:00
parent 42c8302705
commit a5df6d04c0
16 changed files with 48 additions and 22 deletions

View File

@@ -1,3 +1,6 @@
{ {
"typescript.tsdk": "node_modules/typescript/lib" "typescript.tsdk": "node_modules/typescript/lib",
"editor.codeActionsOnSave": {
"source.fixAll.biome": "explicit"
}
} }

View File

@@ -9,13 +9,19 @@
"ignoreUnknown": false "ignoreUnknown": false
}, },
"formatter": { "formatter": {
"enabled": false, "enabled": false
"indentStyle": "tab"
}, },
"linter": { "linter": {
"enabled": true, "enabled": true,
"rules": { "rules": {
"recommended": true "recommended": true,
"style": {
"useShorthandFunctionType": "off"
},
"suspicious": {
"noExplicitAny": "off",
"noShadowRestrictedNames": "off"
}
} }
}, },
"javascript": { "javascript": {

View File

@@ -1,3 +1,4 @@
/** biome-ignore-all lint/complexity/useArrowFunction: necessary for class prototypes */
import { Effect, Function, Predicate, Runtime, Scope } from "effect" import { Effect, Function, Predicate, Runtime, Scope } from "effect"
import * as React from "react" import * as React from "react"
import type * as Component from "./Component.js" import type * as Component from "./Component.js"

View File

@@ -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 { Context, Effect, Effectable, ExecutionStrategy, Function, Predicate, Runtime, Scope, Tracer, type Types, type Utils } from "effect"
import * as React from "react" import * as React from "react"
import * as Hooks from "./Hooks/index.js" import * as Hooks from "./Hooks/index.js"
@@ -12,12 +14,12 @@ extends
Effect.Effect<(props: P) => A, never, Exclude<R, Scope.Scope>>, Effect.Effect<(props: P) => A, never, Exclude<R, Scope.Scope>>,
Component.Options Component.Options
{ {
new(_: never): {} new(_: never): Record<string, never>
readonly [TypeId]: TypeId readonly [TypeId]: TypeId
readonly ["~Props"]: P readonly "~Props": P
readonly ["~Success"]: A readonly "~Success": A
readonly ["~Error"]: E readonly "~Error": E
readonly ["~Context"]: R readonly "~Context": R
/** @internal */ /** @internal */
readonly body: (props: P) => Effect.Effect<A, E, R> readonly body: (props: P) => Effect.Effect<A, E, R>
@@ -53,6 +55,7 @@ const ComponentProto = Object.freeze({
this: Component<P, A, E, R> this: Component<P, A, E, R>
) { ) {
const self = this const self = this
// biome-ignore lint/style/noNonNullAssertion: context initialization
const runtimeRef = React.useRef<Runtime.Runtime<Exclude<R, Scope.Scope>>>(null!) const runtimeRef = React.useRef<Runtime.Runtime<Exclude<R, Scope.Scope>>>(null!)
runtimeRef.current = yield* Effect.runtime<Exclude<R, Scope.Scope>>() runtimeRef.current = yield* Effect.runtime<Exclude<R, Scope.Scope>>()

View File

@@ -1,5 +1,5 @@
import * as AsyncData from "@typed/async-data" 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 type { NoSuchElementException } from "effect/Cause"
import * as React from "react" import * as React from "react"
import * as Hooks from "./Hooks/index.js" import * as Hooks from "./Hooks/index.js"
@@ -287,6 +287,7 @@ export const useField = <A, I, R, SA, SE, SR, const P extends PropertyPath.Paths
): FormField< ): FormField<
PropertyPath.ValueFromPath<A, P>, PropertyPath.ValueFromPath<A, P>,
PropertyPath.ValueFromPath<I, P> PropertyPath.ValueFromPath<I, P>
// biome-ignore lint/correctness/useExhaustiveDependencies: individual path components need to be compared
> => React.useMemo(() => field(self, path), [self, ...path]) > => React.useMemo(() => field(self, path), [self, ...path])
export namespace useInput { export namespace useInput {

View File

@@ -11,8 +11,10 @@ export const useCallbackPromise: {
callback: (...args: Args) => Effect.Effect<A, E, R>, callback: (...args: Args) => Effect.Effect<A, E, R>,
deps: React.DependencyList, deps: React.DependencyList,
) { ) {
// biome-ignore lint/style/noNonNullAssertion: context initialization
const runtimeRef = React.useRef<Runtime.Runtime<R>>(null!) const runtimeRef = React.useRef<Runtime.Runtime<R>>(null!)
runtimeRef.current = yield* Effect.runtime<R>() runtimeRef.current = yield* Effect.runtime<R>()
// biome-ignore lint/correctness/useExhaustiveDependencies: use of React.DependencyList
return React.useCallback((...args: Args) => Runtime.runPromise(runtimeRef.current)(callback(...args)), deps) return React.useCallback((...args: Args) => Runtime.runPromise(runtimeRef.current)(callback(...args)), deps)
}) })

View File

@@ -11,8 +11,10 @@ export const useCallbackSync: {
callback: (...args: Args) => Effect.Effect<A, E, R>, callback: (...args: Args) => Effect.Effect<A, E, R>,
deps: React.DependencyList, deps: React.DependencyList,
) { ) {
// biome-ignore lint/style/noNonNullAssertion: context initialization
const runtimeRef = React.useRef<Runtime.Runtime<R>>(null!) const runtimeRef = React.useRef<Runtime.Runtime<R>>(null!)
runtimeRef.current = yield* Effect.runtime<R>() runtimeRef.current = yield* Effect.runtime<R>()
// biome-ignore lint/correctness/useExhaustiveDependencies: use of React.DependencyList
return React.useCallback((...args: Args) => Runtime.runSync(runtimeRef.current)(callback(...args)), deps) return React.useCallback((...args: Args) => Runtime.runSync(runtimeRef.current)(callback(...args)), deps)
}) })

View File

@@ -1,7 +1,7 @@
import { Effect, ExecutionStrategy, Runtime, Scope } from "effect" import { Effect, ExecutionStrategy, Runtime, Scope } from "effect"
import * as React from "react" import * as React from "react"
import type { ScopeOptions } from "./ScopeOptions.js"
import { closeScope } from "./internal.js" import { closeScope } from "./internal.js"
import type { ScopeOptions } from "./ScopeOptions.js"
export const useEffect: { export const useEffect: {
@@ -24,5 +24,6 @@ export const useEffect: {
() => closeScope(scope, runtime, options) () => closeScope(scope, runtime, options)
), ),
Runtime.runSync(runtime), Runtime.runSync(runtime),
// biome-ignore lint/correctness/useExhaustiveDependencies: use of React.DependencyList
), deps) ), deps)
}) })

View File

@@ -27,5 +27,6 @@ export const useFork: {
...options, ...options,
finalizerExecutionMode: options?.finalizerExecutionMode ?? "fork", finalizerExecutionMode: options?.finalizerExecutionMode ?? "fork",
}) })
// biome-ignore lint/correctness/useExhaustiveDependencies: use of React.DependencyList
}, deps) }, deps)
}) })

View File

@@ -1,7 +1,7 @@
import { Effect, ExecutionStrategy, Runtime, Scope } from "effect" import { Effect, ExecutionStrategy, Runtime, Scope } from "effect"
import * as React from "react" import * as React from "react"
import type { ScopeOptions } from "./ScopeOptions.js"
import { closeScope } from "./internal.js" import { closeScope } from "./internal.js"
import type { ScopeOptions } from "./ScopeOptions.js"
export const useLayoutEffect: { export const useLayoutEffect: {
@@ -24,5 +24,6 @@ export const useLayoutEffect: {
() => closeScope(scope, runtime, options) () => closeScope(scope, runtime, options)
), ),
Runtime.runSync(runtime), Runtime.runSync(runtime),
// biome-ignore lint/correctness/useExhaustiveDependencies: use of React.DependencyList
), deps) ), deps)
}) })

View File

@@ -12,5 +12,6 @@ export const useMemo: {
deps: React.DependencyList, deps: React.DependencyList,
) { ) {
const runtime = yield* Effect.runtime() 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) return yield* React.useMemo(() => Runtime.runSync(runtime)(Effect.cached(factory())), deps)
}) })

View File

@@ -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 React from "react"
import * as SetStateAction from "../SetStateAction.js" import * as SetStateAction from "../SetStateAction.js"
import { useCallbackSync } from "./useCallbackSync.js" import { useCallbackSync } from "./useCallbackSync.js"

View File

@@ -1,7 +1,7 @@
import { Effect, ExecutionStrategy, Ref, Runtime, Scope } from "effect" import { Effect, ExecutionStrategy, Ref, Runtime, Scope } from "effect"
import * as React from "react" import * as React from "react"
import type { ScopeOptions } from "./ScopeOptions.js"
import { closeScope } from "./internal.js" import { closeScope } from "./internal.js"
import type { ScopeOptions } from "./ScopeOptions.js"
export const useScope: { export const useScope: {
@@ -12,6 +12,7 @@ export const useScope: {
} = Effect.fnUntraced(function*(deps, options) { } = Effect.fnUntraced(function*(deps, options) {
const runtime = yield* Effect.runtime() const runtime = yield* Effect.runtime()
// biome-ignore lint/correctness/useExhaustiveDependencies: no reactivity needed
const [isInitialRun, initialScope] = React.useMemo(() => Runtime.runSync(runtime)(Effect.all([ const [isInitialRun, initialScope] = React.useMemo(() => Runtime.runSync(runtime)(Effect.all([
Ref.make(true), Ref.make(true),
Scope.make(options?.finalizerExecutionStrategy ?? ExecutionStrategy.sequential), Scope.make(options?.finalizerExecutionStrategy ?? ExecutionStrategy.sequential),
@@ -30,6 +31,7 @@ export const useScope: {
Effect.map(scope => () => closeScope(scope, runtime, options)), Effect.map(scope => () => closeScope(scope, runtime, options)),
), ),
}) })
// biome-ignore lint/correctness/useExhaustiveDependencies: use of React.DependencyList
), deps) ), deps)
return scope return scope

View File

@@ -16,6 +16,7 @@ export const useSubscribeStream: {
initialValue?: A, initialValue?: A,
) { ) {
const [reactStateValue, setReactStateValue] = React.useState( const [reactStateValue, setReactStateValue] = React.useState(
// biome-ignore lint/correctness/useExhaustiveDependencies: no reactivity needed
React.useMemo(() => initialValue React.useMemo(() => initialValue
? Option.some(initialValue) ? Option.some(initialValue)
: Option.none(), : Option.none(),

View File

@@ -1,3 +1,4 @@
/** biome-ignore-all lint/complexity/useArrowFunction: necessary for class prototypes */
import { type Equivalence, Function, Predicate } from "effect" import { type Equivalence, Function, Predicate } from "effect"
import type * as Component from "./Component.js" import type * as Component from "./Component.js"

View File

@@ -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 { Effect, type Layer, ManagedRuntime, Predicate, type Runtime } from "effect"
import * as React from "react" 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 type TypeId = typeof TypeId
export interface ReactRuntime<R, ER> { export interface ReactRuntime<R, ER> {
new(_: never): {} new(_: never): Record<string, never>
readonly [TypeId]: TypeId readonly [TypeId]: TypeId
readonly runtime: ManagedRuntime.ManagedRuntime<R, ER> readonly runtime: ManagedRuntime.ManagedRuntime<R, ER>
readonly context: React.Context<Runtime.Runtime<R>> readonly context: React.Context<Runtime.Runtime<R>>
@@ -23,6 +24,7 @@ export const make = <R, ER>(
): ReactRuntime<R, ER> => Object.setPrototypeOf( ): ReactRuntime<R, ER> => Object.setPrototypeOf(
Object.assign(function() {}, { Object.assign(function() {}, {
runtime: ManagedRuntime.make(layer, memoMap), runtime: ManagedRuntime.make(layer, memoMap),
// biome-ignore lint/style/noNonNullAssertion: context initialization
context: React.createContext<Runtime.Runtime<R>>(null!), context: React.createContext<Runtime.Runtime<R>>(null!),
}), }),
ReactRuntimeProto, ReactRuntimeProto,
@@ -48,16 +50,14 @@ export const Provider = <R, ER>(
) )
} }
namespace ProviderInner { interface ProviderInnerProps<R, ER> {
export interface Props<R, ER> { readonly runtime: ReactRuntime<R, ER>
readonly runtime: ReactRuntime<R, ER> readonly promise: Promise<Runtime.Runtime<R>>
readonly promise: Promise<Runtime.Runtime<R>> readonly children?: React.ReactNode
readonly children?: React.ReactNode
}
} }
const ProviderInner = <R, ER>( const ProviderInner = <R, ER>(
{ runtime, promise, children }: ProviderInner.Props<R, ER> { runtime, promise, children }: ProviderInnerProps<R, ER>
): React.ReactNode => React.createElement( ): React.ReactNode => React.createElement(
runtime.context, runtime.context,
{ value: React.use(promise) }, { value: React.use(promise) },