Suggests Effect.fromOption when Option.match or an Option tag conditional only converts Some to Effect.succeed and None to Effect.fail
| Property | Value |
|---|---|
| Category | Style |
| Default severity | suggestion |
| Fixable | Yes |
| Effect versions | v4 |
| Diagnostic codes | TS377118 |
| Language Service name | optionMatchToFromOption |
| Oxlint name | effecttsgo/option-match-to-from-option |
import { Data, Effect, Option } from "effect"
class UserNotFound extends Data.TaggedError("UserNotFound")<{
readonly id: string
}> {}
declare const findUser: (id: string) => Option.Option<{ readonly name: string }>
export const getUser = (id: string) =>
Option.match(findUser(id), {
/**
^^^^^^^^^^^^ effecttsgo(option-match-to-from-option): `Effect.fromOption` expresses this Option-to-Effect conversion more directly than `Option.match` or an Option tag conditional.
*/
onNone: () => Effect.fail(new UserNotFound({ id })),
onSome: (user) => Effect.succeed(user)
})See the Language Service setup guide for installation instructions.
See the Oxlint setup guide for installation and patching instructions.
{
"$schema": "./node_modules/@effect/tsgo/oxlint-schema.json",
"options": {
"typeAware": true
},
"plugins": ["effecttsgo"],
"rules": {
"effecttsgo/option-match-to-from-option": "warn"
}
}
{ "$schema": "./node_modules/@effect/tsgo/schema.json", "compilerOptions": { "plugins": [ { "name": "@effect/language-service", "diagnosticSeverity": { "optionMatchToFromOption": "warning" } } ] } }