Suggests Effect.catchNoSuchElement instead of wrapping successes in Option.some and catching NoSuchElementError into Option.none
| Property | Value |
|---|---|
| Category | Style |
| Default severity | suggestion |
| Fixable | Yes |
| Effect versions | v4 |
| Diagnostic codes | TS377167 |
| Language Service name | mapSomeCatchNoSuchElement |
| Oxlint name | effecttsgo/map-some-catch-no-such-element |
import { Effect, Option } from "effect"
const users = new Map<string, { readonly name: string }>()
const findUser = (id: string) => Effect.fromNullishOr(users.get(id))
export const lookupUser = (id: string) =>
findUser(id).pipe(
Effect.map(Option.some),
Effect.catchTag("NoSuchElementError", () => Effect.succeed(Option.none()))
/**
^^^^^^^^^^^^^^^ effecttsgo(map-some-catch-no-such-element): Use Effect.catchNoSuchElement instead of wrapping successes in Option.some and catching NoSuchElementError into Option.none.
*/
)See the Language Service setup guide for installation instructions.
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/map-some-catch-no-such-element": "warn"
}
}
{ "$schema": "./node_modules/@effect/tsgo/schema.json", "compilerOptions": { "plugins": [ { "name": "@effect/language-service", "diagnosticSeverity": { "mapSomeCatchNoSuchElement": "warning" } } ] } }