@mui/codemod 5.0.0 → 5.0.4
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/LICENSE +21 -21
- package/README.md +20 -2
- package/codemod.js +0 -0
- package/node/v1.0.0/menu-item-primary-text.js +30 -0
- package/node/v1.0.0/menu-item-primary-text.test/actual.js +32 -0
- package/node/v1.0.0/menu-item-primary-text.test/expected.js +32 -0
- package/node/v5.0.0/create-theme.test/custom-fn.actual.js +1 -1
- package/node/v5.0.0/create-theme.test/custom-fn.expected.js +1 -1
- package/node/v5.0.0/jss-to-styled.js +1 -1
- package/node/v5.0.0/jss-to-styled.test/Anonymous.expected.js +1 -1
- package/node/v5.0.0/jss-to-styled.test/eighth.expected.js +1 -1
- package/node/v5.0.0/jss-to-styled.test/eleventh.expected.js +1 -1
- package/node/v5.0.0/jss-to-styled.test/exportClass.expected.js +1 -1
- package/node/v5.0.0/jss-to-styled.test/exportFunction.expected.js +1 -1
- package/node/v5.0.0/jss-to-styled.test/fifth.expected.js +1 -1
- package/node/v5.0.0/jss-to-styled.test/first.expected.js +1 -1
- package/node/v5.0.0/jss-to-styled.test/fourth.expected.js +1 -1
- package/node/v5.0.0/jss-to-styled.test/nineth.expected.js +1 -1
- package/node/v5.0.0/jss-to-styled.test/second.expected.js +1 -1
- package/node/v5.0.0/jss-to-styled.test/seventh.expected.js +1 -1
- package/node/v5.0.0/jss-to-styled.test/sixth.expected.js +1 -1
- package/node/v5.0.0/jss-to-styled.test/tenth.expected.js +1 -1
- package/node/v5.0.0/jss-to-styled.test/third.expected.js +1 -1
- package/node/v5.0.0/jss-to-styled.test/withCreateStyles.expected.js +1 -1
- package/node/v5.0.0/jss-to-styled.test/withCreateStyles1.expected.js +1 -1
- package/node/v5.0.0/jss-to-styled.test/withCreateStyles2.expected.js +1 -1
- package/node/v5.0.0/jss-to-styled.test/withCreateStyles3.expected.js +1 -1
- package/node/v5.0.0/optimal-imports.js +14 -4
- package/node/v5.0.0/theme-spacing.js +1 -1
- package/node/v5.0.0/theme-spacing.test/actual.js +1 -1
- package/node/v5.0.0/theme-spacing.test/expected.js +4 -1
- package/package.json +7 -6
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2014 Call-Em-All
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014 Call-Em-All
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -542,7 +542,7 @@ import Typography from '@material-ui/core/Typography';
|
|
|
542
542
|
- backgroundColor: theme.palette.primary.main
|
|
543
543
|
- },
|
|
544
544
|
- cta: {
|
|
545
|
-
- borderRadius: theme.shape.radius
|
|
545
|
+
- borderRadius: theme.shape.radius
|
|
546
546
|
- },
|
|
547
547
|
- content: {
|
|
548
548
|
- color: theme.palette.common.white,
|
|
@@ -563,7 +563,7 @@ import Typography from '@material-ui/core/Typography';
|
|
|
563
563
|
+ backgroundColor: theme.palette.primary.main
|
|
564
564
|
+ },
|
|
565
565
|
+ [`& .${classes.cta}`]: {
|
|
566
|
-
+ borderRadius: theme.shape.radius
|
|
566
|
+
+ borderRadius: theme.shape.radius
|
|
567
567
|
+ },
|
|
568
568
|
+ [`& .${classes.content}`]: {
|
|
569
569
|
+ color: theme.palette.common.white,
|
|
@@ -1266,6 +1266,24 @@ The diff should look like this:
|
|
|
1266
1266
|
npx @mui/codemod v1.0.0/svg-icon-imports <path>
|
|
1267
1267
|
```
|
|
1268
1268
|
|
|
1269
|
+
#### `menu-item-primary-text`
|
|
1270
|
+
|
|
1271
|
+
Updates `MenuItem` with `primaryText` property making its value tag's child.
|
|
1272
|
+
The diff should look like this:
|
|
1273
|
+
|
|
1274
|
+
```diff
|
|
1275
|
+
-<MenuItem primaryText="Profile" />
|
|
1276
|
+
-<MenuItem primaryText={"Profile" + "!"} />
|
|
1277
|
+
+<MenuItem>Profile</MenuItem>
|
|
1278
|
+
+<MenuItem>{"Profile" + "!"}</MenuItem>
|
|
1279
|
+
```
|
|
1280
|
+
|
|
1281
|
+
<!-- #default-branch-switch -->
|
|
1282
|
+
|
|
1283
|
+
```sh
|
|
1284
|
+
npx @mui/codemod v1.0.0/menu-item-primary-text <path>
|
|
1285
|
+
```
|
|
1286
|
+
|
|
1269
1287
|
### v0.15.0
|
|
1270
1288
|
|
|
1271
1289
|
#### `import-path`
|
package/codemod.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = transformer;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @param {import('jscodeshift').FileInfo} file
|
|
10
|
+
* @param {import('jscodeshift').API} api
|
|
11
|
+
*/
|
|
12
|
+
function transformer(file, api, options) {
|
|
13
|
+
const j = api.jscodeshift;
|
|
14
|
+
const printOptions = options.printOptions;
|
|
15
|
+
return j(file.source).findJSXElements('MenuItem').forEach(path => {
|
|
16
|
+
if (!path.node.openingElement.selfClosing) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const attributes = path.node.openingElement.attributes;
|
|
21
|
+
attributes.forEach((node, index) => {
|
|
22
|
+
if (node.type === 'JSXAttribute' && node.name.name === 'primaryText') {
|
|
23
|
+
delete attributes[index];
|
|
24
|
+
path.node.openingElement.selfClosing = false;
|
|
25
|
+
path.node.children = [node.value];
|
|
26
|
+
path.node.closingElement = j.jsxClosingElement(path.node.openingElement.name);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}).toSource(printOptions);
|
|
30
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
|
|
5
|
+
/*#__PURE__*/
|
|
6
|
+
(0, _jsxRuntime.jsxs)("div", {
|
|
7
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(MenuItem, {
|
|
8
|
+
onClick: () => {
|
|
9
|
+
analytics('Clicked Menu > Progress');
|
|
10
|
+
},
|
|
11
|
+
primaryText: "My Progress",
|
|
12
|
+
rightIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(ProgressIcon, {})
|
|
13
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(MenuItem, {
|
|
14
|
+
onClick: () => {
|
|
15
|
+
analytics('Clicked Menu > Progress2');
|
|
16
|
+
},
|
|
17
|
+
primaryText: true ? "My Progress" : "Not progress",
|
|
18
|
+
rightIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(ProgressIcon, {})
|
|
19
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(MenuItem, {
|
|
20
|
+
onClick: () => {
|
|
21
|
+
analytics('Clicked Menu > Progress2');
|
|
22
|
+
},
|
|
23
|
+
primaryText: getText('progress'),
|
|
24
|
+
rightIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(ProgressIcon, {})
|
|
25
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(MenuItem, {
|
|
26
|
+
onClick: () => {
|
|
27
|
+
analytics('Clicked Menu > Progress');
|
|
28
|
+
},
|
|
29
|
+
rightIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(ProgressIcon, {}),
|
|
30
|
+
children: "Already changed"
|
|
31
|
+
})]
|
|
32
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
4
|
+
|
|
5
|
+
/*#__PURE__*/
|
|
6
|
+
(0, _jsxRuntime.jsxs)("div", {
|
|
7
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(MenuItem, {
|
|
8
|
+
onClick: () => {
|
|
9
|
+
analytics('Clicked Menu > Progress');
|
|
10
|
+
},
|
|
11
|
+
rightIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(ProgressIcon, {}),
|
|
12
|
+
children: "My Progress"
|
|
13
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(MenuItem, {
|
|
14
|
+
onClick: () => {
|
|
15
|
+
analytics('Clicked Menu > Progress2');
|
|
16
|
+
},
|
|
17
|
+
rightIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(ProgressIcon, {}),
|
|
18
|
+
children: true ? "My Progress" : "Not progress"
|
|
19
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(MenuItem, {
|
|
20
|
+
onClick: () => {
|
|
21
|
+
analytics('Clicked Menu > Progress2');
|
|
22
|
+
},
|
|
23
|
+
rightIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(ProgressIcon, {}),
|
|
24
|
+
children: getText('progress')
|
|
25
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(MenuItem, {
|
|
26
|
+
onClick: () => {
|
|
27
|
+
analytics('Clicked Menu > Progress');
|
|
28
|
+
},
|
|
29
|
+
rightIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(ProgressIcon, {}),
|
|
30
|
+
children: "Already changed"
|
|
31
|
+
})]
|
|
32
|
+
});
|
|
@@ -5,9 +5,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
+
exports.createTheme = createTheme;
|
|
8
9
|
exports.createThemeOptions = createThemeOptions;
|
|
9
10
|
exports.createThemeOverrides = createThemeOverrides;
|
|
10
|
-
exports.createTheme = createTheme;
|
|
11
11
|
|
|
12
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
13
|
|
|
@@ -5,9 +5,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
+
exports.createTheme = createTheme;
|
|
8
9
|
exports.createThemeOptions = createThemeOptions;
|
|
9
10
|
exports.createThemeOverrides = createThemeOverrides;
|
|
10
|
-
exports.createTheme = createTheme;
|
|
11
11
|
|
|
12
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
13
|
|
|
@@ -517,7 +517,7 @@ function transformer(file, api, options) {
|
|
|
517
517
|
});
|
|
518
518
|
|
|
519
519
|
if (!imports.size()) {
|
|
520
|
-
root.find(j.ImportDeclaration).at(0).forEach(path => path.insertAfter(j.importDeclaration([j.importSpecifier(j.identifier('styled'))], j.literal('@material
|
|
520
|
+
root.find(j.ImportDeclaration).at(0).forEach(path => path.insertAfter(j.importDeclaration([j.importSpecifier(j.identifier('styled'))], j.literal('@mui/material/styles'))));
|
|
521
521
|
}
|
|
522
522
|
/**
|
|
523
523
|
* remove import
|
|
@@ -9,7 +9,7 @@ exports.default = Cart;
|
|
|
9
9
|
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
|
|
12
|
-
var _styles = require("@material
|
|
12
|
+
var _styles = require("@mui/material/styles");
|
|
13
13
|
|
|
14
14
|
var _Typography = _interopRequireDefault(require("@material-ui/core/Typography"));
|
|
15
15
|
|
|
@@ -9,7 +9,7 @@ exports.default = Page;
|
|
|
9
9
|
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
|
|
12
|
-
var _styles = require("@material
|
|
12
|
+
var _styles = require("@mui/material/styles");
|
|
13
13
|
|
|
14
14
|
var _SomeNamespace = _interopRequireDefault(require("SomeNamespace"));
|
|
15
15
|
|
|
@@ -9,7 +9,7 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
|
|
12
|
-
var _styles = require("@material
|
|
12
|
+
var _styles = require("@mui/material/styles");
|
|
13
13
|
|
|
14
14
|
var _Typography2 = _interopRequireDefault(require("@material-ui/core/Typography"));
|
|
15
15
|
|
|
@@ -9,7 +9,7 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
|
|
12
|
-
var _styles = require("@material
|
|
12
|
+
var _styles = require("@mui/material/styles");
|
|
13
13
|
|
|
14
14
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
15
|
|
|
@@ -9,7 +9,7 @@ exports.MyCard = void 0;
|
|
|
9
9
|
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
|
|
12
|
-
var _styles = require("@material
|
|
12
|
+
var _styles = require("@mui/material/styles");
|
|
13
13
|
|
|
14
14
|
var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
|
|
15
15
|
|
|
@@ -9,7 +9,7 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
|
|
12
|
-
var _styles = require("@material
|
|
12
|
+
var _styles = require("@mui/material/styles");
|
|
13
13
|
|
|
14
14
|
var _Typography2 = _interopRequireDefault(require("@material-ui/core/Typography"));
|
|
15
15
|
|
|
@@ -11,7 +11,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
11
11
|
|
|
12
12
|
var _react = _interopRequireDefault(require("react"));
|
|
13
13
|
|
|
14
|
-
var _styles = require("@material
|
|
14
|
+
var _styles = require("@mui/material/styles");
|
|
15
15
|
|
|
16
16
|
var _CircularProgress2 = _interopRequireDefault(require("@material-ui/core/CircularProgress"));
|
|
17
17
|
|
|
@@ -11,7 +11,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
11
11
|
|
|
12
12
|
var _react = _interopRequireDefault(require("react"));
|
|
13
13
|
|
|
14
|
-
var _styles = require("@material
|
|
14
|
+
var _styles = require("@mui/material/styles");
|
|
15
15
|
|
|
16
16
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
17
17
|
|
|
@@ -9,7 +9,7 @@ exports.MyCard = void 0;
|
|
|
9
9
|
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
|
|
12
|
-
var _styles = require("@material
|
|
12
|
+
var _styles = require("@mui/material/styles");
|
|
13
13
|
|
|
14
14
|
var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
|
|
15
15
|
|
|
@@ -11,7 +11,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
11
11
|
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
13
13
|
|
|
14
|
-
var _styles = require("@material
|
|
14
|
+
var _styles = require("@mui/material/styles");
|
|
15
15
|
|
|
16
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
17
|
|
|
@@ -11,7 +11,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
11
11
|
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
13
13
|
|
|
14
|
-
var _styles = require("@material
|
|
14
|
+
var _styles = require("@mui/material/styles");
|
|
15
15
|
|
|
16
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
17
|
|
|
@@ -11,7 +11,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
11
11
|
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
13
13
|
|
|
14
|
-
var _styles = require("@material
|
|
14
|
+
var _styles = require("@mui/material/styles");
|
|
15
15
|
|
|
16
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
17
|
|
|
@@ -11,7 +11,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
11
11
|
|
|
12
12
|
var React = _interopRequireWildcard(require("react"));
|
|
13
13
|
|
|
14
|
-
var _styles = require("@material
|
|
14
|
+
var _styles = require("@mui/material/styles");
|
|
15
15
|
|
|
16
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
17
|
|
|
@@ -17,7 +17,7 @@ var _getJSExports = _interopRequireDefault(require("../util/getJSExports"));
|
|
|
17
17
|
if (process.env.NODE_ENV === 'test') {
|
|
18
18
|
const resolve = require.resolve;
|
|
19
19
|
|
|
20
|
-
require.resolve = source => resolve(source.replace(/^@material-ui\/core\/modern/, '../../../mui-material/src'));
|
|
20
|
+
require.resolve = source => resolve(source.replace(/^@material-ui\/core\/es/, '../../../mui-material/src').replace(/^@material-ui\/core\/modern/, '../../../mui-material/src'));
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
function transformer(fileInfo, api, options) {
|
|
@@ -59,9 +59,19 @@ function transformer(fileInfo, api, options) {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
const targetImportPath = `${targetModule}/${subpath}`;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
let loader;
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
loader = require.resolve(`${importModule}/modern/${subpath}`, {
|
|
66
|
+
paths: [(0, _path.dirname)(fileInfo.path)]
|
|
67
|
+
});
|
|
68
|
+
} catch (error) {
|
|
69
|
+
loader = require.resolve(`${importModule}/es/${subpath}`, {
|
|
70
|
+
paths: [(0, _path.dirname)(fileInfo.path)]
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const whitelist = (0, _getJSExports.default)(loader);
|
|
65
75
|
path.node.specifiers.forEach((specifier, index) => {
|
|
66
76
|
if (!path.node.specifiers.length) {
|
|
67
77
|
return;
|
|
@@ -10,7 +10,7 @@ exports.default = transformer;
|
|
|
10
10
|
*/
|
|
11
11
|
function transformer(file) {
|
|
12
12
|
return file.source // `${theme.spacing(2)}px` -> theme.spacing(2)
|
|
13
|
-
.replace(
|
|
13
|
+
.replace(/`(-?)\${(-?)(theme\.spacing|spacing)\(([^{}]*)\)}px`/gm, '$3($1$2$4)') // `${theme.spacing(2)}px ${theme.spacing(4)}px` -> `${theme.spacing(2)} ${theme.spacing(4)}`
|
|
14
14
|
.replace(/(?<={(theme\.spacing|spacing)\(.*\)})px/gm, '').replace(/((theme\.spacing|spacing)\(.*\))\s*\+\s*'px'/gm, '$1').replace(/\${(theme.spacing|spacing)(\(.*\))\s*([+-])\s*([\d.]+)\s*}px/gm, // eslint-disable-next-line no-template-curly-in-string
|
|
15
15
|
'calc(${$1$2} $3 $4px)').replace(/\${(theme.spacing|spacing)(\(.*\))\s*([*/])\s*([\d.]+)\s*}px/gm, // eslint-disable-next-line no-template-curly-in-string
|
|
16
16
|
'calc(${$1$2} $3 $4)');
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
theme.spacing(gap) + 'px';
|
|
5
5
|
spacing(gap) + 'px'`calc(100% - ${spacing(itemHorzPadding * 2)}px)``calc(100% - ${theme.spacing(itemHorzPadding * 2)}px)`;
|
|
6
6
|
|
|
7
|
-
padding: `${theme.spacing(2) - 1}px 0``calc(100% - ${theme.spacing(itemHorzPadding) * 0.3}px)`;
|
|
7
|
+
padding: `${theme.spacing(2) - 1}px 0``calc(100% - ${theme.spacing(itemHorzPadding) * 0.3}px)``${-theme.spacing(1)}px``-${theme.spacing(1)}px`;
|
|
@@ -7,4 +7,7 @@ theme.spacing(0.5)`${theme.spacing(1 / 2)} ${theme.spacing(4)}`;
|
|
|
7
7
|
theme.spacing(gap);
|
|
8
8
|
spacing(gap)`calc(100% - ${spacing(itemHorzPadding * 2)})``calc(100% - ${theme.spacing(itemHorzPadding * 2)})`;
|
|
9
9
|
|
|
10
|
-
padding: `calc(${theme.spacing(2)} - 1px) 0``calc(100% - calc(${theme.spacing(itemHorzPadding)} * 0.3))`;
|
|
10
|
+
padding: `calc(${theme.spacing(2)} - 1px) 0``calc(100% - calc(${theme.spacing(itemHorzPadding)} * 0.3))`;
|
|
11
|
+
|
|
12
|
+
theme.spacing(-1);
|
|
13
|
+
theme.spacing(-1);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/codemod",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.4",
|
|
4
4
|
"bin": "./codemod.js",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "MUI Team",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"homepage": "https://github.com/mui-org/material-ui/tree/master/packages/mui-codemod",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@babel/core": "^7.15.
|
|
30
|
-
"@babel/runtime": "^7.
|
|
31
|
-
"@babel/traverse": "^7.15.
|
|
29
|
+
"@babel/core": "^7.15.8",
|
|
30
|
+
"@babel/runtime": "^7.15.4",
|
|
31
|
+
"@babel/traverse": "^7.15.4",
|
|
32
32
|
"jscodeshift": "^0.13.0",
|
|
33
33
|
"jscodeshift-add-imports": "^1.0.10",
|
|
34
|
-
"yargs": "^17.
|
|
34
|
+
"yargs": "^17.2.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/jscodeshift": "0.11.2"
|
|
@@ -42,5 +42,6 @@
|
|
|
42
42
|
},
|
|
43
43
|
"engines": {
|
|
44
44
|
"node": ">=12.0.0"
|
|
45
|
-
}
|
|
45
|
+
},
|
|
46
|
+
"gitHead": "86443310e4344ae1ce6e04f084d58e17e4d62170"
|
|
46
47
|
}
|