preferSchemaOverJson

August 4, 2026 ยท View on GitHub

Suggests using Effect Schema for JSON operations instead of JSON.parse/JSON.stringify

PropertyValue
CategoryEffect-native
Default severityoff
FixableNo
Effect versionsv3, v4
Diagnostic codesTS377026
Language Service namepreferSchemaOverJson
Oxlint nameeffecttsgo/prefer-schema-over-json

Preview

import { Effect } from "effect"

export const preview = Effect.gen(function*() {
  const text = yield* Effect.succeed('{"ok":true}')
  return JSON.parse(text)
/**
         ^^^^^^^^^^^^^^^^ effecttsgo(prefer-schema-over-json): This code uses `JSON.parse` or `JSON.stringify`. Use `Schema.UnknownFromJsonString` for unknown shapes, `Schema.fromJsonString(schema)` for known ones, or `Schema.toCodecJson(schema)` when working with JSON values instead of strings.
*/
})

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": {
          "preferSchemaOverJson": "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-schema-over-json": "warn"
  }
}