Skip to main content
PRONeed enterprise-grade codemods tailored to your codebase?

Assess, plan, evolve.

Reusable compiler-aware skills that help coding agents understand, plan, and safely evolve your codebase.

54 packages

Sort by
typescript/remove-console

This codemod removes all `console` statements from your TypeScript and JavaScript files ## Example ### Before ```ts const greeting = "hello world!"; console.log("good morning y'all!"); const sayHi = () => { console.error("oops!"); }; ``` ### After ```ts const greeting = "hello world!"; const sayHi = () => {}; ```

  • migration
Yyoshi2no
v1.0.1
3
2 years ago
typescript/use-template-literals

This codemod replaces string concatenations with template literals. ## Before ```jsx const name = 'John'; const greeting = 'Hello, ' + name + '!'; ``` ## After ```jsx const name = 'John'; const greeting = `Hello, ${name}!`; ```

  • migration
  • typescript
CCodemod
v1.0.3
75
a year ago
typescript/remove-public-modifier

This codemod removes public modifier in interface declarations as it is implicit. ## Before ```jsx class MyClass { public myProperty: string; public constructor() { } public myMethod(): void { } } ``` ## After ```jsx class MyClass { myProperty: string; constructor() { } myMethod(): void { } } ```

  • migration
CCodemod
v1.0.2
62
a year ago
TypeScript/v5.6/add-test-for-regex-in-conditional

Add .test() to regex literals in conditionals ### Before ```ts if (/^[0-9]+$/) { //some awesome code } ``` ### After ```ts if (/^[0-9]+$/.test('')) { //some awesome code } ```

  • TypeScript
  • best-practices
Aalexbit-codemod
v1.0.3
0
2 years ago
TypeScript/v5.6/arrow-function-condition-to-binary-expression

Identify cases where an arrow function is mistakenly used instead of a comparison operator (e.g., x => 0 instead of x >= 0) and convert the arrow function expressions to proper comparison operations. ### Before ```ts // Arrow Function Misused as a Comparison const x = 5; if ((x) => 0) { //some awesome code } ``` ### After ```ts const x = 5; if (x >= 0) { //some awesome code } ```

  • TypeScript
  • best-practices
Aalexbit-codemod
v1.0.2
0
2 years ago
typescript-strictness-mining

Read-only TypeScript strictness mining (syntax + tsconfig metrics) and an optional migration workflow (tsc gate, safe-fixes, strict enablement, AI cleanup).

  • mining
  • metrics
  • +8
Aalexbit-codemod avataralexbit-codemod
v0.0.6
4
4 months ago
typescript-impossible-states-mining

Mine TypeScript types that make illegal states representable

  • mining
  • metrics
  • +3
Aalexbit-codemod avataralexbit-codemod
v0.1.1
3
2 months ago
react-prop-types-typescript

Convert React PropTypes declarations into TypeScript props interfaces

  • React
  • PropTypes
  • +1
Ccodemod-com-bot avatarcodemod-com-bot
v0.1.4
59,156
2 days ago
react/replace-react-fc-typescript

This codemod removes `React.FC`, `React.FunctionComponent` and `React.SFC` and replaces the Props as the type of the unique argument in the component definition. This codemod supports: - Inline defined props. - Generics. - Props defined with intersection. - Component modules defined using intersection. - Regular named functions. - Functions that accept a component definition. - Using FC, FunctionComponent and SFC as a named export. ## Before: ```jsx type Props2 = { id: number }; export const MyComponent2: React.FC<Props2> = (props) => { return <span>{props.id}</span> } ``` ## After: ```tsx type Props2 = { id: number }; export const MyComponent2 = (props: Props2) => { return <span>{props.id}</span>; }; ```

  • react
  • migration
CCodemod
v1.0.6
408
a year ago
goto-to-location-href

