Mmohebifar

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.

muimaterial-uimigrationthemingreact
Public
0 executions

Run locally

npx codemod mui-v4-create-mui-theme-to-v5-create-theme

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

Example

Before:

ts

After:

ts

Development

bash

License

MIT

Ready to contribute?

Build your own codemod and share it with the community.