Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migration b4 #861

Merged
merged 1 commit into from
Feb 4, 2025
Merged

migration b4 #861

merged 1 commit into from
Feb 4, 2025

Conversation

GoldGroove06
Copy link
Contributor

@GoldGroove06 GoldGroove06 commented Jan 30, 2025

Summary by CodeRabbit

  • Refactor

    • Enhanced type safety for Storybook story files across multiple UI components
    • Added explicit type annotations for render functions and component props
    • Improved import statements to support TypeScript type definitions
  • Chores

    • Added missing React imports in story files
    • Updated method signatures to improve type checking and code clarity

Copy link
Contributor

coderabbitai bot commented Jan 30, 2025

Walkthrough

The pull request focuses on enhancing type safety and consistency across multiple UI component story files. The changes primarily involve adding React and TypeScript imports, updating function signatures with explicit type annotations, and modifying render methods in story files for components like Separator, Skeleton, Strong, Switch, and Table. These modifications aim to improve type checking and provide more precise type definitions for component props and rendering functions.

Changes

File Change Summary
src/components/ui/.../Separator.stories.tsx Added TypeScript imports, enhanced render function with SeparatorProps type
src/components/ui/.../Skeleton.stories.tsx Removed args parameter from render function
src/components/ui/.../Strong.stories.tsx Removed args parameter from render function, added React import
src/components/ui/.../Switch.stories.tsx Added type annotations for render, CheckBox, and handleChange functions
src/components/ui/.../Table.stories.tsx Added React import, typed Template function with args: any

Possibly related PRs

Suggested Labels

automerge

Suggested Reviewers

  • kotAPI

Poem

🐰 Type safety hops along the code,
Annotations bloom where stories unfold
Rabbits of logic, precise and bright
Typing our components with pure delight!
Storybook dances, types now clear 🎉


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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: 3

🔭 Outside diff range comments (1)
src/components/ui/Switch/stories/Switch.stories.tsx (1)

Line range hint 21-23: Fix incorrect prop spreading in Switch components.

The defaultChecked prop is incorrectly receiving the entire args object.

-            <Switch defaultChecked={args} key={index} variant={variant} onChange={handleChange} {...args}/>
+            <Switch key={index} variant={variant} onChange={handleChange} {...args}/>
🧰 Tools
🪛 ESLint

[error] 1-1: '/home/jailuser/git/node_modules/react/index.js' imported multiple times.

(import/no-duplicates)


[error] 4-4: '/home/jailuser/git/node_modules/react/index.js' imported multiple times.

(import/no-duplicates)

🧹 Nitpick comments (5)
src/components/ui/Strong/stories/Strong.stories.tsx (1)

4-4: Remove duplicate React import.

The React import is duplicated. Since React 17+, the JSX transform doesn't require explicit React imports.

-import React from 'react';
src/components/ui/Table/stories/Table.stories.tsx (1)

4-4: Remove unnecessary React import.

The React import is not needed with the new JSX transform (React 17+).

-import React from 'react';
src/components/ui/Separator/stories/Separator.stories.tsx (1)

11-11: Simplify type annotation.

The type annotation can be simplified to just use SeparatorProps.

-    render: (args: JSX.IntrinsicAttributes & SeparatorProps) => <SandboxEditor>
+    render: (args: SeparatorProps) => <SandboxEditor>
src/components/ui/Switch/stories/Switch.stories.tsx (1)

9-9: Simplify type annotations.

The type annotations can be simplified:

  1. Remove JSX.IntrinsicAttributes from render
  2. handleChange type can be simplified to just boolean
-    render: (args: JSX.IntrinsicAttributes & SwitchProps) => <CheckBox {...args}/>
+    render: (args: SwitchProps) => <CheckBox {...args}/>

