Skip to content

Latest commit

 

History

History
65 lines (53 loc) · 1.7 KB

prefer-effect-record.md

File metadata and controls

65 lines (53 loc) · 1.7 KB

preferEffectRecord

Suggests Effect Record APIs for native Object member references, with semantic caveats

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

Preview

import * as Record from "effect/Record"

const scores = { alice: 1, bob: 2 }
export const native = Object.entries(scores)
/**
                             ^^^^^^^ effecttsgo(prefer-effect-record): Consider effect/Record.toEntries instead of native Object.entries. Requires a record rather than arrays or primitives; types entries with inferred keys and snapshots keys before reads, so getter or proxy mutations can change the result.
*/
export const preferred = Record.toEntries(scores)

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": {
          "preferEffectRecord": "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-record": "warn"
  }
}