## Codemod Description This codemod is designed to replace specific patterns in TypeScript files with updated code logic. It transforms instances of `goto($A)` into `window.location.href = $A;` when the `$A` value is a URL starting with `http://` or `https://`. This refactor makes external navigation more explicit by using `window.location.href`. --- ## Features - **Pattern Matching**: Identifies instances of `goto($A)` in TypeScript files. - **Conditional Replacement**: Applies transformations only when the matched node contains URLs starting with `http://` or `https://`. - **Automated Code Refactoring**: Updates all matching files automatically. - **Logging**: Displays original and transformed code snippets for review. --- ## Workflow Details The codemod works by finding and replacing `goto($A)` with `window.location.href = $A;` based on the condition that `$A` is an external URL starting with `http://` or `https://`. ### Code Transformations: - **Pattern**: `goto($A)` - **Regex Filters**: - `http://` - `https://` - **Replacement**: - `window.location.href = $A;` --- ## Before and After Examples ### Example 1: Internal Navigation (Unchanged) #### Before ```typescript import { goto } from '$app/navigation'; function navigateInternal() { goto('/dashboard', { state: { userId: 42, from: 'home' } }); goto('/dashboard'); } ``` #### After ```typescript import { goto } from '$app/navigation'; function navigateInternal() { goto('/dashboard', { state: { userId: 42, from: 'home' } }); goto('/dashboard'); } ``` - **Explanation**: Internal URLs (like `/dashboard`) remain unchanged, as they do not match the transformation condition. --- ### Example 2: External Navigation with `http://` #### Before ```typescript function navigateExternal() { goto('http://example.com'); } ``` #### After ```typescript function navigateExternal() { window.location.href = 'http://example.com'; } ``` - **Explanation**: External URLs starting with `http://` are transformed into `window.location.href = $A;`. --- ### Example 3: External Navigation with `https://` #### Before ```typescript function navigateExternal() { goto('https://example.com'); } ``` #### After ```typescript function navigateExternal() { window.location.href = 'https://example.com'; } ``` - **Explanation**: External URLs starting with `https://` are also transformed in the same way. --- ## How It Works 1. The script scans all TypeScript files (`*.ts`) in your project. 2. It searches for instances of `goto($A)` and checks if `$A` matches either `http://` or `https://`. 3. When a match is found, the `goto($A)` pattern is replaced with `window.location.href = $A;`. 4. Internal navigation paths are left unchanged, as they do not match the regex condition. --- ## Conclusion This codemod provides an efficient way to refactor external navigation in your TypeScript code by converting `goto($A)` into `window.location.href = $A;` for URLs starting with `http://` or `https://`. It helps make external link handling more explicit and consistent across your project. --- ## License This codemod is open-source and licensed under the MIT License. ```

  • sveltekit
  • typescript
  • +6
Ppriyanshuthapliyal2005
v1.0.0
0
a year ago
sveltekit-import-and-path-simplification

# Simplify SvelteKit Import and Path Usage This codemod simplifies the import statements and path resolution in your SvelteKit project. It replaces the usage of `resolvePath` and concatenation with `base` by using the `resolveRoute` function from `$app/paths`. This results in cleaner and more readable code. ## Transformations This codemod performs the following transformations: - **Import Statement**: Transforms: ```typescript import { resolvePath } from '@sveltejs/kit'; import { base } from '$app/paths'; ``` into ```typescript import { resolveRoute } from '$app/paths'; ``` - **Path Resolution**: Transforms: ```typescript const path = base + resolvePath('/blog/[slug]', { slug }); ``` into ```typescript const path = resolveRoute('/blog/[slug]', { slug }); ``` ## Usage To apply this codemod, run the workflow script on your TypeScript files. Ensure you have the necessary dependencies installed and your project is configured to use this codemod. ## Example ### Before ```typescript import { resolvePath } from '@sveltejs/kit'; import { base } from '$app/paths'; const path = base + resolvePath('/blog/[slug]', { slug }); ``` ### After ```typescript import { resolveRoute } from '$app/paths'; const path = resolveRoute('/blog/[slug]', { slug }); ```

  • sveltekit
  • typescript
  • +6
Ppriyanshuthapliyal2005
v1.0.1
0
a year ago
codemod/typescript-maintainability-audit-bundle

Run a coordinated TypeScript maintainability audit across type-safety, function complexity, collection usage, module exports, naming consistency, TODO comments, and unused imports without rewriting source files.

  • typescript
  • tsx
  • +4
Ccodemod avatarcodemod
v0.1.13
2
3 months ago

Ready to evolve your codebase?

Build tailored, compiler-aware skills to assess, plan, and automate complex codebase changes.