Skip to content
This repository was archived by the owner on Jul 17, 2026. It is now read-only.

Add codemod script to remove empty usePresenter parameters - #1005

Open
codegen-sh[bot] wants to merge 2 commits into
developfrom
codegen-remove-empty-presenter-params
Open

codegen-sh[bot] wants to merge 2 commits into
developfrom
codegen-remove-empty-presenter-params

Conversation

@codegen-sh

@codegen-sh codegen-sh Bot commented Apr 2, 2025

Copy link
Copy Markdown
Contributor

This PR adds a codemod script that finds all usages of usePresenter where the second argument is an empty object ({}) and removes that parameter.

Features

  • Identifies usePresenter function calls in the codebase
  • Detects when the second argument is an empty object ({})
  • Handles various forms of empty objects (with whitespace, etc.)
  • Removes the empty parameter and preserves the rest of the call
  • Provides detailed logging of changes made
  • Includes documentation on how to use the script

Usage

# Navigate to your project root
cd your-project-root

# Run the script
python scripts/codemods/remove_empty_presenter_params.py

Example Transformation

Before:

const presenter = usePresenter(someValue, {});

After:

const presenter = usePresenter(someValue);

@codegen-sh
codegen-sh Bot requested review from a team and codegen-team as code owners April 2, 2025 22:09
@codecov

codecov Bot commented Apr 2, 2025 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codegen-sh

codegen-sh Bot commented Apr 2, 2025

Copy link
Copy Markdown
Contributor Author

I've reviewed this PR which adds a codemod script to remove empty usePresenter parameters. The implementation looks good and follows a clean approach:

  1. ✅ The script correctly identifies usePresenter calls with empty object parameters
  2. ✅ It handles various forms of empty objects with whitespace
  3. ✅ The regex pattern is well-designed to match different empty object formats
  4. ✅ The code provides good logging to track changes
  5. ✅ The README documentation is clear and includes usage examples

The Codecov report shows that all modified and coverable lines are covered by tests, which is excellent.

This codemod will be useful for cleaning up codebases that have unnecessary empty object parameters in usePresenter calls. The implementation is straightforward and follows the pattern of other codemods in the codebase.

Great work! 👍

This branch has not been deployed

No deployments
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants