npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@wigxel/react-tf

v0.0.1

Published

Transform React function components from arrow functions to function declarations

Readme


title: "React Component Transformer" description: "A CLI tool that transforms React codebase to the Wigxel coding standards"

React Component Transformer

A CLI tool that transforms React codebase to the Wigxel coding standards

Features

  • Arrow Function → Function Declaration: Automatically converts arrow function components to function declarations
  • Inline Type Extraction: Extracts inline type literals to named type aliases (e.g., { name: string }ComponentProps)
  • Named Type Destructuring: Moves destructuring to function body for components with ≥3 props or default values
  • Rest Element Handling: Renames ...props to ...restProps to avoid naming conflicts
  • Gitignore-Aware Filtering: Respects .gitignore files when scanning for files
  • Content-Hash Caching: Skips unchanged files for faster re-runs
  • Parallel Processing: Uses worker threads for multi-core performance
  • Debug Mode: Real-time logging with color-coded timing

Usage

# Basic usage
react-component-transformer ./src

# With debug logging
react-component-transformer ./src --debug

# Force reprocess (ignore cache)
react-component-transformer ./src --force

# Specify number of workers
react-component-transformer ./src --workers 8

Options

| Option | Alias | Description | Default | | ------------- | ----- | -------------------------------- | ------- | | --directory | - | Directory to scan for .tsx files | . | | --debug | -d | Enable debug logging | false | | --workers | -w | Number of worker threads | 4 | | --force | -f | Force reprocess (ignore cache) | false |

Transformations

Arrow Function with Inline Type

Before:

const Box = ({ boxes, count }: { boxes: number; count: string }) => {
  return (
    <div>
      {boxes} - {count}
    </div>
  );
};

After:

type BoxProps = {
  boxes: number;
  count: string;
};

function Box(props: BoxProps) {
  const { boxes, count } = props;

  return (
    <div>
      {boxes} - {count}
    </div>
  );
}

Function Declaration with Named Type (≥3 Props)

Before:

function Avatar({ size = 80, disabled, className, ...props }: AvatarProps) {
  return <div {...props} className={className} />;
}

After:

function Avatar(props: AvatarProps) {
  const { size = 80, disabled, className, ...restProps } = props;

  return <div {...restProps} className={className} />;
}

How It Works

  1. Scanning: Recursively scans the target directory for .tsx files, respecting .gitignore rules
  2. Caching: Checks content-hash cache to skip unchanged files
  3. Parallel Processing: Distributes files across worker threads
  4. AST Transformation: Uses ts-morph to parse and transform the AST
  5. Output: Writes transformed files back to disk

Cache

The tool maintains a .transformer-cache.json file in the target directory that stores content hashes of processed files. This allows it to skip files that haven't changed since the last run.

To force reprocessing of all files, use the --force flag.

Development

# Install dependencies
npm install

# Run tests
npm test

# Build the CLI
npm run build

# Run demo
npm run demo

License

MIT