Skip to content

Latest commit

 

History

History
75 lines (63 loc) · 1.66 KB

schema-struct-with-tag.md

File metadata and controls

75 lines (63 loc) · 1.66 KB

schemaStructWithTag

Suggests using Schema.TaggedStruct instead of Schema.Struct with _tag field

Property Value
Category Style
Default severity suggestion
Fixable Yes
Effect versions v3, v4
Diagnostic codes TS377036
Language Service name schemaStructWithTag
Oxlint name effecttsgo/schema-struct-with-tag

Preview

import * as Schema from "effect/Schema"

export const preview = Schema.Struct({
/**
                       ^^^^^^^^^^^^^^^ effecttsgo(schema-struct-with-tag): This `Schema.Struct` includes a `_tag` field. `Schema.TaggedStruct` is the tagged-struct form for this pattern and makes the tag optional in the constructor.
*/
  _tag: Schema.Literal("User"),
/**
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*/
  name: Schema.String
/**
^^^^^^^^^^^^^^^^^^^^^
*/
})
/**
^^
*/

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": {
          "schemaStructWithTag": "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/schema-struct-with-tag": "warn"
  }
}