Skip to content

fix: resolve ESLint no-explicit-any errors in prompts.json route#1090

Open
mksglu wants to merge 1 commit intof:mainfrom
mksglu:fix/lint-errors-prompts-json
Open

fix: resolve ESLint no-explicit-any errors in prompts.json route#1090
mksglu wants to merge 1 commit intof:mainfrom
mksglu:fix/lint-errors-prompts-json

Conversation

@mksglu
Copy link
Contributor

@mksglu mksglu commented Mar 19, 2026

Summary

Fixes 2 ESLint no-explicit-any errors in src/app/prompts.json/route.ts that caused CI lint failure after #1086 merge.

Changes

- contributors: prompt.contributors.map((c: any) => ({
+ contributors: prompt.contributors.map((c: { username: string; name: string | null; avatar: string | null; githubUsername: string | null; verified: boolean }) => ({

- tags: prompt.tags.map((pt: any) => ({
+ tags: prompt.tags.map((pt: { tag: { id: string; name: string; slug: string; color: string | null } }) => ({

Verification

  • npx eslint . → 0 errors, 208 warnings (all pre-existing)
  • npx tsc --noEmit → 0 errors on this file

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Improved type safety and code maintainability through enhanced type annotations in data mapping processes.

Fixes ESLint no-explicit-any errors on contributors and tags map callbacks.

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

coderabbitai bot commented Mar 19, 2026

📝 Walkthrough

Walkthrough

Updated TypeScript type annotations in the prompts.json route handler for contributors and tags mapping logic. Changed from generic any-typed elements to explicit type shapes with named properties, improving type safety without altering mapped output or API behavior.

Changes

Cohort / File(s) Summary
TypeScript Type Annotations
src/app/prompts.json/route.ts
Added explicit inline TypeScript type annotations to contributors and tags mapping operations, replacing generic any types with structured object shapes containing specific properties.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Poem

A rabbit hops through types so clear,
No more any shadows here!
Contributors and tags now shine,
With explicit shapes so fine,
TypeScript wisdom, line by line! 🐰✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: resolving ESLint no-explicit-any errors in the prompts.json route file by replacing any types with explicit type annotations.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/app/prompts.json/route.ts`:
- Around line 193-200: Extract the inline callback parameter types used in the
contributors and tags mappings into named interfaces: create ContributorListItem
for the contributor shape (username, name, avatar, githubUsername, verified),
TagListItem for the inner tag shape (id, name, slug, color) and
PromptTagListItem for the wrapper used in prompt.tags; then update the mappings
in the contributors and tags callbacks to use these interfaces instead of inline
types and change color's type on TagListItem from string | null to string to
match the Prisma schema; reference getUserIdentifier in the contributors mapping
to ensure the identifier call remains unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 09dfcc72-4953-4560-95a6-ce8be2c2fb94

📥 Commits

Reviewing files that changed from the base of the PR and between 4ef6246 and abdc1b6.

📒 Files selected for processing (1)
  • src/app/prompts.json/route.ts

Comment on lines +193 to +200
contributors: prompt.contributors.map((c: { username: string; name: string | null; avatar: string | null; githubUsername: string | null; verified: boolean }) => ({
username: c.username,
name: c.name,
avatar: c.avatar,
identifier: getUserIdentifier(c),
verified: c.verified,
})),
tags: prompt.tags.map((pt: any) => ({
tags: prompt.tags.map((pt: { tag: { id: string; name: string; slug: string; color: string | null } }) => ({
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify inline object callback parameter types still exist in this route
rg -nP 'map\s*\(\s*\(\w+\s*:\s*\{[^)]*\}\)\s*=>\s*\(' src/app/prompts.json/route.ts

# Verify Tag.color nullability in Prisma schema
rg -n -A4 -B2 'model Tag|color\s+String' prisma/schema.prisma

Repository: f/prompts.chat

Length of output: 598


Extract inline object types into named interfaces and fix color type to match schema.

Lines 193 and 200 use inline object types as callback parameters, which violates the guideline "Use interface for object shapes". Additionally, line 200 incorrectly types color as string | null when the Prisma schema defines Tag.color as non-nullable String with a default value.

Extract the callback parameter types into named interfaces (ContributorListItem, TagListItem, and PromptTagListItem) and change color: string | null to color: string.

Suggested refactor
+interface ContributorListItem {
+  username: string;
+  name: string | null;
+  avatar: string | null;
+  githubUsername: string | null;
+  verified: boolean;
+}
+
+interface TagListItem {
+  id: string;
+  name: string;
+  slug: string;
+  color: string;
+}
+
+interface PromptTagListItem {
+  tag: TagListItem;
+}
...
-        contributors: prompt.contributors.map((c: { username: string; name: string | null; avatar: string | null; githubUsername: string | null; verified: boolean }) => ({
+        contributors: prompt.contributors.map((c: ContributorListItem) => ({
           username: c.username,
           name: c.name,
           avatar: c.avatar,
           identifier: getUserIdentifier(c),
           verified: c.verified,
         })),
-        tags: prompt.tags.map((pt: { tag: { id: string; name: string; slug: string; color: string | null } }) => ({
+        tags: prompt.tags.map((pt: PromptTagListItem) => ({
           id: pt.tag.id,
           name: pt.tag.name,
           slug: pt.tag.slug,
           color: pt.tag.color,
         })),
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app/prompts.json/route.ts` around lines 193 - 200, Extract the inline
callback parameter types used in the contributors and tags mappings into named
interfaces: create ContributorListItem for the contributor shape (username,
name, avatar, githubUsername, verified), TagListItem for the inner tag shape
(id, name, slug, color) and PromptTagListItem for the wrapper used in
prompt.tags; then update the mappings in the contributors and tags callbacks to
use these interfaces instead of inline types and change color's type on
TagListItem from string | null to string to match the Prisma schema; reference
getUserIdentifier in the contributors mapping to ensure the identifier call
remains unchanged.

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