Skip to content

Comments

Fix more lint issues in dashboard.#45

Closed
sbansal1999 wants to merge 2 commits intodatabuddy-analytics:mainfrom
sbansal1999:fix-dashboard-lint-issues-3
Closed

Fix more lint issues in dashboard.#45
sbansal1999 wants to merge 2 commits intodatabuddy-analytics:mainfrom
sbansal1999:fix-dashboard-lint-issues-3

Conversation

@sbansal1999
Copy link
Contributor

@sbansal1999 sbansal1999 commented Jul 28, 2025

Summary by CodeRabbit

  • Refactor

    • Improved code clarity and consistency by adding explicit braces to conditional statements in several components.
    • Simplified array creation for rendering skeleton UI elements.
    • Removed unused import statements across multiple files.
  • Style

    • Enhanced code readability without changing any user-facing functionality.

@vercel
Copy link

vercel bot commented Jul 28, 2025

@sbansal1999 is attempting to deploy a commit to the Databuddy Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 28, 2025

Warning

Rate limit exceeded

@sbansal1999 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 4 minutes and 37 seconds before requesting another review.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3f2039d and 2ebece8.

📒 Files selected for processing (2)
  • apps/dashboard/app/(main)/websites/[id]/revenue/_components/recent-transactions.tsx (2 hunks)
  • apps/dashboard/app/(main)/websites/[id]/revenue/page.tsx (2 hunks)

Walkthrough

The changes across several dashboard application components primarily involve syntactic refactoring for code clarity and consistency. These include adding explicit braces to single-line conditional return statements and updating array creation patterns. Additionally, several unused import statements were removed. No logic, control flow, or exported interfaces were altered.

Changes

Cohort / File(s) Change Summary
Conditional Braces Refactor
.../goal-card.tsx, .../revenue-chart.tsx, .../session-utils.tsx, .../minimal-table.tsx
Added explicit block braces around single-line conditional return statements for improved clarity and consistency. No logic changes.
Unused Import Removal
.../profile-row.tsx, .../revenue/_components/page-header.tsx, .../revenue-chart.tsx, .../minimal-table.tsx
Removed unused icon and UI component import statements. No other code changes.
Array Creation Pattern Update
.../revenue/_components/recent-transactions.tsx, .../revenue/page.tsx
Replaced [...Array(n)] with [...new Array(n)] for creating arrays of length n in skeleton and fallback rendering. Also simplified map function parameters. Logic remains unchanged.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

A rabbit hopped through lines of code,
Tidying braces where logic flowed.
Unused imports left behind,
Arrays re-shaped, all well-aligned.
With clarity now in every part,
This dashboard code is off to a smart start!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
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.

Actionable comments posted: 0

🧹 Nitpick comments (4)
apps/dashboard/app/(main)/websites/[id]/revenue/_components/recent-transactions.tsx (1)

45-47: Prefer Array.from({ length: 5 }) over spread-on-array literal for clarity

[...new Array(5)] works, but it relies on readers remembering that spreading an array with empty slots materialises undefineds.
Using Array.from({ length: 5 }) (or a small helper) is self-describing and avoids the extra spread.