const CheckBox = (args: SwitchProps) => {
    // ...
-    const handleChange = (state: boolean | ((prevState: boolean) => boolean)) => {
+    const handleChange = (state: boolean) => {

Also applies to: 12-12, 16-16

src/components/ui/Skeleton/stories/Skeleton.stories.tsx (1)

Line range hint 63-67: Consider removing unused args configuration.

The All export defines args that aren't being used by the render function anymore. This could be confusing for other developers.

 export const All = {
-    args: {
-        className: ''
-    }
 };
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 05b0636 and 642fa4f.

📒 Files selected for processing (5)
  • src/components/ui/Separator/stories/Separator.stories.tsx (1 hunks)
  • src/components/ui/Skeleton/stories/Skeleton.stories.tsx (1 hunks)
  • src/components/ui/Strong/stories/Strong.stories.tsx (1 hunks)
  • src/components/ui/Switch/stories/Switch.stories.tsx (1 hunks)
  • src/components/ui/Table/stories/Table.stories.tsx (1 hunks)
🧰 Additional context used
🪛 ESLint
src/components/ui/Separator/stories/Separator.stories.tsx

[error] 1-1: '/home/jailuser/git/node_modules/react/index.js' imported multiple times.

(import/no-duplicates)


[error] 2-2: A space is required after '{'.

(object-curly-spacing)


[error] 2-2: A space is required before '}'.

(object-curly-spacing)


[error] 4-4: '/home/jailuser/git/node_modules/react/index.js' imported multiple times.

(import/no-duplicates)

src/components/ui/Switch/stories/Switch.stories.tsx

[error] 1-1: '/home/jailuser/git/node_modules/react/index.js' imported multiple times.

(import/no-duplicates)


[error] 4-4: '/home/jailuser/git/node_modules/react/index.js' imported multiple times.

(import/no-duplicates)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (2)
src/components/ui/Strong/stories/Strong.stories.tsx (1)

10-10: LGTM! Simplified render function.

Removing the unused args parameter improves code clarity.

src/components/ui/Skeleton/stories/Skeleton.stories.tsx (1)

11-11: LGTM! Simplified render function signature.

The removal of unused args parameter improves code clarity.


export default {
title: 'WIP/Table',
component: Table
};

// More on writing stories with args: https://storybook.js.org/docs/react/writing-stories/args
const Template = (args) => {
const Template = (args: any) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Replace any type with proper TableProps type.

Using any type defeats TypeScript's type safety. Consider importing and using the proper props type.

-const Template = (args: any) => {
+import { TableProps } from '../Table';
+const Template = (args: TableProps) => {

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +1 to +4
import { JSX, ClassAttributes, HTMLAttributes } from 'react';
import Separator, {SeparatorProps} from '../Separator';
import SandboxEditor from '~/components/tools/SandboxEditor/SandboxEditor';
import React from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consolidate and clean up React imports.

There are multiple redundant imports and unused types.

-import { JSX, ClassAttributes, HTMLAttributes } from 'react';
import Separator, {SeparatorProps} from '../Separator';
import SandboxEditor from '~/components/tools/SandboxEditor/SandboxEditor';
-import React from 'react';
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import { JSX, ClassAttributes, HTMLAttributes } from 'react';
import Separator, {SeparatorProps} from '../Separator';
import SandboxEditor from '~/components/tools/SandboxEditor/SandboxEditor';
import React from 'react';
import Separator, {SeparatorProps} from '../Separator';
import SandboxEditor from '~/components/tools/SandboxEditor/SandboxEditor';
🧰 Tools
🪛 ESLint

[error] 1-1: '/home/jailuser/git/node_modules/react/index.js' imported multiple times.

(import/no-duplicates)


[error] 2-2: A space is required after '{'.

(object-curly-spacing)


[error] 2-2: A space is required before '}'.

(object-curly-spacing)


[error] 4-4: '/home/jailuser/git/node_modules/react/index.js' imported multiple times.

(import/no-duplicates)

Comment on lines +1 to +4
import { JSX, useState } from 'react';
import Switch, { SwitchProps } from '../Switch';
import SandboxEditor from '~/components/tools/SandboxEditor/SandboxEditor';
import React from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consolidate React imports.

Multiple React imports can be consolidated.

-import { JSX, useState } from 'react';
import Switch, { SwitchProps } from '../Switch';
import SandboxEditor from '~/components/tools/SandboxEditor/SandboxEditor';
-import React from 'react';

Committable suggestion skipped: line range outside the PR's diff.

🧰 Tools
🪛 ESLint

[error] 1-1: '/home/jailuser/git/node_modules/react/index.js' imported multiple times.

(import/no-duplicates)


[error] 4-4: '/home/jailuser/git/node_modules/react/index.js' imported multiple times.

(import/no-duplicates)

@kotAPI kotAPI added the automerge A tag that tells kodiak bot to automerge PRs for us when tests and approval conditions are met label Feb 4, 2025
@kodiakhq kodiakhq bot merged commit 6ec9194 into rad-ui:main Feb 4, 2025
5 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge A tag that tells kodiak bot to automerge PRs for us when tests and approval conditions are met
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants