Skip to content

Latest commit

 

History

History
65 lines (53 loc) · 1.63 KB

prefer-effect-array.md

File metadata and controls

65 lines (53 loc) · 1.63 KB

preferEffectArray

Suggests Effect Array APIs for native array member references, with semantic caveats

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

Preview

import * as A from "effect/Array"

const values = [1, 2, 3]
export const native = values.find(n => n > 1)
/**
                             ^^^^ effecttsgo(prefer-effect-array): Consider effect/Array.findFirst instead of native Array.find. Returns Option, with None replacing undefined; the callback type accepts (value, index), with no array parameter or thisArg.
*/
export const preferred = A.findFirst(values, n => n > 1)

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": {
          "preferEffectArray": "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-array": "warn"
  }
}