Skip to content

chore(lint): restore green lint via scoped rules + meaningful JSDoc (…#440

Merged
arpitgupta1214 merged 1 commit into
mainfrom
test
Apr 14, 2026
Merged

chore(lint): restore green lint via scoped rules + meaningful JSDoc (…#440
arpitgupta1214 merged 1 commit into
mainfrom
test

Conversation

@arpitgupta1214
Copy link
Copy Markdown
Collaborator

@arpitgupta1214 arpitgupta1214 commented Apr 14, 2026

#435)

  • chore(lint): scope eslint rules by file type + residual code fixes

Splits eslint.config.js into three file-scoped rule blocks so strict JSDoc requirements apply only where they belong:

  • all **/*.ts: keeps import/first, prettier, member-ordering, and tightens no-unused-vars to argsIgnorePattern: "^_" (was "^_$" which only matched bare _)
  • app/api/**/*.ts: retains the full jsdoc ruleset per CLAUDE.md's "all API routes require JSDoc" mandate
  • test files (**/*.test.ts, **/__tests__/**): disables no-explicit-any and jsdoc/require-jsdoc — tests legitimately need loose typing and don't ship as docs

Residual code-level fixes the new config surfaces:

  • lib/credits/getCreditUsage.ts: replace (usage as any) with a typed Partial record narrowing
  • lib/content/templates/types.ts, lib/trigger/fetchTriggerRuns.ts: move [key: string]: unknown index signature before named fields (member-ordering)
  • lib/artists/createArtistInDb.ts, lib/workspaces/createWorkspaceInDb.ts: drop unused error binding from catch
  • misc test files: remove unused imports/vars, fix import/first ordering
  • docs(api): meaningful JSDoc for 19 route handlers

Writes endpoint-specific JSDoc against the strict rules scoped to app/api/**. Each handler now documents the HTTP verb + path, the request body/query shape (referencing the validate*Body / validate*Query schema file where applicable), the success response shape, and the relevant non-200 status codes. No placeholder filler — every description conveys something the signature does not.

Files:

  • accounts/[id], admins/coding/pr, admins/coding/slack, admins/content/slack, admins/privy
  • chats/[id]/messages/trailing
  • coding-agent/callback, coding-agent/github
  • connectors
  • content (PATCH), content/analyze, content/caption, content/image, content/templates/[id], content/transcribe, content/upscale, content/video
  • songs/analyze/presets
  • transcribe
  • fix(credits): use typed LanguageModelUsage fields; restore json() assertion in sandbox test
  • getCreditUsage: drop the hand-rolled Partial-record cast and the v2-compat promptTokens/completionTokens fallback — LanguageModelUsage (= V3Usage) already types inputTokens / outputTokens directly, and the real runtime caller (handleChatCredits) passes this exact type. The compat branch was dead against the typed surface.
  • getCreditUsage.test.ts: update mock usage objects from the legacy promptTokens/completionTokens shape to the SDK V3 shape the function is actually typed against.
  • postSandboxesFilesHandler.test.ts: restore result.json() so the 500-path still asserts the response is valid JSON (not just status code), matching the original test intent.
  • docs(api): correct @returns shape for coding-agent github webhook

Cubic review feedback: the JSDoc claimed { ok: true } on 200 but the handler returns { status: <outcome> } payloads (update_triggered, ignored, busy, no_state, updating) and { status: "error", error } on non-200s. Update the doc to match the actual contract.



Summary by cubic

Scopes strict JSDoc linting to app/api/** and adds accurate docs for 19 API handlers, while tightening TypeScript lint rules and cleaning up minor code. Also fixes credit usage calculations and restores a missing JSON assertion in a sandbox test.

  • Refactors

    • Split eslint.config.js into file-scoped rule sets: default TS, app/api/** (strict JSDoc), and tests (**/*.test.ts, **/__tests__/**) with JSDoc off and no-explicit-any disabled.
    • Tightened @typescript-eslint/no-unused-vars to ignore args/vars starting with _; kept import/first, prettier, and member-ordering.
    • Wrote endpoint-specific JSDoc for 19 routes with clear request/response details; minor code tidy to satisfy lint (remove unused imports/vars, reorder index signatures, drop unused catch bindings, clarify handler params).
  • Bug Fixes

    • getCreditUsage: use inputTokens/outputTokens from LanguageModelUsage; updated tests to the v3 shape.
    • Restored result.json() assertion in sandbox file upload error test.
    • Corrected GitHub webhook JSDoc to document { status } responses and error shapes.

Written for commit ec0008b. Summary will update on new commits.

…435)

* chore(lint): scope eslint rules by file type + residual code fixes

Splits eslint.config.js into three file-scoped rule blocks so strict JSDoc
requirements apply only where they belong:

- all `**/*.ts`: keeps import/first, prettier, member-ordering, and tightens
  `no-unused-vars` to `argsIgnorePattern: "^_"` (was `"^_$"` which only
  matched bare `_`)
- `app/api/**/*.ts`: retains the full jsdoc ruleset per CLAUDE.md's "all
  API routes require JSDoc" mandate
- test files (`**/*.test.ts`, `**/__tests__/**`): disables
  `no-explicit-any` and `jsdoc/require-jsdoc` — tests legitimately need
  loose typing and don't ship as docs

Residual code-level fixes the new config surfaces:
- `lib/credits/getCreditUsage.ts`: replace `(usage as any)` with a typed
  Partial record narrowing
- `lib/content/templates/types.ts`, `lib/trigger/fetchTriggerRuns.ts`:
  move `[key: string]: unknown` index signature before named fields
  (member-ordering)
- `lib/artists/createArtistInDb.ts`, `lib/workspaces/createWorkspaceInDb.ts`:
  drop unused `error` binding from catch
- misc test files: remove unused imports/vars, fix import/first ordering

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs(api): meaningful JSDoc for 19 route handlers

Writes endpoint-specific JSDoc against the strict rules scoped to
`app/api/**`. Each handler now documents the HTTP verb + path, the
request body/query shape (referencing the `validate*Body` / `validate*Query`
schema file where applicable), the success response shape, and the
relevant non-200 status codes. No placeholder filler — every description
conveys something the signature does not.

Files:
- accounts/[id], admins/coding/pr, admins/coding/slack,
  admins/content/slack, admins/privy
- chats/[id]/messages/trailing
- coding-agent/callback, coding-agent/github
- connectors
- content (PATCH), content/analyze, content/caption, content/image,
  content/templates/[id], content/transcribe, content/upscale,
  content/video
- songs/analyze/presets
- transcribe

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(credits): use typed LanguageModelUsage fields; restore json() assertion in sandbox test

- `getCreditUsage`: drop the hand-rolled Partial-record cast and the v2-compat
  `promptTokens`/`completionTokens` fallback — `LanguageModelUsage` (= V3Usage)
  already types `inputTokens` / `outputTokens` directly, and the real runtime
  caller (`handleChatCredits`) passes this exact type. The compat branch was
  dead against the typed surface.
- `getCreditUsage.test.ts`: update mock usage objects from the legacy
  `promptTokens`/`completionTokens` shape to the SDK V3 shape the function is
  actually typed against.
- `postSandboxesFilesHandler.test.ts`: restore `result.json()` so the 500-path
  still asserts the response is valid JSON (not just status code), matching
  the original test intent.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs(api): correct @returns shape for coding-agent github webhook

Cubic review feedback: the JSDoc claimed `{ ok: true }` on 200 but the handler
returns `{ status: <outcome> }` payloads (`update_triggered`, `ignored`, `busy`,
`no_state`, `updating`) and `{ status: "error", error }` on non-200s. Update the
doc to match the actual contract.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 14, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
recoup-api Ready Ready Preview Apr 14, 2026 11:11pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 14, 2026

Warning

Rate limit exceeded

@arpitgupta1214 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 49 minutes and 41 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 49 minutes and 41 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 220cfe0f-40da-486a-a23c-486b9343eb95

📥 Commits

Reviewing files that changed from the base of the PR and between b9341e3 and ec0008b.

⛔ Files ignored due to path filters (13)
  • eslint.config.js is excluded by none and included by none
  • lib/admins/slack/__tests__/fetchBotMentions.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
  • lib/agents/generalAgent/__tests__/getGeneralAgent.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
  • lib/artist/__tests__/updateArtistSocials.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
  • lib/chat/__tests__/validateChatRequest.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
  • lib/chats/__tests__/getChatsHandler.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
  • lib/chats/__tests__/validateGetChatsRequest.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
  • lib/credits/__tests__/getCreditUsage.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
  • lib/github/__tests__/createOrUpdateFileContent.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
  • lib/github/__tests__/expandSubmoduleEntries.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
  • lib/sandbox/__tests__/postSandboxesFilesHandler.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
  • lib/supabase/account_sandboxes/__tests__/selectAccountSandboxes.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
  • lib/tasks/__tests__/enrichTasks.test.ts is excluded by !**/*.test.*, !**/__tests__/** and included by lib/**
📒 Files selected for processing (26)
  • app/api/accounts/[id]/route.ts
  • app/api/admins/coding/pr/route.ts
  • app/api/admins/coding/slack/route.ts
  • app/api/admins/content/slack/route.ts
  • app/api/admins/privy/route.ts
  • app/api/chats/[id]/messages/trailing/route.ts
  • app/api/coding-agent/callback/route.ts
  • app/api/coding-agent/github/route.ts
  • app/api/connectors/route.ts
  • app/api/content/analyze/route.ts
  • app/api/content/caption/route.ts
  • app/api/content/image/route.ts
  • app/api/content/route.ts
  • app/api/content/templates/[id]/route.ts
  • app/api/content/transcribe/route.ts
  • app/api/content/upscale/route.ts
  • app/api/content/video/route.ts
  • app/api/songs/analyze/presets/route.ts
  • app/api/transcribe/route.ts
  • lib/artists/createArtistInDb.ts
  • lib/chats/compactChatsHandler.ts
  • lib/coding-agent/resolvePRState.ts
  • lib/content/templates/types.ts
  • lib/credits/getCreditUsage.ts
  • lib/trigger/fetchTriggerRuns.ts
  • lib/workspaces/createWorkspaceInDb.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test

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.

@arpitgupta1214 arpitgupta1214 merged commit bade52f into main Apr 14, 2026
7 checks passed
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