[WEB-5459] feat(codemods): add function declaration transformer with tests (#8137)

- Add jscodeshift-based codemod to convert arrow function components to function declarations
- Support React.FC, observer-wrapped, and forwardRef components
- Include comprehensive test suite covering edge cases
- Add npm script to run transformer across codebase
- Target only .tsx files in source directories, excluding node_modules and declaration files

* [WEB-5459] chore: updates after running codemod

---------

Co-authored-by: sriramveeraghanta <veeraghanta.sriram@gmail.com>
This commit is contained in:
Aaron 2025-11-20 19:09:40 +07:00 committed by GitHub
parent 90866fb925
commit 83fdebf64d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
1771 changed files with 17003 additions and 13856 deletions

View file

@ -2,51 +2,67 @@ import * as React from "react";
import { cn } from "../utils/classname";
const Table = React.forwardRef<React.ComponentRef<"table">, React.ComponentPropsWithoutRef<"table">>(
({ className, ...props }, ref) => (
const Table = React.forwardRef(function Table(
{ className, ...props }: React.ComponentPropsWithoutRef<"table">,
ref: React.ForwardedRef<React.ComponentRef<"table">>
) {
return (
<div className="relative w-full overflow-auto">
<table ref={ref} className={cn("w-full caption-bottom text-sm", className)} {...props} />
</div>
)
);
);
});
Table.displayName = "Table";
const TableHeader = React.forwardRef<React.ComponentRef<"thead">, React.ComponentPropsWithoutRef<"thead">>(
({ className, ...props }, ref) => (
const TableHeader = React.forwardRef(function TableHeader(
{ className, ...props }: React.ComponentPropsWithoutRef<"thead">,
ref: React.ForwardedRef<React.ComponentRef<"thead">>
) {
return (
<thead
ref={ref}
className={cn("bg-custom-background-80 py-4 border-y border-custom-border-200", className)}
{...props}
/>
)
);
);
});
TableHeader.displayName = "TableHeader";
const TableBody = React.forwardRef<React.ComponentRef<"tbody">, React.ComponentPropsWithoutRef<"tbody">>(
({ className, ...props }, ref) => <tbody ref={ref} className={cn("", className)} {...props} />
);
const TableBody = React.forwardRef(function TableBody(
{ className, ...props }: React.ComponentPropsWithoutRef<"tbody">,
ref: React.ForwardedRef<React.ComponentRef<"tbody">>
) {
return <tbody ref={ref} className={cn("", className)} {...props} />;
});
TableBody.displayName = "TableBody";
const TableFooter = React.forwardRef<React.ComponentRef<"tfoot">, React.ComponentPropsWithoutRef<"tfoot">>(
({ className, ...props }, ref) => (
<tfoot ref={ref} className={cn("bg-custom-background-300 font-medium", className)} {...props} />
)
);
const TableFooter = React.forwardRef(function TableFooter(
{ className, ...props }: React.ComponentPropsWithoutRef<"tfoot">,
ref: React.ForwardedRef<React.ComponentRef<"tfoot">>
) {
return <tfoot ref={ref} className={cn("bg-custom-background-300 font-medium", className)} {...props} />;
});
TableFooter.displayName = "TableFooter";
const TableRow = React.forwardRef<React.ComponentRef<"tr">, React.ComponentPropsWithoutRef<"tr">>(
({ className, ...props }, ref) => (
const TableRow = React.forwardRef(function TableRow(
{ className, ...props }: React.ComponentPropsWithoutRef<"tr">,
ref: React.ForwardedRef<React.ComponentRef<"tr">>
) {
return (
<tr
ref={ref}
className={cn("transition-colors data-[state=selected]:bg-custom-background-100", className)}
{...props}
/>
)
);
);
});
TableRow.displayName = "TableRow";
const TableHead = React.forwardRef<React.ComponentRef<"th">, React.ComponentPropsWithoutRef<"th">>(
({ className, ...props }, ref) => (
const TableHead = React.forwardRef(function TableHead(
{ className, ...props }: React.ComponentPropsWithoutRef<"th">,
ref: React.ForwardedRef<React.ComponentRef<"th">>
) {
return (
<th
ref={ref}
className={cn(
@ -55,26 +71,30 @@ const TableHead = React.forwardRef<React.ComponentRef<"th">, React.ComponentProp
)}
{...props}
/>
)
);
);
});
TableHead.displayName = "TableHead";
const TableCell = React.forwardRef<React.ComponentRef<"td">, React.ComponentPropsWithoutRef<"td">>(
({ className, ...props }, ref) => (
const TableCell = React.forwardRef(function TableCell(
{ className, ...props }: React.ComponentPropsWithoutRef<"td">,
ref: React.ForwardedRef<React.ComponentRef<"td">>
) {
return (
<td
ref={ref}
className={cn("p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]", className)}
{...props}
/>
)
);
);
});
TableCell.displayName = "TableCell";
const TableCaption = React.forwardRef<React.ComponentRef<"caption">, React.ComponentPropsWithoutRef<"caption">>(
({ className, ...props }, ref) => (
<caption ref={ref} className={cn("mt-4 text-sm text-custom-text-300", className)} {...props} />
)
);
const TableCaption = React.forwardRef(function TableCaption(
{ className, ...props }: React.ComponentPropsWithoutRef<"caption">,
ref: React.ForwardedRef<React.ComponentRef<"caption">>
) {
return <caption ref={ref} className={cn("mt-4 text-sm text-custom-text-300", className)} {...props} />;
});
TableCaption.displayName = "TableCaption";
export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption };