Skip to content

Fix/codemod top level imports 45051 #46405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
5 changes: 1 addition & 4 deletions packages/mui-codemod/src/v5.0.0/top-level-imports.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ export default function transformer(fileInfo, api, options) {
break;
}
case 'ImportSpecifier':
if (
!whitelist.has(specifier.imported.name) == null &&
specifier.imported.name !== 'withStyles'
) {
if (!whitelist.has(specifier.imported.name) && specifier.imported.name !== 'withStyles') {
return;
}
resultSpecifiers.push(specifier);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ import TableFooter from '@mui/material/TableFooter';
import Zoom from '@mui/material/Zoom';
import ClickAwayListener from '@mui/material/ClickAwayListener';
import ListSubheader from '@mui/material/ListSubheader';
import { grey, blue } from '@mui/material/colors';
import { grey as grey2 } from '@mui/material/colors';
import { blue as blue2 } from '@mui/material/colors';
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { withStyles } from '@mui/styles';

import {
ThemeProvider,
createTheme,
MenuItem,
Tab,
Tabs as MuiTabs,
Expand Down Expand Up @@ -59,3 +58,7 @@ import {
ClickAwayListener,
ListSubheader,
} from '@mui/material';
import { createTheme } from '@mui/material/styles';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is createTheme moved? Is createTheme not included on the whitelist?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, that's right it's not currently in the whitelist so to get the tests passing I moved it outside of the @mui/material import.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@siriwatknp do you know if this is correct?

import { grey, blue } from '@mui/material/colors';
import { grey as grey2 } from '@mui/material/colors';
import { blue as blue2 } from '@mui/material/colors';