fix: resolve ESLint no-explicit-any errors in prompts.json route#1090
fix: resolve ESLint no-explicit-any errors in prompts.json route#1090
Conversation
Fixes ESLint no-explicit-any errors on contributors and tags map callbacks. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughUpdated TypeScript type annotations in the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~5 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
src/app/prompts.json/route.ts
| 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 } }) => ({ |
There was a problem hiding this comment.
🧩 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.prismaRepository: 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.
Summary
Fixes 2 ESLint
no-explicit-anyerrors insrc/app/prompts.json/route.tsthat caused CI lint failure after #1086 merge.Changes
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