Skip to content

Latest commit

 

History

History
65 lines (53 loc) · 1.6 KB

prefer-effect-string.md

File metadata and controls

65 lines (53 loc) · 1.6 KB

preferEffectString

Suggests Effect String APIs for native String method invocations, with semantic caveats

Property Value
Category Effect-native
Default severity off
Fixable No
Effect versions v3, v4
Diagnostic codes TS377150
Language Service name preferEffectString
Oxlint name effecttsgo/prefer-effect-string

Preview

import * as Str from "effect/String"

const email = "[email protected]"
export const native = email.indexOf("@")
/**
                            ^^^^^^^ effecttsgo(prefer-effect-string): Consider effect/String.indexOf instead of native String.indexOf. Returns Option<number>, with None replacing -1; there is no position parameter.
*/
export const preferred = Str.indexOf("@")(email)

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": {
          "preferEffectString": "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/prefer-effect-string": "warn"
  }
}