Skip to content

fix(dead-export-finder): replace JSON.parse with Schema.parseJson#51

Merged
ryanbas21 merged 1 commit into
mainfrom
fix/prefer-schema-over-json-parse
May 13, 2026
Merged

fix(dead-export-finder): replace JSON.parse with Schema.parseJson#51
ryanbas21 merged 1 commit into
mainfrom
fix/prefer-schema-over-json-parse

Conversation

@ryanbas21
Copy link
Copy Markdown
Owner

Summary

  • Replaces raw JSON.parse calls with Schema.parseJson(Schema.Record(...)) in workspace-detector.ts
  • Resolves TS44 preferSchemaOverJson diagnostic from the Effect Language Service
  • Both call sites preserve their original error handling: lenient (returns null) in readPackageInfo, strict (raises WorkspaceNotFoundError) in detect

Test plan

  • tsc --noEmit passes with no errors
  • All 42 tests pass (pnpm test)
  • Pre-commit hooks (eslint, prettier, syncpack) pass

🤖 Generated with Claude Code

Resolves TS44 preferSchemaOverJson diagnostic by using Effect Schema
for JSON parsing in workspace-detector.ts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@pullfrog pullfrog Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No new issues found.

TL;DR — Mechanical refactor replacing JSON.parse with Schema.parseJson in workspace-detector.ts, resolving the Effect Language Service preferSchemaOverJson diagnostic. Error handling semantics are preserved at both call sites.

Key changes

  • Add JsonRecord schema for structured JSON parsing — Module-level Schema.parseJson(Schema.Record(...)) replaces ad-hoc JSON.parse + type cast
  • Port readPackageInfo to schema-based parsingEffect.flatMap with Schema.decodeUnknown replaces the try/catch block; the outer Effect.catchAll preserves the lenient null-return behavior
  • Port detect to schema-based parsingSchema.decodeUnknown + Effect.mapError replaces Effect.try, preserving the strict WorkspaceNotFoundError on parse failure

Summary | 1 file | 1 commit | base: mainfix/prefer-schema-over-json-parse

Pullfrog  | View workflow run𝕏

@ryanbas21 ryanbas21 merged commit 00b1a06 into main May 13, 2026
1 check passed
@ryanbas21 ryanbas21 deleted the fix/prefer-schema-over-json-parse branch May 13, 2026 23:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant