Mmohebifar

sentry-flex-layout

Transform CSS-IN-JS styled components to Sentry Flex Layout components

transformationmigration
Public
1 executions
2 stars
How to Use
Run this codemod on your codebase using one of the following commands

The easiest way to run this codemod without installing anything globally:

Documentation

sentry-flex-layout

Transform CSS-IN-JS styled components to Sentry Flex Layout components

Installation

bash

Usage

This codemod transforms CSS-IN-JS styled components with flexbox properties into Sentry's Flex Layout components.

Example Transformation

Before:

jsx

After:

jsx

Supported CSS Properties

The codemod converts the following CSS flexbox properties to Flex component props:

  • justify-contentjustify (flex-start → start, flex-end → end, etc.)
  • align-itemsalign (flex-start → start, flex-end → end, etc.)
  • flex-directiondirection (row, column, row-reverse, column-reverse)
  • flex-wrapwrap (wrap, nowrap, wrap-reverse)
  • gapgap (preserved as-is)

Requirements

  • Only transforms styled("div") components that include display: flex
  • Requires the Flex component to be imported
  • Preserves all other styled components unchanged

Development

bash

Migration Strategy

This codemod is designed to handle large-scale migrations of CSS-IN-JS flex layouts to component-based layouts. It:

  1. Finds candidates: Automatically identifies styled("div") components with flex properties
  2. Extracts properties: Parses CSS and maps flexbox properties to component props
  3. Generates components: Creates JSX Flex components with appropriate props
  4. Preserves children: Maintains {children} placeholder for component usage

For large codebases with 325+ instances, run the codemod incrementally and test each transformation.

License

MIT

Ready to contribute?

Build your own codemod and share it with the community.