Skip to content

Latest commit

 

History

History
68 lines (55 loc) · 1.67 KB

match-boolean-to-is-success.md

File metadata and controls

68 lines (55 loc) · 1.67 KB

matchBooleanToIsSuccess

Suggests Effect.isSuccess or Effect.isFailure when Effect.match or Effect.matchEager folds to complementary boolean literals

Property Value
Category Style
Default severity suggestion
Fixable Yes
Effect versions v3, v4
Diagnostic codes TS377173, TS377174
Language Service name matchBooleanToIsSuccess
Oxlint name effecttsgo/match-boolean-to-is-success

Preview

import { Effect } from "effect"

declare const saveUser: Effect.Effect<void, Error>

export const saved = Effect.match(saveUser, {
/**
                     ^^^^^^^^^^^^ effecttsgo(match-boolean-to-is-success): `Effect.isSuccess` expresses this check more directly than `Effect.match` folding to complementary boolean literals.
*/
  onFailure: () => false,
  onSuccess: () => true
})

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": {
          "matchBooleanToIsSuccess": "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/match-boolean-to-is-success": "warn"
  }
}