Skip to content

Latest commit

 

History

History
68 lines (55 loc) · 1.76 KB

result-match-to-from-result.md

File metadata and controls

68 lines (55 loc) · 1.76 KB

resultMatchToFromResult

Suggests Effect.fromResult when Result.match or a Result guard conditional only converts Success to Effect.succeed and Failure to Effect.fail

Property Value
Category Style
Default severity suggestion
Fixable Yes
Effect versions v4
Diagnostic codes TS377165
Language Service name resultMatchToFromResult
Oxlint name effecttsgo/result-match-to-from-result

Preview

import { Effect, Result } from "effect"

declare const parsePort: (raw: string) => Result.Result<number, Error>

export const port = Result.match(parsePort("8080"), {
/**
                    ^^^^^^^^^^^^ effecttsgo(result-match-to-from-result): `Effect.fromResult` expresses this Result-to-Effect conversion more directly than `Result.match` or a Result guard conditional.
*/
  onFailure: (error) => Effect.fail(error),
  onSuccess: (value) => Effect.succeed(value)
})

Language Service Configuration

See the Language Service setup guide for installation instructions.

{
  "$schema": "./node_modules/@effect/tsgo/schema.json",
  "compilerOptions": {
    "plugins": [
      {
        "name": "@effect/language-service",
        "diagnosticSeverity": {
          "resultMatchToFromResult": "warning"
        }
      }
    ]
  }
}

Oxlint Configuration

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/result-match-to-from-result": "warn"
  }
}