@mui/codemod 5.4.4 → 5.5.3

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.
@@ -7,21 +7,26 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.default = transformer;
9
9
 
10
+ var _path = require("path");
11
+
10
12
  var _jscodeshiftAddImports = _interopRequireDefault(require("jscodeshift-add-imports"));
11
13
 
14
+ var _getJSExports = _interopRequireDefault(require("../util/getJSExports"));
15
+
16
+ // istanbul ignore next
17
+ if (process.env.NODE_ENV === 'test') {
18
+ const resolve = require.resolve;
19
+
20
+ require.resolve = source => resolve(source.replace(/^@mui\/material\/modern/, '../../../mui-material/src'));
21
+ }
22
+
12
23
  function transformer(fileInfo, api, options) {
13
24
  const j = api.jscodeshift;
14
25
  const importModule = options.importModule || '@mui/material';
15
26
  const targetModule = options.targetModule || '@mui/material';
16
- let requirePath = importModule;
17
-
18
- if (process.env.NODE_ENV === 'test') {
19
- requirePath = requirePath.replace(/^@mui\/material/, '../../../mui-material/src');
20
- } // eslint-disable-next-line global-require, import/no-dynamic-require
21
-
22
-
23
- const whitelist = require(requirePath);
24
-
27
+ const whitelist = (0, _getJSExports.default)(require.resolve(`${importModule}/modern`, {
28
+ paths: [(0, _path.dirname)(fileInfo.path)]
29
+ }));
25
30
  const printOptions = options.printOptions || {
26
31
  quote: 'single',
27
32
  trailingComma: true
@@ -64,7 +69,7 @@ function transformer(fileInfo, api, options) {
64
69
  const localName = specifier.local.name;
65
70
  const moduleName = match[1];
66
71
 
67
- if (whitelist[moduleName] == null) {
72
+ if (!whitelist.has(moduleName)) {
68
73
  return;
69
74
  }
70
75
 
@@ -74,7 +79,7 @@ function transformer(fileInfo, api, options) {
74
79
  }
75
80
 
76
81
  case 'ImportSpecifier':
77
- if (whitelist[specifier.imported.name] == null && specifier.imported.name !== 'withStyles') {
82
+ if (!whitelist.has(specifier.imported.name) == null && specifier.imported.name !== 'withStyles') {
78
83
  return;
79
84
  }
80
85
 
@@ -16,7 +16,7 @@ function transformer(file, api, options) {
16
16
  const variant = attributes.find(node => node.type === 'JSXAttribute' && node.name.name === 'variant');
17
17
 
18
18
  if (!variant) {
19
- attributes.push(j.jsxAttribute(j.jsxIdentifier('variant'), j.literal('standard')));
19
+ attributes.unshift(j.jsxAttribute(j.jsxIdentifier('variant'), j.literal('standard')));
20
20
  }
21
21
  }
22
22
 
@@ -27,25 +27,25 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
27
27
 
28
28
  function TextFieldComponent(props) {
29
29
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
30
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_TextField4.default, (0, _extends2.default)({}, props, {
30
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_TextField4.default, (0, _extends2.default)({
31
31
  variant: "standard"
32
- })), _TextField || (_TextField = /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextField4.default, {
32
+ }, props)), _TextField || (_TextField = /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextField4.default, {
33
33
  variant: "outlined"
34
34
  })), _TextField2 || (_TextField2 = /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextField4.default, {
35
35
  variant: "standard"
36
36
  })), _TextField3 || (_TextField3 = /*#__PURE__*/(0, _jsxRuntime.jsx)(_TextField4.default, {
37
37
  variant: "filled"
38
- })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Select4.default, (0, _extends2.default)({}, props, {
38
+ })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_Select4.default, (0, _extends2.default)({
39
39
  variant: "standard"
40
- })), _Select || (_Select = /*#__PURE__*/(0, _jsxRuntime.jsx)(_Select4.default, {
40
+ }, props)), _Select || (_Select = /*#__PURE__*/(0, _jsxRuntime.jsx)(_Select4.default, {
41
41
  variant: "outlined"
42
42
  })), _Select2 || (_Select2 = /*#__PURE__*/(0, _jsxRuntime.jsx)(_Select4.default, {
43
43
  variant: "standard"
44
44
  })), _Select3 || (_Select3 = /*#__PURE__*/(0, _jsxRuntime.jsx)(_Select4.default, {
45
45
  variant: "filled"
46
- })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_FormControl4.default, (0, _extends2.default)({}, props, {
46
+ })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_FormControl4.default, (0, _extends2.default)({
47
47
  variant: "standard"
48
- })), _FormControl || (_FormControl = /*#__PURE__*/(0, _jsxRuntime.jsx)(_FormControl4.default, {
48
+ }, props)), _FormControl || (_FormControl = /*#__PURE__*/(0, _jsxRuntime.jsx)(_FormControl4.default, {
49
49
  variant: "outlined"
50
50
  })), _FormControl2 || (_FormControl2 = /*#__PURE__*/(0, _jsxRuntime.jsx)(_FormControl4.default, {
51
51
  variant: "standard"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/codemod",
3
- "version": "5.4.4",
3
+ "version": "5.5.3",
4
4
  "bin": "./codemod.js",
5
5
  "private": false,
6
6
  "author": "MUI Team",