mui-v4-create-mui-theme-to-v5-create-theme
Replace deprecated `createMuiTheme` usage from Material-UI v4-era imports with `createTheme` from `@mui/material/styles`, including deterministic import rewrites and call-site renaming in React JavaScript/TypeScript codebases.
# mui-v4-create-mui-theme-to-v5-create-theme
Replace deprecated `createMuiTheme` usage from Material-UI v4-era imports with `createTheme` from `@mui/material/styles`, including deterministic import rewrites and call-site renaming in React JavaScript/TypeScript codebases.
## What It Rewrites
- `import { createMuiTheme } from '@material-ui/core/styles'` to `import { createTheme } from '@mui/material/styles'`
- aliased named imports such as `import { createMuiTheme as makeTheme } ...` while preserving the local alias
- namespace imports such as `import * as muiStyles from '@material-ui/core/styles'` and member calls like `muiStyles.createMuiTheme(...)`
- CommonJS destructuring and namespace requires from `@material-ui/core/styles`
- named imports from `@material-ui/core` when they bind `createMuiTheme`
## What It Does Not Rewrite
- local functions or variables named `createMuiTheme` that are not imported from targeted Material-UI packages
- string literals, comments, or docs mentioning `createMuiTheme`
- already migrated `@mui/material/styles` `createTheme` usage
- theme option shape changes such as `palette.type`; that belongs in a separate MUI v5 theme-options codemod
## Scope
- processes `**/*.{js,jsx,ts,tsx,mjs,cjs}`
- excludes `node_modules`, `dist`, `build`, `.next`, and `coverage`
## Usage
```bash
# Run the local package against a target project
pnpm dlx codemod@latest workflow run -w . -t /path/to/project --no-interactive
# Run a published package from the registry
pnpm dlx codemod@latest mui-v4-create-mui-theme-to-v5-create-theme -t /path/to/project --no-interactive
```
## Example
Before:
```ts
import { createMuiTheme, ThemeProvider } from '@material-ui/core/styles';
const theme = createMuiTheme({ palette: { type: 'dark' } });
```
After:
```ts
import { createTheme, ThemeProvider } from '@mui/material/styles';
const theme = createTheme({ palette: { type: 'dark' } });
```
## Development
```bash
# Test the transformation
pnpm test
# Type-check the codemod
pnpm run check-types
# Validate the workflow
pnpm dlx codemod@latest workflow validate -w workflow.yaml
# Publish to registry
pnpm dlx codemod@latest login
pnpm dlx codemod@latest publish
```
## License
MIT