[codemod] Add packageName support to the v9 system props codemod by franco-dias · Pull Request #48253 · mui/material-ui (original) (raw)
Summary
The v9.0.0/system-props codemod ignores the --packageName CLI option. The import matching is hardcoded to only match @mui:
root.find(j.ImportDeclaration, decl => decl.source.value.includes('@mui'))
The CLI (codemod.js) accepts --packageName and passes it through to jscodeshift as options.packageName, but removeSystemProps.js never reads it. This means the option documented in the README has no effect for this codemod.
This is a problem for design systems that re-export MUI components under a custom package name. Those usages are silently skipped.
Fix
Read options.packageName and include it in the import declaration filter. When not provided, behavior is unchanged -- only @mui imports are matched.
const packageName = options.packageName; root.find(j.ImportDeclaration, decl => decl.source.value.includes('@mui') || (packageName && decl.source.value.includes(packageName)) )
Add unit tests to cover the behavior changes when the packageName option is provided.
- I have followed (at least) the PR section of the contributing guide.