Skip to content

Error fixed for that allRows#365

Open
AsimSafarli wants to merge 1 commit intododopayments:mainfrom
AsimSafarli:patch-1
Open

Error fixed for that allRows#365
AsimSafarli wants to merge 1 commit intododopayments:mainfrom
AsimSafarli:patch-1

Conversation

@AsimSafarli
Copy link
Copy Markdown

@AsimSafarli AsimSafarli commented Feb 23, 2026

When we use that let then we get this error "'allRows' is never reassigned. Use 'const' instead.",

Summary

Describe the purpose of this PR.

Changes

  • Key changes in this PR

Screenshots/Recordings (if UI)

Add before/after or short clip if relevant.

How to Test

Steps to validate locally:

  1. npm ci
  2. npm run typecheck
  3. npm run build

Checklist

  • Title is clear and descriptive
  • Related issue linked (if any)
  • Tests or manual verification steps included
  • CI passes (typecheck & build)
  • Docs updated (if needed)

Summary by CodeRabbit

  • Refactor
    • Improved code quality in the usage table component with minor internal optimizations.

When we use that let then we get this error "'allRows' is never reassigned. Use 'const' instead.",
@vercel
Copy link
Copy Markdown

vercel bot commented Feb 23, 2026

@AsimSafarli is attempting to deploy a commit to the Dodo Payments Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 23, 2026

📝 Walkthrough

Walkthrough

A variable declaration in the usage table component was changed from mutable (let) to immutable (const) when mapping usage history to CSV rows, with an added blank line for readability.

Changes

Cohort / File(s) Summary
Variable Declaration Refactoring
src/registry/billingsdk/usage-table.tsx
Changed allRows variable from let to const to enforce immutability after initialization.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A hop and a skip, the code stays still,
Let becomes const—immutable will,
No reassignment in sight, pure and true,
Safer and cleaner, the rabbit's debut!

🚥 Pre-merge checks | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

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.
Description check ⚠️ Warning The PR description contains only a problem statement followed by the empty template. Required sections like Summary and Changes are not meaningfully filled in. Complete the Summary section with the PR's purpose, fill in the Changes section with specific modifications made, and remove or complete placeholder text.
Title check ❓ Inconclusive The title 'Error fixed for that allRows' is vague and unclear. It mentions fixing an error related to allRows but lacks clarity about what the actual fix is or why it matters. Revise the title to be more specific and clear, such as 'Change allRows from let to const to fix linting error' or 'Use const for non-reassigned allRows variable'.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
Copy Markdown
Contributor

@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.

🧹 Nitpick comments (2)
src/registry/billingsdk/usage-table.tsx (2)

72-78: formatNumber / formatCurrency in useCallback deps cause the callback to be recreated on every render.

Both helpers are defined as fresh function references on every render. Because they are included in the useCallback dependency array (lines 176–177), exportToCsv itself is also recreated on every render, defeating the purpose of memoization. Since neither function closes over any state or props, the simplest fix is to hoist them outside the component.

♻️ Proposed refactor — hoist pure helpers outside the component
+"use client";
+import React, { useCallback } from "react";
+// ...
+
+// Hoisted outside the component — no dependency on state/props
+const formatNumber = (num: number) => new Intl.NumberFormat().format(num);
+const formatCurrency = (amount: number) => `$${amount.toFixed(2)}`;
+
 export function UsageTable({ ... }: UsageTableProps) {
-  const formatNumber = (num: number) => {
-    return new Intl.NumberFormat().format(num);
-  };
-
-  const formatCurrency = (amount: number) => {
-    return `$${amount.toFixed(2)}`;
-  };
   // ...

Then remove them from the useCallback dependency array:

   }, [
     usageHistory,
     totalRow,
     showTotal,
     hasApiCost,
     hasCostToYou,
-    formatNumber,
-    formatCurrency,
   ]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/registry/billingsdk/usage-table.tsx` around lines 72 - 78, formatNumber
and formatCurrency are recreated each render and included in the useCallback
deps, causing exportToCsv to be recreated every render; hoist both pure helper
functions (formatNumber, formatCurrency) out of the component scope so they are
stable top-level functions and then remove them from the exportToCsv useCallback
dependency array (leaving only real dependencies) so exportToCsv can be memoized
properly.

97-107: exportColumns is used inside useCallback but absent from the dependency array.

exportColumns is declared inside the component (line 86) and captured in the exportToCsv closure, but it's not listed in the useCallback deps (lines 170–178). The react-hooks/exhaustive-deps rule would flag this. It's functionally harmless today since the array is static, but it's an inconsistency worth resolving — either move exportColumns outside the component alongside formatNumber/formatCurrency, or add it to the dep array.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/registry/billingsdk/usage-table.tsx` around lines 97 - 107, The
exportToCsv useCallback closes over exportColumns but exportColumns is not in
its dependency array; either add exportColumns to the useCallback deps or move
the exportColumns declaration out of the component (like
formatNumber/formatCurrency) so it's truly static; update the dependency array
on exportToCsv (the useCallback that defines exportToCsv) to include
exportColumns if you keep it inside the component, or hoist exportColumns above
the component and keep the current deps.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/registry/billingsdk/usage-table.tsx`:
- Around line 72-78: formatNumber and formatCurrency are recreated each render
and included in the useCallback deps, causing exportToCsv to be recreated every
render; hoist both pure helper functions (formatNumber, formatCurrency) out of
the component scope so they are stable top-level functions and then remove them
from the exportToCsv useCallback dependency array (leaving only real
dependencies) so exportToCsv can be memoized properly.
- Around line 97-107: The exportToCsv useCallback closes over exportColumns but
exportColumns is not in its dependency array; either add exportColumns to the
useCallback deps or move the exportColumns declaration out of the component
(like formatNumber/formatCurrency) so it's truly static; update the dependency
array on exportToCsv (the useCallback that defines exportToCsv) to include
exportColumns if you keep it inside the component, or hoist exportColumns above
the component and keep the current deps.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 13e1fda and 4d610b8.

📒 Files selected for processing (1)
  • src/registry/billingsdk/usage-table.tsx

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