codemod/mui-gridlist-to-grid-migration
Replace deprecated Material UI GridList/GridListTile usage with Grid container/item composition.
# @codemod/mui-gridlist-to-grid-migration
Replace deprecated `GridList`/`GridListTile` usage with modern Material UI `Grid` composition, including import rewrites and prop mapping, to improve maintainability and alignment with current MUI best practices.
## Usage
```bash
# Run from the registry
npx codemod@latest run @codemod/mui-gridlist-to-grid-migration
# Or run locally
npx codemod@latest run -w workflow.yaml
```
## What It Rewrites
- `GridList` becomes `Grid` with the `container` prop.
- `GridListTile` becomes `Grid` with the `item` prop.
- `cols` is mapped to `xs` using a 12-column grid calculation.
- Numeric `spacing` values are converted from pixel gaps to MUI Grid spacing units by dividing by `8` and rounding.
- Expression-based `spacing` values are rewritten to `Math.round(expr / 8)` so Grid still receives scale units instead of pixel values.
- Legacy `GridList`, `GridListTile`, and `GridListTileBar` imports are removed, and a `Grid` import is added when needed.
- The migration always targets `@mui/material/Grid`; it does not expose mode flags for alternate import targets or helper emission.
## Supported Inputs
- Default imports such as `@material-ui/core/GridList` and `@material-ui/core/GridListTile`
- Named imports such as `import { GridList, GridListTile } from '@material-ui/core'`
- Aliased named imports such as `GridList as LegacyGridList`
- JavaScript, JSX, TypeScript, and TSX files
- Nested `GridList` blocks, which are transformed independently with their own `cols` mapping
## Preserved Behavior
- Non-layout props such as `className`, `style`, `id`, `key`, `data-*`, and event handlers are preserved.
- Existing `Grid` imports are reused instead of duplicated.
- Locally shadowed `GridList` identifiers are not transformed.
## Manual Follow-Up
- `rows` has no direct `Grid` equivalent. The codemod leaves a TODO comment on migrated tiles that used it.
- `GridListTileBar` is replaced with a TODO comment for manual migration to `ImageListItemBar` or an app-specific overlay.
- `cellHeight` is not recreated automatically. Files using that prop are left unchanged for manual review.
## Development
```bash
# Test the fixtures
pnpm test
# Check types
pnpm check-types
# Validate the workflow
npx codemod@latest workflow validate -w workflow.yaml
```
## License
MIT