[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

@ -6,7 +6,7 @@ type TBanner = {
message: string;
};
export const Banner: FC<TBanner> = (props) => {
export function Banner(props: TBanner) {
const { type, message } = props;
return (
@ -29,4 +29,4 @@ export const Banner: FC<TBanner> = (props) => {
</div>
</div>
);
};
}

View file

@ -9,7 +9,7 @@ type Props = {
icon?: React.ReactNode | undefined;
};
export const BreadcrumbLink: React.FC<Props> = (props) => {
export function BreadcrumbLink(props: Props) {
const { href, label, icon } = props;
return (
<Tooltip tooltipContent={label} position="bottom">
@ -35,4 +35,4 @@ export const BreadcrumbLink: React.FC<Props> = (props) => {
</li>
</Tooltip>
);
};
}

View file

@ -6,16 +6,18 @@ type TProps = {
darkerShade?: boolean;
};
export const CodeBlock = ({ children, className, darkerShade }: TProps) => (
<span
className={cn(
"px-0.5 text-xs text-custom-text-300 bg-custom-background-90 font-semibold rounded-md border border-custom-border-100",
{
"text-custom-text-200 bg-custom-background-80 border-custom-border-200": darkerShade,
},
className
)}
>
{children}
</span>
);
export function CodeBlock({ children, className, darkerShade }: TProps) {
return (
<span
className={cn(
"px-0.5 text-xs text-custom-text-300 bg-custom-background-90 font-semibold rounded-md border border-custom-border-100",
{
"text-custom-text-200 bg-custom-background-80 border-custom-border-200": darkerShade,
},
className
)}
>
{children}
</span>
);
}

View file

@ -13,7 +13,7 @@ type Props = {
onDiscardHref: string;
};
export const ConfirmDiscardModal: React.FC<Props> = (props) => {
export function ConfirmDiscardModal(props: Props) {
const { isOpen, handleClose, onDiscardHref } = props;
return (
@ -71,4 +71,4 @@ export const ConfirmDiscardModal: React.FC<Props> = (props) => {
</Dialog>
</Transition.Root>
);
};
}

View file

@ -30,7 +30,7 @@ export type TControllerInputFormField = {
required: boolean;
};
export const ControllerInput: React.FC<Props> = (props) => {
export function ControllerInput(props: Props) {
const { name, control, type, label, description, placeholder, error, required } = props;
// states
const [showPassword, setShowPassword] = useState(false);
@ -81,4 +81,4 @@ export const ControllerInput: React.FC<Props> = (props) => {
{description && <p className="pt-0.5 text-xs text-custom-text-300">{description}</p>}
</div>
);
};
}

View file

@ -19,7 +19,7 @@ export type TCopyField = {
description: string | React.ReactNode;
};
export const CopyField: React.FC<Props> = (props) => {
export function CopyField(props: Props) {
const { label, url, description } = props;
return (
@ -43,4 +43,4 @@ export const CopyField: React.FC<Props> = (props) => {
<div className="text-xs text-custom-text-300">{description}</div>
</div>
);
};
}

View file

@ -16,32 +16,27 @@ type Props = {
disabled?: boolean;
};
export const EmptyState: React.FC<Props> = ({
title,
description,
image,
primaryButton,
secondaryButton,
disabled = false,
}) => (
<div className={`flex h-full w-full items-center justify-center`}>
<div className="flex w-full flex-col items-center text-center">
{image && <img src={image} className="w-52 sm:w-60" alt={primaryButton?.text || "button image"} />}
<h6 className="mb-3 mt-6 text-xl font-semibold sm:mt-8">{title}</h6>
{description && <p className="mb-7 px-5 text-custom-text-300 sm:mb-8">{description}</p>}
<div className="flex items-center gap-4">
{primaryButton && (
<Button
variant="primary"
prependIcon={primaryButton.icon}
onClick={primaryButton.onClick}
disabled={disabled}
>
{primaryButton.text}
</Button>
)}
{secondaryButton}
export function EmptyState({ title, description, image, primaryButton, secondaryButton, disabled = false }: Props) {
return (
<div className={`flex h-full w-full items-center justify-center`}>
<div className="flex w-full flex-col items-center text-center">
{image && <img src={image} className="w-52 sm:w-60" alt={primaryButton?.text || "button image"} />}
<h6 className="mb-3 mt-6 text-xl font-semibold sm:mt-8">{title}</h6>
{description && <p className="mb-7 px-5 text-custom-text-300 sm:mb-8">{description}</p>}
<div className="flex items-center gap-4">
{primaryButton && (
<Button
variant="primary"
prependIcon={primaryButton.icon}
onClick={primaryButton.onClick}
disabled={disabled}
>
{primaryButton.text}
</Button>
)}
{secondaryButton}
</div>
</div>
</div>
</div>
);
);
}

View file

@ -2,7 +2,7 @@ import { useTheme } from "next-themes";
import LogoSpinnerDark from "@/app/assets/images/logo-spinner-dark.gif?url";
import LogoSpinnerLight from "@/app/assets/images/logo-spinner-light.gif?url";
export const LogoSpinner = () => {
export function LogoSpinner() {
const { resolvedTheme } = useTheme();
const logoSrc = resolvedTheme === "dark" ? LogoSpinnerLight : LogoSpinnerDark;
@ -12,4 +12,4 @@ export const LogoSpinner = () => {
<img src={logoSrc} alt="logo" className="h-6 w-auto sm:h-11" />
</div>
);
};
}

View file

@ -5,7 +5,7 @@ type TPageHeader = {
description?: string;
};
export const PageHeader: React.FC<TPageHeader> = (props) => {
export function PageHeader(props: TPageHeader) {
const { title = "God Mode - Plane", description = "Plane god mode" } = props;
return (
@ -14,4 +14,4 @@ export const PageHeader: React.FC<TPageHeader> = (props) => {
<meta name="description" content={description} />
</>
);
};
}