Skip to content

Latest commit

 

History

History
65 lines (53 loc) · 1.56 KB

instance-of-schema.md

File metadata and controls

65 lines (53 loc) · 1.56 KB

instanceOfSchema

Suggests using Schema.is instead of instanceof for Effect Schema types

Property Value
Category Effect-native
Default severity off
Fixable Yes
Effect versions v3, v4
Diagnostic codes TS377042
Language Service name instanceOfSchema
Oxlint name effecttsgo/instance-of-schema

Preview

import { Schema as S } from "effect"

class User extends S.Class<User>("User")({ name: S.String }) {}
declare const value: unknown
export const preview = value instanceof User
/**
                       ^^^^^^^^^^^^^^^^^^^^^ effecttsgo(instance-of-schema): This code uses `instanceof` with an Effect Schema type. `Schema.is` is the schema-aware runtime check for this case.
*/

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": {
          "instanceOfSchema": "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/instance-of-schema": "warn"
  }
}