Skip to content

Commit

Permalink
Bump jscodeshift to ^0.15.2 (#34680)
Browse files Browse the repository at this point in the history
  • Loading branch information
renovate[bot] authored Apr 11, 2024
1 parent 802a586 commit 17eea99
Show file tree
Hide file tree
Showing 25 changed files with 84 additions and 629 deletions.
4 changes: 2 additions & 2 deletions packages/mui-codemod/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@
"@babel/core": "^7.24.4",
"@babel/runtime": "^7.24.4",
"@babel/traverse": "^7.24.1",
"jscodeshift": "^0.13.1",
"jscodeshift": "^0.15.2",
"jscodeshift-add-imports": "^1.0.10",
"postcss": "^8.4.38",
"postcss-cli": "^8.3.1",
"yargs": "^17.7.2"
},
"devDependencies": {
"@types/chai": "^4.3.14",
"@types/jscodeshift": "0.11.5",
"@types/jscodeshift": "0.11.11",
"chai": "^4.4.1"
},
"sideEffects": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ export default function transformer(file, api) {
.find(j.ImportDeclaration)
.filter(({ node }) => {
const sourceVal = node.source.value;
if (sourceVal.startsWith('@mui/base')) {
node.source.value = sourceVal.replace(/unstyled/im, '');
node.source.raw = sourceVal.replace(/unstyled/im, '');
}

return sourceVal.startsWith('@mui/base');
})
.forEach((path) => {
const sourceVal = path.node.source.value;
if (sourceVal.startsWith('@mui/base')) {
path.node.source = j.stringLiteral(sourceVal.replace(/unstyled/im, ''));
}
const specifiers = [];
path.node.specifiers.forEach((elementNode) => {
const importedName = elementNode.imported?.name || '';
Expand Down
4 changes: 2 additions & 2 deletions packages/mui-codemod/src/v5.0.0/box-sx-prop.test/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Button from '@material-ui/core/Button';

export default function BoxComponent(props) {
return (
<Box
(<Box
sx={{
m: 2,
border: "1px dashed grey",
Expand All @@ -25,6 +25,6 @@ export default function BoxComponent(props) {
sx={{
p: [1, 2, 4]
}} />
</Box>
</Box>)
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default function Cart() {
});
};
return (
<Root>
(<Root>
<Head title="View cart">
<meta name="robots" content="noindex,nofollow" />
</Head>
Expand Down Expand Up @@ -208,6 +208,6 @@ export default function Cart() {
</OrderBody>
</Container>
<AppFooter />
</Root>
</Root>)
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export default function Page() {


return (
<StyledSomeNamespaceSomeComponent>
(<StyledSomeNamespaceSomeComponent>
<h1 className={classes.header}></h1>
<img className={classes.img}></img>
</StyledSomeNamespaceSomeComponent>
</StyledSomeNamespaceSomeComponent>)
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function SellHero() {


return (
<Root className={classes.root}>
(<Root className={classes.root}>
<Container className={classes.container}>
<Typography variant="h1" align="center" color="textPrimary" className={classes.title}>
Sell themes
Expand All @@ -87,7 +87,7 @@ function SellHero() {
</Button>
</div>
</Container>
</Root>
</Root>)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class AppAppBar extends React.Component {
const { menuOpen } = this.state;

return (
<StyledAppBar essential={essential} position={position}>
(<StyledAppBar essential={essential} position={position}>
<div className={clsx(classes.wrap, { [classes.wrapOpened]: menuOpen })}>
<Link to="/" aria-label="Back to homepage" color="inherit">
<Logo color={menuOpen ? 'inherit' : 'textPrimary'} />
Expand Down Expand Up @@ -237,7 +237,7 @@ class AppAppBar extends React.Component {
</div>
)}
</div>
</StyledAppBar>
</StyledAppBar>)
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ const StyledCard = styled(Card)(function getStyles(
export const MyCard = ((props) => {
const { } = props;
return (
<StyledCard className={classes.root}>
(<StyledCard className={classes.root}>
<CardActions className={classes.actions}>
<Button className={classes.button}>Submit</Button>
</CardActions>
</StyledCard>
</StyledCard>)
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export default function Page() {


return (
<Root>
(<Root>
<h1 className={classes.header}></h1>
<img className={classes.img}></img>
</Root>
</Root>)
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function AffiliatesHero() {


return (
<Root className={classes.root}>
(<Root className={classes.root}>
<Container className={classes.container}>
<Typography variant="h1" align="center" color="textPrimary" className={classes.title}>
Affiliate Program
Expand All @@ -85,7 +85,7 @@ function AffiliatesHero() {
</Button>
</div>
</Container>
</Root>
</Root>)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function Iframe(props) {
}, []);

return (
<Root>
(<Root>
{loaded === false ? (
<div className={classes.loader}>
<CircularProgress />
Expand All @@ -109,7 +109,7 @@ function Iframe(props) {
frameBorder="0"
{...props}
/>
</Root>
</Root>)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ const StyledCard = styled(Card)((
export const MyCard = ((props) => {
const { } = props;
return (
<StyledCard className={classes.root}>
(<StyledCard className={classes.root}>
<CardActions className={classes.actions}>
<Button className={classes.button}>Submit</Button>
</CardActions>
</StyledCard>
</StyledCard>)
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const Root = styled('div')((
const MyComponent = (props) => {


return <Root {...props} className={classes.root} />;
return (<Root {...props} className={classes.root} />);
};

export default MyComponent;
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const Root = styled('div')((
const MyComponent = (props) => {
const { } = props;

return <Root {...props} className={classes.root} />;
return (<Root {...props} className={classes.root} />);
};

export default (MyComponent);
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const Root = styled('div')({
const MyComponent = (props) => {
const { } = props;

return <Root {...props} className={classes.root} />;
return (<Root {...props} className={classes.root} />);
};

export default (MyComponent);
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const Root = styled('div')({
const MyComponent = (props) => {


return <Root {...props} className={classes.root} />;
return (<Root {...props} className={classes.root} />);
};

export default MyComponent;
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { makeStyles } from 'tss-react/mui';

const useStyles = makeStyles<{color: 'primary' | 'secondary', padding: number}, 'child' | 'small'>({name: 'App'})((theme, { color, padding }, classes) => ({
root: {
root: ({
padding: padding,

[`&:hover .${classes.child}`]: {
backgroundColor: theme.palette[color].main,
}
},
}),
small: {},
child: {
border: '1px solid black',
Expand All @@ -28,15 +29,15 @@ function App({classes: classesProp}: {classes?: any}) {
});

return (
<div className={classes.root}>
(<div className={classes.root}>
<div className={classes.child}>
The Background take the primary theme color when the mouse hovers the parent.
</div>
<div className={cx(classes.child, classes.small)}>
The Background take the primary theme color when the mouse hovers the parent.
I am smaller than the other child.
</div>
</div>
</div>)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ const useStyles = makeStyles<void, 'child' | 'small'>()((theme, _params, classes
function App() {
const { classes, cx } = useStyles();
return (
<div className={classes.parent}>
(<div className={classes.parent}>
<div className={classes.child}>
Background turns red when the mouse hovers over the parent.
</div>
<div className={cx(classes.child, classes.small)}>
Background turns red when the mouse hovers over the parent.
I am smaller than the other child.
</div>
</div>
</div>)
);
}

Expand Down
12 changes: 6 additions & 6 deletions packages/mui-codemod/src/v5.0.0/preset-safe.test/expected.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const Header = () => {
const classes = useStyles();
const { dark, setDark } = React.useContext(DarkContext);
return (
<AppBar color="default" position="sticky">
(<AppBar color="default" position="sticky">
<Toolbar>
<Typography className={classes.head} variant="h6">
👋 Hello
Expand All @@ -110,7 +110,7 @@ const Header = () => {
onChange={(event, checked) => setDark(checked)}
/>
</Toolbar>
</AppBar>
</AppBar>)
);
};

Expand All @@ -119,7 +119,7 @@ function App() {
const handleClose = () => setOpen(false);
const { setDark } = React.useContext(DarkContext);
const classes = useStyles();
return <>
return (<>
<CssBaseline />
<Header />
<Container>
Expand Down Expand Up @@ -173,7 +173,7 @@ function App() {
</DialogActions>
</Dialog>
</Container>
</>;
</>);
}

const withThemeProvider = (Component) => (props) => {
Expand All @@ -188,15 +188,15 @@ const withThemeProvider = (Component) => (props) => {
[dark],
);
return (
<DarkContext.Provider value={{ dark, setDark }}>
(<DarkContext.Provider value={{ dark, setDark }}>
<StylesProvider injectFirst>
<StyledEngineProvider injectFirst>
<ThemeProvider theme={theme}>
<Component {...props} />
</ThemeProvider>
</StyledEngineProvider>
</StylesProvider>
</DarkContext.Provider>
</DarkContext.Provider>)
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import Page from './pages';

const App = () => {
return (
<Providers>
(<Providers>
<StyledEngineProvider injectFirst>
<MuiThemeProvider theme={createMuiTheme()}>
<OtherProvider>
<Page />
</OtherProvider>
</MuiThemeProvider>
</StyledEngineProvider>
</Providers>
</Providers>)
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import Page from './pages';
const App = () => {
return (
<StyledEngineProvider injectFirst>
<ThemeProvider theme={createTheme()}>
(<ThemeProvider theme={createTheme()}>
<OtherProvider>
<Page />
</OtherProvider>
</ThemeProvider>
</ThemeProvider>)
</StyledEngineProvider>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { createTheme, ThemeProvider, Theme } from '@material-ui/core';

function App() {
return (
<ThemeProvider theme={createTheme()}>
(<ThemeProvider theme={createTheme()}>
<div data-testid="foo" />
</ThemeProvider>
</ThemeProvider>)
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { createTheme, ThemeProvider, Theme } from '@material-ui/core/styles';

function App() {
return (
<ThemeProvider theme={createTheme()}>
(<ThemeProvider theme={createTheme()}>
<div data-testid="foo" />
</ThemeProvider>
</ThemeProvider>)
);
}
Loading

0 comments on commit 17eea99

Please sign in to comment.