Skip to content

fix: import order violation in ESM modules and untyped API response - #818

Open
saurabhhhcodes wants to merge 1 commit into
Aditya948351:masterfrom
saurabhhhcodes:fix/devpath-batch-5
Open

fix: import order violation in ESM modules and untyped API response#818
saurabhhhcodes wants to merge 1 commit into
Aditya948351:masterfrom
saurabhhhcodes:fix/devpath-batch-5

Conversation

@saurabhhhcodes

Copy link
Copy Markdown
Contributor

Bugs fixed:

  1. ESM import order violation (RealTimeContext.tsx): AVATAR_API constant declared before import statement — invalid ESM syntax that can break strict build tools.

  2. ESM import order violation (InteractiveBackground.tsx): Same pattern — DEVPATH_API constant declared before imports.

  3. Untyped API response (CodingNews.tsx): setNews(data) accepted arbitrary JSON without validating it matches NewsItem[]. Added array check with graceful fallback to FALLBACK_NEWS.

Verification:

  • No more import-before-code lint/compile errors
  • News API responses validated before setting state
  • Fallback news shown gracefully on API format mismatch

- Move AVATAR_API constant after imports in RealTimeContext.tsx (invalid
  ESM — imports must precede all code)
- Move DEVPATH_API constant after imports in InteractiveBackground.tsx
  (same ESM violation)
- Guard setNews(data) in CodingNews.tsx: validate that API response is
  an array before setting; fall back to FALLBACK_NEWS on mismatch
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