@mui/codemod 5.15.13 → 5.15.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -1632,14 +1632,14 @@ npx @mui/codemod@latest v5.0.0/jss-to-tss-react <path>
|
|
|
1632
1632
|
The following scenarios are not currently handled by this codemod and will be marked with a
|
|
1633
1633
|
"TODO jss-to-tss-react codemod" comment:
|
|
1634
1634
|
|
|
1635
|
-
- If the hook returned by `makeStyles` (
|
|
1635
|
+
- If the hook returned by `makeStyles` (for example `useStyles`) is exported and used in another file,
|
|
1636
1636
|
the usages in other files will not be converted.
|
|
1637
1637
|
- Arrow functions as the value for a CSS prop will not be converted. Arrow functions **are**
|
|
1638
1638
|
supported at the rule level, though with some caveats listed below.
|
|
1639
1639
|
- In order for arrow functions at the rule level to be converted, the parameter must use object
|
|
1640
|
-
destructuring (
|
|
1641
|
-
(
|
|
1642
|
-
- If an arrow function at the rule level contains a code block (
|
|
1640
|
+
destructuring (for example `root: ({color, padding}) => (...)`). If the parameter is not destructured
|
|
1641
|
+
(for example `root: (props) => (...)`), it will not be converted.
|
|
1642
|
+
- If an arrow function at the rule level contains a code block (that is contains an explicit `return`
|
|
1643
1643
|
statement) rather than just an object expression, it will not be converted.
|
|
1644
1644
|
|
|
1645
1645
|
You can find more details about migrating from JSS to tss-react in [the migration guide](https://mui.com/material-ui/migration/migrating-from-jss/#2-use-tss-react).
|
|
@@ -102,7 +102,7 @@ function transformStylesExpression(j, comments, stylesExpression, nestedKeys, se
|
|
|
102
102
|
if (prop.value.body.type === 'ObjectExpression') {
|
|
103
103
|
let example = '';
|
|
104
104
|
if (prop.value.params[0].type === 'Identifier') {
|
|
105
|
-
example = ' (
|
|
105
|
+
example = ' (for example `(props) => ({...})` instead of `({color}) => ({...})`)';
|
|
106
106
|
}
|
|
107
107
|
extraComment = ` Arrow function has parameter type of ${prop.value.params[0].type} instead of ObjectPattern${example}.`;
|
|
108
108
|
} else {
|
|
@@ -303,7 +303,7 @@ function transformer(file, api, options) {
|
|
|
303
303
|
});
|
|
304
304
|
});
|
|
305
305
|
/**
|
|
306
|
-
* Convert classes assignment syntax in calls to the hook (
|
|
306
|
+
* Convert classes assignment syntax in calls to the hook (for example useStyles) and
|
|
307
307
|
* convert usages of clsx or classnames to cx.
|
|
308
308
|
*/
|
|
309
309
|
styleHooks.forEach(hookName => {
|
|
@@ -38,7 +38,7 @@ const useExportedStyles = exports.useExportedStyles = (0, _mui.makeStyles)()({
|
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
// TODO jss-to-tss-react codemod: Unable to handle style definition reliably. Unsupported arrow function syntax.
|
|
41
|
-
// Arrow function has parameter type of Identifier instead of ObjectPattern (
|
|
41
|
+
// Arrow function has parameter type of Identifier instead of ObjectPattern (for example `(props) => ({...})` instead of `({color}) => ({...})`).
|
|
42
42
|
const useStyles2 = (0, _mui.makeStyles)()({
|
|
43
43
|
test2: props => ({
|
|
44
44
|
backgroundColor: "blue",
|