Product
Introducing Ruby Support in Socket
Socket is launching Ruby support for all users. Enhance your Rails projects with AI-powered security scans for vulnerabilities and supply chain threats. Now in Beta!
@mui/x-codemod
Advanced tools
Codemod scripts for MUI X
This repository contains a collection of codemod scripts based for use with jscodeshift that help update MUI X APIs.
npx @mui/x-codemod <codemod> <paths...>
Applies a `@mui/x-codemod` to the specified paths
Positionals:
codemod The name of the codemod [string]
paths Paths forwarded to `jscodeshift` [string]
Options:
--version Show version number [boolean]
--help Show help [boolean]
--parser which parser for jscodeshift to use.
[string] [default: 'tsx']
--jscodeshift Pass options directly to jscodeshift [array]
Examples:
npx @mui/x-codemod v6.0.0/preset-safe src
npx @mui/x-codemod v6.0.0/component-rename-prop src --
--component=DataGrid --from=prop --to=newProp
jscodeshift
optionsTo pass more options directly to jscodeshift, use --jscodeshift=...
. For example:
// single option
npx @mui/x-codemod --jscodeshift=--run-in-band
// multiple options
npx @mui/x-codemod --jscodeshift=--cpus=1 --jscodeshift=--print --jscodeshift=--dry --jscodeshift=--verbose=2
See all available options here.
Recast
OptionsOptions to recast's printer can be provided
through jscodeshift's printOptions
command line argument
npx @mui/x-codemod <transform> <path> --jscodeshift="--printOptions='{\"quote\":\"double\"}'"
preset-safe
A combination of all important transformers for migrating v5 to v6. ⚠️ This codemod should be run only once.
npx @mui/x-codemod v6.0.0/preset-safe <path|folder>
The list includes these transformers
localization-provider-rename-locale
Renames locale
into adapterLocale
(or LocalizationProvider
)
<LocalizationProvider
dateAdapter={AdapterDayjs}
- locale="fr"
+ adapterLocale="fr"
>
{children}
</LocalizationProvider
npx @mui/x-codemod v6.0.0/localization-provider-rename-locale <path>
text-props-to-localeText
Replace props used for localization such as cancelText
to their corresponding localeText
key.
<DatePicker
- cancelText="Cancelar"
+ localeText={{
+ cancelButtonLabel: "Cancelar"
+ }}
/>
npx @mui/x-codemod v6.0.0/text-props-to-localeText <path>
If you were always using the same text value in all your components, consider moving those translation from the component to the LocalizationProvider
by hand.
<LocalizationProvider
dateAdapter={AdapterDayjs}
+ localeText={{ cancelButtonLabel: "Cancelar" }}
>
<DatePicker
- localeText={{ cancelButtonLabel: "Cancelar" }}
/>
<DateTimePicker
- localeText={{ cancelButtonLabel: "Cancelar" }}
/>
</LocalizationProvider>
You can find more details about this breaking change in the migration guide.
FAQs
Codemod scripts for MUI X.
The npm package @mui/x-codemod receives a total of 986 weekly downloads. As such, @mui/x-codemod popularity was classified as not popular.
We found that @mui/x-codemod demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket is launching Ruby support for all users. Enhance your Rails projects with AI-powered security scans for vulnerabilities and supply chain threats. Now in Beta!
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.