@mui/x-codemod 6.0.3 → 6.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/codemod.js CHANGED
@@ -86,6 +86,5 @@ _yargs.default.command({
86
86
  type: 'array'
87
87
  });
88
88
  },
89
- // @ts-expect-error
90
89
  handler: run
91
90
  }).scriptName('npx @mui/x-codemod').example('$0 v6.0.0/preset-safe src', 'Run "preset-safe" codemod on "src" path').example('$0 v6.0.0/component-rename-prop src -- --component=DataGrid --from=prop --to=newProp', 'Run "component-rename-prop" codemod in "src" path on "DataGrid" component with custom "from" and "to" arguments').help().parse();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/x-codemod",
3
- "version": "6.0.3",
3
+ "version": "6.0.4",
4
4
  "bin": "./codemod.js",
5
5
  "private": false,
6
6
  "author": "MUI Team",
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = removeObjectProperty;
7
+ const getAttributeName = attribute => attribute.name.type === 'JSXIdentifier' ? attribute.name.name : attribute.name.name.name;
7
8
  function removeObjectProperty({
8
9
  root,
9
10
  propName,
@@ -12,9 +13,16 @@ function removeObjectProperty({
12
13
  j
13
14
  }) {
14
15
  root.find(j.JSXElement).filter(path => {
15
- return componentsNames.includes(path.value.openingElement.name.name);
16
+ switch (path.value.openingElement.name.type) {
17
+ case 'JSXNamespacedName':
18
+ return componentsNames.includes(path.value.openingElement.name.name.name);
19
+ case 'JSXIdentifier':
20
+ return componentsNames.includes(path.value.openingElement.name.name);
21
+ default:
22
+ return false;
23
+ }
16
24
  }).forEach(element => {
17
- const targetAttribute = element.value.openingElement.attributes.find(attribute => attribute.name.name === propName);
25
+ const targetAttribute = element.value.openingElement.attributes?.filter(attribute => attribute.type === 'JSXAttribute')?.find(attribute => getAttributeName(attribute) === propName);
18
26
  if (!targetAttribute) {
19
27
  return;
20
28
  }