preferSchemaOverJson
August 4, 2026 ยท View on GitHub
Suggests using Effect Schema for JSON operations instead of JSON.parse/JSON.stringify
| Property | Value |
|---|---|
| Category | Effect-native |
| Default severity | off |
| Fixable | No |
| Effect versions | v3, v4 |
| Diagnostic codes | TS377026 |
| Language Service name | preferSchemaOverJson |
| Oxlint name | effecttsgo/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"
}
}