-{[...new Array(5)].map((_, i) => (
+{Array.from({ length: 5 }).map((_, i) => (
apps/dashboard/app/(main)/websites/[id]/revenue/page.tsx (2)

92-109: Inconsistent skeleton array pattern within the same file

Here we switched to [...new Array(4)], while PageHeaderSkeleton above still uses [...Array(4)].
For consistency (and to avoid the spread-of-holes pattern altogether) consider standardising on:

-{[...new Array(4)].map((_, i) => (
+{Array.from({ length: 4 }).map((_, i) => (

or refactor both places to a small utility, e.g. range(4), to keep the codebase uniform.


334-346: Same note on skeleton list generation

Replicate whichever array-creation style you settle on elsewhere (Array.from or a helper) to keep the codebase consistent and silence any remaining lint noise.

-{[...new Array(5)].map((_, i) => (
+{Array.from({ length: 5 }).map((_, i) => (
apps/dashboard/app/(main)/websites/[id]/goals/_components/goal-card.tsx (1)

52-60: LGTM! Consider using the centralized formatter.

The brace addition improves consistency. However, there's code duplication - similar number formatting logic exists in multiple files.

Consider using the more comprehensive formatNumber function from apps/dashboard/lib/formatters.ts which handles additional edge cases:

+import { formatNumber } from '@/lib/formatters';

-	const formatNumber = (num: number) => {
-		if (num >= 1_000_000) {
-			return `${(num / 1_000_000).toFixed(1)}M`;
-		}
-		if (num >= 1000) {
-			return `${(num / 1000).toFixed(1)}K`;
-		}
-		return num.toString();
-	};

The centralized version also handles null/undefined values and NaN cases more robustly.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e21c29e and 3f2039d.

📒 Files selected for processing (8)
  • apps/dashboard/app/(main)/websites/[id]/goals/_components/goal-card.tsx (1 hunks)
  • apps/dashboard/app/(main)/websites/[id]/profiles/_components/profile-row.tsx (0 hunks)
  • apps/dashboard/app/(main)/websites/[id]/revenue/_components/page-header.tsx (0 hunks)
  • apps/dashboard/app/(main)/websites/[id]/revenue/_components/recent-transactions.tsx (2 hunks)
  • apps/dashboard/app/(main)/websites/[id]/revenue/_components/revenue-chart.tsx (2 hunks)
  • apps/dashboard/app/(main)/websites/[id]/revenue/page.tsx (2 hunks)
  • apps/dashboard/app/(main)/websites/[id]/sessions/_components/session-utils.tsx (2 hunks)
  • apps/dashboard/app/(main)/websites/[id]/test/components/minimal-table.tsx (1 hunks)
💤 Files with no reviewable changes (2)
  • apps/dashboard/app/(main)/websites/[id]/revenue/_components/page-header.tsx
  • apps/dashboard/app/(main)/websites/[id]/profiles/_components/profile-row.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (7)
apps/dashboard/app/(main)/websites/[id]/revenue/_components/recent-transactions.tsx (1)

94-95: Good cleanup – removed unused index parameter

Dropping the unused index argument makes the intent clearer and satisfies the linter without altering behaviour. Nice touch.

apps/dashboard/app/(main)/websites/[id]/test/components/minimal-table.tsx (1)

72-87: LGTM! Consistent brace addition improves code clarity.

The expansion of single-line conditional returns into multi-line blocks with explicit braces enhances readability and follows consistent formatting standards. The logic for extracting percentage values from various property names remains unchanged.

apps/dashboard/app/(main)/websites/[id]/sessions/_components/session-utils.tsx (2)

147-150: LGTM! Consistent brace formatting.

The expansion of the single-line conditional return improves code consistency while preserving the logic for handling root paths.


161-174: LGTM! Improved readability with consistent braces.

All conditional branches now use explicit braces, making the function more readable and consistent with the codebase formatting standards. The type checking logic remains unchanged.

apps/dashboard/app/(main)/websites/[id]/revenue/_components/revenue-chart.tsx (3)

37-39: LGTM! Consistent conditional formatting.

The expansion of the single-line conditional return with explicit braces improves readability and aligns with the formatting standards applied across the codebase.


42-47: LGTM! Improved function consistency.

The getMetricIcon function now uses explicit braces for all conditional returns, maintaining consistency with the broader refactoring pattern while preserving the icon selection logic.


117-123: LGTM! Consistent formatting improvements.

The valueFormatter function now uses explicit braces for conditional returns, improving readability. The currency formatting logic with M/k suffixes remains unchanged and functions correctly.

@sbansal1999
Copy link
Contributor Author

Closing in favour of #43.

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