Codemod variant-prop doesn't change files as expected
See original GitHub issueDuplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Current behavior 😯
After running the variant-prop
codemod, no changes are applied.
Expected behavior 🤔
The script should normally add the variant="standard"
to all TextField, Select, and FormControls.
Steps to reproduce 🕹
Steps:
- Run npx @mui/codemod v5.0.0/variant-prop <path> on a project that does has TextField, Select, and FormControls with no variant defined.
Context 🔦
The output in my console when I’m running the command just shows that the script found 144 files but for some reason it left them unmodified:
npx: installed 251 in 4.335s Executing command: jscodeshift /npm/_npx/13468/lib/node_modules/@mui/codemod/node_modules/jscodeshift/bin/jscodeshift.js --transform //.npm/_npx/13468/lib/node_modules/@mui/codemod/node/v5.0.0/variant-prop.js --extensions js,ts,jsx,tsx --parser tsx --ignore-pattern **/node_modules/** Processing 144 files... Spawning 7 workers... Sending 21 files to free worker... Sending 21 files to free worker... Sending 21 files to free worker... Sending 21 files to free worker... Sending 21 files to free worker... Sending 21 files to free worker... Sending 18 files to free worker... All done. Results: 0 errors 144 unmodified 0 skipped 0 ok Time elapsed: 6.511seconds
Your environment 🌎
`npx @mui/envinfo`
System:
OS: macOS 11.6.2
Binaries:
Node: 12.22.1 - /usr/local/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 6.14.12 - /usr/local/bin/npm
Browsers:
Chrome: 96.0.4664.110
Edge: Not Found
Firefox: 95.0.2
Safari: 15.2
npmPackages:
@emotion/react: ^11.7.1 => 11.7.1
@emotion/styled: ^11.6.0 => 11.6.0
@mui/base: 5.0.0-alpha.62
@mui/icons-material: ^5.2.5 => 5.2.5
@mui/lab: ^5.0.0-alpha.30 => 5.0.0-alpha.62
@mui/material: ^5.2.5 => 5.2.6
@mui/private-theming: 5.2.3
@mui/styled-engine: 5.2.6
@mui/styles: ^5.2.3 => 5.2.3
@mui/system: 5.2.6
@mui/types: 7.1.0
@mui/utils: 5.2.3
@types/react: 16.9.17
react: ^17.0.2 => 17.0.2
react-dom: ^16.12.0 => 16.12.0
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top GitHub Comments
I think I found the issue, the codemod uses a regex to match “/^@material-ui/core(/TextField|/Select|/FormControl)?$/” but preset-safe rewrote the imports to “@mui/material” so they get skipped. When I change the import back, the changes were made.
I would say that this is a bug. To give the best experience, the Codemod should be independent of each other. The fix should be pretty straightforward (updating the regex to include
@mui/material
). Feel free to submit a PR (otherwise I can do it this week).