TRAITS

unwrap-presence-only-options

When an Option is used only to check presence and access its value, unwrap it with Option.getOrUndefined rather than repeatedly using Option.isSome and .value: yield* effect.pipe(Effect.map(Option.getOrUndefined)). Access the value directly and use explicit undefined checks where strict-boolean linting requires them. Retain Option when its combinators or distinction between Some(undefined) and None are needed.

Applies when
using Option only to test presence and access the contained value.
File types
  • TypeScript
  • TSX
ID
6edef001-f09f-4783-8d1a-8fd3b526ecf6
Source
.agents/traits/unwrap-presence-only-options-6edef001-f09f-4783-8d1a-8fd3b526ecf6.md

Skipping this trait

Add this comment before any code to skip the trait for a whole file. A reason is required.

File header
// traits-ignore-file 6edef001-f09f-4783-8d1a-8fd3b526ecf6: <reason>