@vkontakte/vkui-codemods 1.1.0-beta.2 → 1.1.0

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.
Files changed (132) hide show
  1. package/dist/autoDetectVKUIVersion.js +16 -24
  2. package/dist/cli.js +97 -160
  3. package/dist/codemod-helpers.js +41 -43
  4. package/dist/getAvailableCodemods.js +13 -14
  5. package/dist/helpers/logger.js +17 -17
  6. package/dist/index.js +76 -147
  7. package/dist/report.js +4 -4
  8. package/dist/testHelpers/testHelper.js +17 -88
  9. package/dist/transforms/v6/accordion.js +10 -10
  10. package/dist/transforms/v6/action-sheet-item.js +5 -5
  11. package/dist/transforms/v6/action-sheet.js +15 -15
  12. package/dist/transforms/v6/alert.js +14 -14
  13. package/dist/transforms/v6/appearance-provider.js +8 -10
  14. package/dist/transforms/v6/banner.js +10 -10
  15. package/dist/transforms/v6/calendar-range.js +6 -6
  16. package/dist/transforms/v6/calendar.js +6 -6
  17. package/dist/transforms/v6/card-scroll.js +5 -5
  18. package/dist/transforms/v6/chip.js +6 -6
  19. package/dist/transforms/v6/chips-input.js +6 -6
  20. package/dist/transforms/v6/config-provider.js +20 -20
  21. package/dist/transforms/v6/content-card.js +7 -7
  22. package/dist/transforms/v6/custom-scroll-view.js +11 -13
  23. package/dist/transforms/v6/date-input.js +6 -6
  24. package/dist/transforms/v6/date-range-input.js +6 -6
  25. package/dist/transforms/v6/fixed-layout.js +11 -11
  26. package/dist/transforms/v6/forbid-imports.js +8 -8
  27. package/dist/transforms/v6/form-item.js +9 -9
  28. package/dist/transforms/v6/form-layout.js +10 -10
  29. package/dist/transforms/v6/gallery.js +5 -5
  30. package/dist/transforms/v6/gradient-prop-change.js +12 -12
  31. package/dist/transforms/v6/horizontal-cell-show-more.js +7 -11
  32. package/dist/transforms/v6/image-base.js +7 -7
  33. package/dist/transforms/v6/modal-card.js +16 -18
  34. package/dist/transforms/v6/modal-page-header.js +11 -11
  35. package/dist/transforms/v6/pagination.js +12 -12
  36. package/dist/transforms/v6/panel-header-content.js +10 -10
  37. package/dist/transforms/v6/panel-header.js +11 -11
  38. package/dist/transforms/v6/placeholder.js +5 -5
  39. package/dist/transforms/v6/popout-wrapper.js +9 -9
  40. package/dist/transforms/v6/popover.js +45 -54
  41. package/dist/transforms/v6/popper.js +35 -44
  42. package/dist/transforms/v6/range-slider.js +14 -25
  43. package/dist/transforms/v6/rich-tooltip.js +10 -10
  44. package/dist/transforms/v6/search.js +6 -6
  45. package/dist/transforms/v6/select.js +7 -7
  46. package/dist/transforms/v6/simple-cell.js +13 -15
  47. package/dist/transforms/v6/split-col.js +9 -9
  48. package/dist/transforms/v6/tabbar.js +5 -5
  49. package/dist/transforms/v6/tappable.js +13 -15
  50. package/dist/transforms/v6/text-tooltip.js +47 -58
  51. package/dist/transforms/v6/tooltip-container.js +14 -14
  52. package/dist/transforms/v6/tooltip.js +63 -72
  53. package/dist/transforms/v6/typography.js +19 -21
  54. package/dist/transforms/v6/users-stack.js +13 -13
  55. package/dist/transforms/v6/visually-hidden-input.js +13 -24
  56. package/dist/transforms/v7/action-sheet.js +5 -5
  57. package/dist/transforms/v7/alert.js +5 -5
  58. package/dist/transforms/v7/appearance-provider.js +12 -12
  59. package/dist/transforms/v7/appearance.js +16 -16
  60. package/dist/transforms/v7/banner.js +13 -14
  61. package/dist/transforms/v7/calendar.js +5 -5
  62. package/dist/transforms/v7/card-grid.js +5 -5
  63. package/dist/transforms/v7/card-scroll.js +17 -18
  64. package/dist/transforms/v7/cell-button.js +13 -13
  65. package/dist/transforms/v7/cell.js +5 -5
  66. package/dist/transforms/v7/chips-select.js +8 -8
  67. package/dist/transforms/v7/common/moveFromChildrenToLabel.js +19 -21
  68. package/dist/transforms/v7/common/remapSizePropValue.js +14 -16
  69. package/dist/transforms/v7/common/removeChildrenFromComponent.js +6 -6
  70. package/dist/transforms/v7/common/swapGapPropElements.js +7 -7
  71. package/dist/transforms/v7/config-provider.js +32 -36
  72. package/dist/transforms/v7/content-card.js +5 -5
  73. package/dist/transforms/v7/counter.js +12 -12
  74. package/dist/transforms/v7/custom-scroll-view.js +8 -8
  75. package/dist/transforms/v7/custom-select.js +8 -8
  76. package/dist/transforms/v7/date-picker.js +8 -8
  77. package/dist/transforms/v7/flex.js +6 -6
  78. package/dist/transforms/v7/form-item.js +29 -35
  79. package/dist/transforms/v7/form-status.js +5 -5
  80. package/dist/transforms/v7/header.js +21 -21
  81. package/dist/transforms/v7/horizontal-cell-show-more.js +16 -19
  82. package/dist/transforms/v7/horizontal-cell.js +5 -5
  83. package/dist/transforms/v7/horizontal-scroll.js +12 -12
  84. package/dist/transforms/v7/image-overlay.js +30 -32
  85. package/dist/transforms/v7/mini-info-cell.js +5 -5
  86. package/dist/transforms/v7/modal-card.js +7 -7
  87. package/dist/transforms/v7/onboarding-tooltip.js +5 -5
  88. package/dist/transforms/v7/panel-header-back.js +6 -6
  89. package/dist/transforms/v7/panel-header-close.js +6 -6
  90. package/dist/transforms/v7/panel-header-content.js +5 -5
  91. package/dist/transforms/v7/panel-header-edit.js +6 -6
  92. package/dist/transforms/v7/panel-header-submit.js +6 -6
  93. package/dist/transforms/v7/panel-spinner.js +10 -10
  94. package/dist/transforms/v7/placeholder.js +5 -5
  95. package/dist/transforms/v7/rich-cell.js +5 -5
  96. package/dist/transforms/v7/screen-spinner.js +7 -7
  97. package/dist/transforms/v7/scroll-arrow.js +20 -23
  98. package/dist/transforms/v7/select.js +8 -8
  99. package/dist/transforms/v7/separator.js +6 -6
  100. package/dist/transforms/v7/simple-cell.js +5 -5
  101. package/dist/transforms/v7/simple-grid.js +6 -6
  102. package/dist/transforms/v7/spacing.js +9 -9
  103. package/dist/transforms/v7/spinner.js +9 -9
  104. package/dist/transforms/v7/subnavigation-bar.js +10 -10
  105. package/dist/transforms/v7/subnavigation-button.js +5 -5
  106. package/dist/transforms/v7/tabbar-item.js +5 -5
  107. package/dist/transforms/v7/tooltip.js +5 -5
  108. package/dist/transforms/v7/typography.js +16 -17
  109. package/dist/transforms/v7/users-stack.js +13 -13
  110. package/dist/transforms/v8/action-sheet.js +6 -6
  111. package/dist/transforms/v8/alert.js +5 -5
  112. package/dist/transforms/v8/checkbox.js +12 -12
  113. package/dist/transforms/v8/chips-input.js +7 -7
  114. package/dist/transforms/v8/chips-select.js +7 -7
  115. package/dist/transforms/v8/common/moveAllPropsIntoSlotProp.js +6 -16
  116. package/dist/transforms/v8/common/moveInputPropsIntoSlotProps.js +8 -8
  117. package/dist/transforms/v8/common/movePropIntoSlotProps.js +44 -63
  118. package/dist/transforms/v8/custom-select.js +7 -7
  119. package/dist/transforms/v8/file.js +7 -7
  120. package/dist/transforms/v8/input.js +8 -7
  121. package/dist/transforms/v8/native-select.js +7 -7
  122. package/dist/transforms/v8/popout-wrapper.js +12 -12
  123. package/dist/transforms/v8/radio.js +12 -12
  124. package/dist/transforms/v8/rich-cell.js +11 -11
  125. package/dist/transforms/v8/search.js +8 -7
  126. package/dist/transforms/v8/select.js +7 -7
  127. package/dist/transforms/v8/snackbar.js +6 -6
  128. package/dist/transforms/v8/split-layout.js +7 -7
  129. package/dist/transforms/v8/switch.js +7 -7
  130. package/dist/transforms/v8/text-area.js +7 -7
  131. package/dist/transforms/v8/write-bar.js +7 -7
  132. package/package.json +6 -5
@@ -2,13 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parser = void 0;
4
4
  exports.default = transformer;
5
- var codemod_helpers_1 = require("../../codemod-helpers");
5
+ const codemod_helpers_1 = require("../../codemod-helpers");
6
6
  exports.parser = 'tsx';
7
7
  function transformer(file, api, options) {
8
- var alias = options.alias;
9
- var j = api.jscodeshift;
10
- var source = j(file.source);
11
- var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'CardGrid', alias).localName;
8
+ const { alias } = options;
9
+ const j = api.jscodeshift;
10
+ const source = j(file.source);
11
+ const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'CardGrid', alias);
12
12
  if (localName) {
13
13
  (0, codemod_helpers_1.renameProp)(j, source, localName, { spaced: 'padding' });
14
14
  }
@@ -2,24 +2,23 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parser = void 0;
4
4
  exports.default = transformer;
5
- var codemod_helpers_1 = require("../../codemod-helpers");
6
- var report_1 = require("../../report");
5
+ const codemod_helpers_1 = require("../../codemod-helpers");
6
+ const report_1 = require("../../report");
7
7
  exports.parser = 'tsx';
8
8
  function transformer(file, api, options) {
9
- var alias = options.alias;
10
- var j = api.jscodeshift;
11
- var source = j(file.source);
12
- var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'CardScroll', alias).localName;
9
+ const { alias } = options;
10
+ const j = api.jscodeshift;
11
+ const source = j(file.source);
12
+ const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'CardScroll', alias);
13
13
  if (!localName) {
14
14
  return source.toSource();
15
15
  }
16
- var getValueFromAttribute = function (attribute) {
17
- var _a, _b;
18
- if (((_a = attribute.value) === null || _a === void 0 ? void 0 : _a.type) === 'BooleanLiteral') {
16
+ const getValueFromAttribute = (attribute) => {
17
+ if (attribute.value?.type === 'BooleanLiteral') {
19
18
  return attribute.value.value;
20
19
  }
21
- if (((_b = attribute.value) === null || _b === void 0 ? void 0 : _b.type) === 'JSXExpressionContainer') {
22
- var expression = attribute.value.expression;
20
+ if (attribute.value?.type === 'JSXExpressionContainer') {
21
+ const expression = attribute.value.expression;
23
22
  if (expression.type === 'BooleanLiteral') {
24
23
  return expression.value;
25
24
  }
@@ -27,8 +26,8 @@ function transformer(file, api, options) {
27
26
  }
28
27
  return true;
29
28
  };
30
- var addPropPadding = function (attributes) {
31
- attributes === null || attributes === void 0 ? void 0 : attributes.push(j.jsxAttribute(j.jsxIdentifier('padding')));
29
+ const addPropPadding = (attributes) => {
30
+ attributes?.push(j.jsxAttribute(j.jsxIdentifier('padding')));
32
31
  };
33
32
  source
34
33
  .find(j.JSXElement, {
@@ -38,16 +37,16 @@ function transformer(file, api, options) {
38
37
  },
39
38
  },
40
39
  })
41
- .forEach(function (path) {
42
- var attributes = path.node.openingElement.attributes;
43
- var noSpacesAttr = attributes === null || attributes === void 0 ? void 0 : attributes.find(function (attr) { return attr.type === 'JSXAttribute' && attr.name.name === 'noSpaces'; });
40
+ .forEach((path) => {
41
+ const attributes = path.node.openingElement.attributes;
42
+ const noSpacesAttr = attributes?.find((attr) => attr.type === 'JSXAttribute' && attr.name.name === 'noSpaces');
44
43
  if (!noSpacesAttr) {
45
44
  addPropPadding(attributes);
46
45
  return;
47
46
  }
48
- var attrValue = getValueFromAttribute(noSpacesAttr);
47
+ const attrValue = getValueFromAttribute(noSpacesAttr);
49
48
  if (attrValue === null) {
50
- (0, report_1.report)(api, "Manual changes required for ".concat(localName, "'s \"noSpaces\" prop. Need to change it to \"padding\" prop"));
49
+ (0, report_1.report)(api, `Manual changes required for ${localName}'s "noSpaces" prop. Need to change it to "padding" prop`);
51
50
  return;
52
51
  }
53
52
  (0, codemod_helpers_1.removeAttribute)(attributes, noSpacesAttr);
@@ -2,33 +2,33 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parser = void 0;
4
4
  exports.default = transformer;
5
- var codemod_helpers_1 = require("../../codemod-helpers");
6
- var report_1 = require("../../report");
5
+ const codemod_helpers_1 = require("../../codemod-helpers");
6
+ const report_1 = require("../../report");
7
7
  exports.parser = 'tsx';
8
8
  function transformer(file, api, options) {
9
- var alias = options.alias;
10
- var j = api.jscodeshift;
11
- var source = j(file.source);
12
- var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'CellButton', alias).localName;
9
+ const { alias } = options;
10
+ const j = api.jscodeshift;
11
+ const source = j(file.source);
12
+ const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'CellButton', alias);
13
13
  if (!localName) {
14
14
  return source.toSource();
15
15
  }
16
16
  (0, codemod_helpers_1.renameProp)(j, source, localName, { subhead: 'overTitle', expandable: 'chevron' });
17
- var attributeToReplace = 'mode';
18
- var newAttributeName = 'appearance';
19
- var modeToAppearance = {
17
+ const attributeToReplace = 'mode';
18
+ const newAttributeName = 'appearance';
19
+ const modeToAppearance = {
20
20
  primary: 'accent',
21
21
  danger: 'negative',
22
22
  };
23
23
  source
24
24
  .find(j.JSXElement, { openingElement: { name: { name: localName } } })
25
25
  .find(j.JSXAttribute, { name: { name: attributeToReplace } })
26
- .forEach(function (path) {
27
- var component = path.node;
26
+ .forEach((path) => {
27
+ const component = path.node;
28
28
  component.name.name = newAttributeName;
29
- var value = (0, codemod_helpers_1.getStringValueFromAttribute)(component);
29
+ const value = (0, codemod_helpers_1.getStringValueFromAttribute)(component);
30
30
  if (!value || !modeToAppearance[value]) {
31
- (0, report_1.report)(api, ": ".concat(localName, " has been changed. Manual changes required: need to change 'mode' prop to 'appearance'."));
31
+ (0, report_1.report)(api, `: ${localName} has been changed. Manual changes required: need to change 'mode' prop to 'appearance'.`);
32
32
  return;
33
33
  }
34
34
  component.value = j.stringLiteral(modeToAppearance[value]);
@@ -2,13 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parser = void 0;
4
4
  exports.default = transformer;
5
- var codemod_helpers_1 = require("../../codemod-helpers");
5
+ const codemod_helpers_1 = require("../../codemod-helpers");
6
6
  exports.parser = 'tsx';
7
7
  function transformer(file, api, options) {
8
- var alias = options.alias;
9
- var j = api.jscodeshift;
10
- var source = j(file.source);
11
- var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'Cell', alias).localName;
8
+ const { alias } = options;
9
+ const j = api.jscodeshift;
10
+ const source = j(file.source);
11
+ const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'Cell', alias);
12
12
  if (localName) {
13
13
  (0, codemod_helpers_1.renameProp)(j, source, localName, {
14
14
  subhead: 'overTitle',
@@ -2,19 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parser = void 0;
4
4
  exports.default = transformer;
5
- var codemod_helpers_1 = require("../../codemod-helpers");
5
+ const codemod_helpers_1 = require("../../codemod-helpers");
6
6
  exports.parser = 'tsx';
7
- var PROPS_TO_REMOVE = ['autoHideScrollbar', 'autoHideScrollbarDelay'];
7
+ const PROPS_TO_REMOVE = ['autoHideScrollbar', 'autoHideScrollbarDelay'];
8
8
  function transformer(file, api, options) {
9
- var alias = options.alias;
10
- var j = api.jscodeshift;
11
- var source = j(file.source);
12
- var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'ChipsSelect', alias).localName;
9
+ const { alias } = options;
10
+ const j = api.jscodeshift;
11
+ const source = j(file.source);
12
+ const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'ChipsSelect', alias);
13
13
  if (!localName) {
14
14
  return source.toSource();
15
15
  }
16
- (0, codemod_helpers_1.removeProps)(j, api, source, localName, PROPS_TO_REMOVE, function () {
17
- return "need to remove props ".concat(PROPS_TO_REMOVE.join(', '));
16
+ (0, codemod_helpers_1.removeProps)(j, api, source, localName, PROPS_TO_REMOVE, () => {
17
+ return `need to remove props ${PROPS_TO_REMOVE.join(', ')}`;
18
18
  });
19
19
  return source.toSource();
20
20
  }
@@ -1,31 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.moveFromChildrenToLabel = void 0;
4
- var codemod_helpers_1 = require("../../../codemod-helpers");
5
- var report_1 = require("../../../report");
6
- var moveFromChildrenToLabel = function (api, source, localName, needToAddHideLabelProps) {
7
- if (needToAddHideLabelProps === void 0) { needToAddHideLabelProps = false; }
8
- var j = api.jscodeshift;
4
+ const codemod_helpers_1 = require("../../../codemod-helpers");
5
+ const report_1 = require("../../../report");
6
+ const moveFromChildrenToLabel = (api, source, localName, needToAddHideLabelProps = false) => {
7
+ const j = api.jscodeshift;
9
8
  // Находим все JSX элементы с указанным именем
10
9
  source
11
10
  .find(j.JSXElement)
12
- .filter(function (path) {
13
- var elementName = path.node.openingElement.name;
11
+ .filter((path) => {
12
+ const elementName = path.node.openingElement.name;
14
13
  return elementName.type === 'JSXIdentifier' && elementName.name === localName;
15
14
  })
16
- .forEach(function (path) {
17
- var _a, _b, _c, _d, _e, _f, _g;
18
- var element = path.node;
19
- var openingElement = element.openingElement;
20
- var existingLabelProp = (_a = openingElement.attributes) === null || _a === void 0 ? void 0 : _a.find(function (attr) { return attr.type === 'JSXAttribute' && attr.name.name === 'label'; });
15
+ .forEach((path) => {
16
+ const element = path.node;
17
+ const openingElement = element.openingElement;
18
+ const existingLabelProp = openingElement.attributes?.find((attr) => attr.type === 'JSXAttribute' && attr.name.name === 'label');
21
19
  // Получаем содержимое из props children
22
- var childrenProp = (_b = openingElement.attributes) === null || _b === void 0 ? void 0 : _b.find(function (attr) { return attr.type === 'JSXAttribute' && attr.name.name === 'children'; });
20
+ const childrenProp = openingElement.attributes?.find((attr) => attr.type === 'JSXAttribute' && attr.name.name === 'children');
23
21
  // Получаем содержимое из обычных children
24
- var regularChildren = (_c = element.children) === null || _c === void 0 ? void 0 : _c.filter(function (child) { return child.type !== 'JSXText' || child.value.trim() !== ''; });
25
- var labelValue;
22
+ const regularChildren = element.children?.filter((child) => child.type !== 'JSXText' || child.value.trim() !== '');
23
+ let labelValue;
26
24
  if (childrenProp && childrenProp.type === 'JSXAttribute') {
27
25
  // Если есть проп children
28
- if (((_d = childrenProp.value) === null || _d === void 0 ? void 0 : _d.type) === 'JSXElement') {
26
+ if (childrenProp.value?.type === 'JSXElement') {
29
27
  // Если children содержит JSX элемент, оборачиваем его в Fragment
30
28
  labelValue = j.jsxExpressionContainer(j.jsxFragment(j.jsxOpeningFragment(), j.jsxClosingFragment(), [childrenProp.value]));
31
29
  }
@@ -36,7 +34,7 @@ var moveFromChildrenToLabel = function (api, source, localName, needToAddHideLab
36
34
  }
37
35
  else if (regularChildren && regularChildren.length > 0) {
38
36
  if (regularChildren.length === 1 && regularChildren[0].type === 'JSXText') {
39
- var firstChild = regularChildren[0];
37
+ const firstChild = regularChildren[0];
40
38
  if (firstChild.type === 'JSXText') {
41
39
  labelValue = j.jsxExpressionContainer(j.stringLiteral(firstChild.value.trim()));
42
40
  }
@@ -48,18 +46,18 @@ var moveFromChildrenToLabel = function (api, source, localName, needToAddHideLab
48
46
  }
49
47
  if (labelValue) {
50
48
  if (existingLabelProp) {
51
- (0, report_1.report)(api, "Manual changes required for ".concat(localName, "'s \"label\" prop. Need to remove \"children\" prop. You can mode \"children\" value to \"label\" prop"));
49
+ (0, report_1.report)(api, `Manual changes required for ${localName}'s "label" prop. Need to remove "children" prop. You can mode "children" value to "label" prop`);
52
50
  return;
53
51
  }
54
52
  // Очищаем существующие children
55
53
  element.children = [];
56
54
  // Добавляем проп label
57
- (_e = openingElement.attributes) === null || _e === void 0 ? void 0 : _e.push(j.jsxAttribute(j.jsxIdentifier('label'), labelValue));
55
+ openingElement.attributes?.push(j.jsxAttribute(j.jsxIdentifier('label'), labelValue));
58
56
  if (needToAddHideLabelProps) {
59
57
  // Добавляем проп hideLabelOnVKCom и hideLabelOnIOS, так как раньше children был скрыт визуально
60
58
  // и после того как мы перенесли children в label, визуально ничего не должно измениться
61
- (_f = openingElement.attributes) === null || _f === void 0 ? void 0 : _f.push(j.jsxAttribute(j.jsxIdentifier('hideLabelOnVKCom')));
62
- (_g = openingElement.attributes) === null || _g === void 0 ? void 0 : _g.push(j.jsxAttribute(j.jsxIdentifier('hideLabelOnIOS')));
59
+ openingElement.attributes?.push(j.jsxAttribute(j.jsxIdentifier('hideLabelOnVKCom')));
60
+ openingElement.attributes?.push(j.jsxAttribute(j.jsxIdentifier('hideLabelOnIOS')));
63
61
  }
64
62
  }
65
63
  });
@@ -1,42 +1,40 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.remapSizePropValue = void 0;
4
- var report_1 = require("../../../report");
5
- var remapSizePropValue = function (_a) {
6
- var j = _a.j, source = _a.source, sizesMap = _a.sizesMap, componentName = _a.componentName, api = _a.api;
4
+ const report_1 = require("../../../report");
5
+ const remapSizePropValue = ({ j, source, sizesMap, componentName, api, }) => {
7
6
  source
8
7
  .find(j.JSXOpeningElement)
9
- .filter(function (path) { return path.value.name.type === 'JSXIdentifier' && path.value.name.name === componentName; })
8
+ .filter((path) => path.value.name.type === 'JSXIdentifier' && path.value.name.name === componentName)
10
9
  .find(j.JSXAttribute)
11
- .filter(function (attribute) {
12
- var attributeName = attribute.node.name.name;
10
+ .filter((attribute) => {
11
+ const attributeName = attribute.node.name.name;
13
12
  return attributeName === 'size';
14
13
  })
15
- .forEach(function (attribute) {
16
- var _a, _b, _c, _d;
17
- var nodeToReplaceValue;
18
- if (((_a = attribute.node.value) === null || _a === void 0 ? void 0 : _a.type) !== 'JSXExpressionContainer' &&
19
- ((_b = attribute.node.value) === null || _b === void 0 ? void 0 : _b.type) !== 'StringLiteral') {
14
+ .forEach((attribute) => {
15
+ let nodeToReplaceValue;
16
+ if (attribute.node.value?.type !== 'JSXExpressionContainer' &&
17
+ attribute.node.value?.type !== 'StringLiteral') {
20
18
  return;
21
19
  }
22
- if (((_c = attribute.node.value) === null || _c === void 0 ? void 0 : _c.type) === 'JSXExpressionContainer') {
23
- var expression = attribute.node.value.expression;
20
+ if (attribute.node.value?.type === 'JSXExpressionContainer') {
21
+ const expression = attribute.node.value.expression;
24
22
  if (expression.type !== 'StringLiteral') {
25
23
  return;
26
24
  }
27
25
  nodeToReplaceValue = expression;
28
26
  }
29
- if (((_d = attribute.node.value) === null || _d === void 0 ? void 0 : _d.type) === 'StringLiteral') {
27
+ if (attribute.node.value?.type === 'StringLiteral') {
30
28
  nodeToReplaceValue = attribute.node.value;
31
29
  }
32
30
  if (nodeToReplaceValue) {
33
- var newValue = sizesMap[nodeToReplaceValue.value];
31
+ const newValue = sizesMap[nodeToReplaceValue.value];
34
32
  if (newValue) {
35
33
  nodeToReplaceValue.value = newValue;
36
34
  }
37
35
  }
38
36
  else {
39
- (0, report_1.report)(api, "Manual changes required for ".concat(componentName, "'s \"size\" prop."));
37
+ (0, report_1.report)(api, `Manual changes required for ${componentName}'s "size" prop.`);
40
38
  }
41
39
  });
42
40
  };
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.removeChildrenFromComponent = void 0;
4
- var removeChildrenFromComponent = function (api, source, localName) {
5
- var j = api.jscodeshift;
4
+ const removeChildrenFromComponent = (api, source, localName) => {
5
+ const j = api.jscodeshift;
6
6
  source
7
7
  .find(j.JSXElement)
8
- .filter(function (path) {
9
- var elementName = path.node.openingElement.name;
8
+ .filter((path) => {
9
+ const elementName = path.node.openingElement.name;
10
10
  return elementName.type === 'JSXIdentifier' && elementName.name === localName;
11
11
  })
12
- .forEach(function (path) {
13
- var element = path.node;
12
+ .forEach((path) => {
13
+ const element = path.node;
14
14
  element.children = [];
15
15
  });
16
16
  };
@@ -1,20 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.swapGapPropElements = void 0;
4
- var swapGapPropElements = function (j, source, componentName) {
4
+ const swapGapPropElements = (j, source, componentName) => {
5
5
  source
6
6
  .find(j.JSXOpeningElement)
7
- .filter(function (path) { return path.value.name.type === 'JSXIdentifier' && path.value.name.name === componentName; })
8
- .forEach(function (path) {
9
- var attributes = path.node.attributes;
10
- var gapAttribute = attributes === null || attributes === void 0 ? void 0 : attributes.find(function (attr) { return attr.type === 'JSXAttribute' && attr.name.name === 'gap'; });
7
+ .filter((path) => path.value.name.type === 'JSXIdentifier' && path.value.name.name === componentName)
8
+ .forEach((path) => {
9
+ const attributes = path.node.attributes;
10
+ const gapAttribute = attributes?.find((attr) => attr.type === 'JSXAttribute' && attr.name.name === 'gap');
11
11
  if (gapAttribute &&
12
12
  gapAttribute.value &&
13
13
  gapAttribute.value.type === 'JSXExpressionContainer') {
14
- var expression = gapAttribute.value.expression;
14
+ const expression = gapAttribute.value.expression;
15
15
  if (expression.type === 'ArrayExpression' && expression.elements.length === 2) {
16
16
  // Меняем местами элементы массива
17
- var _a = expression.elements, first = _a[0], second = _a[1];
17
+ const [first, second] = expression.elements;
18
18
  if (first && second) {
19
19
  expression.elements = [second, first];
20
20
  }
@@ -2,21 +2,21 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parser = void 0;
4
4
  exports.default = transformer;
5
- var codemod_helpers_1 = require("../../codemod-helpers");
6
- var report_1 = require("../../report");
5
+ const codemod_helpers_1 = require("../../codemod-helpers");
6
+ const report_1 = require("../../report");
7
7
  exports.parser = 'tsx';
8
- var CONFIG_PROVIDER_NAME = 'ConfigProvider';
9
- var CONFIG_PROVIDER_PROPS_NAME = 'ConfigProviderProps';
10
- var CONFIG_PROVIDER_CONTEXT_NAME = 'ConfigProviderContext';
11
- var USE_CONFIG_PROVIDER_NAME = 'useConfigProvider';
8
+ const CONFIG_PROVIDER_NAME = 'ConfigProvider';
9
+ const CONFIG_PROVIDER_PROPS_NAME = 'ConfigProviderProps';
10
+ const CONFIG_PROVIDER_CONTEXT_NAME = 'ConfigProviderContext';
11
+ const USE_CONFIG_PROVIDER_NAME = 'useConfigProvider';
12
12
  function transformer(file, api, options) {
13
- var alias = options.alias;
14
- var j = api.jscodeshift;
15
- var source = j(file.source);
16
- var configProviderName = (0, codemod_helpers_1.getImportInfo)(j, file, CONFIG_PROVIDER_NAME, alias).localName;
17
- var configProviderPropsName = (0, codemod_helpers_1.getImportInfo)(j, file, CONFIG_PROVIDER_PROPS_NAME, alias).localName;
18
- var configProviderContextName = (0, codemod_helpers_1.getImportInfo)(j, file, CONFIG_PROVIDER_CONTEXT_NAME, alias).localName;
19
- var useConfigProviderName = (0, codemod_helpers_1.getImportInfo)(j, file, USE_CONFIG_PROVIDER_NAME, alias).localName;
13
+ const { alias } = options;
14
+ const j = api.jscodeshift;
15
+ const source = j(file.source);
16
+ const { localName: configProviderName } = (0, codemod_helpers_1.getImportInfo)(j, file, CONFIG_PROVIDER_NAME, alias);
17
+ const { localName: configProviderPropsName } = (0, codemod_helpers_1.getImportInfo)(j, file, CONFIG_PROVIDER_PROPS_NAME, alias);
18
+ const { localName: configProviderContextName } = (0, codemod_helpers_1.getImportInfo)(j, file, CONFIG_PROVIDER_CONTEXT_NAME, alias);
19
+ const { localName: useConfigProviderName } = (0, codemod_helpers_1.getImportInfo)(j, file, USE_CONFIG_PROVIDER_NAME, alias);
20
20
  if (!configProviderName &&
21
21
  !configProviderPropsName &&
22
22
  !configProviderContextName &&
@@ -38,10 +38,10 @@ function transformer(file, api, options) {
38
38
  return source.toSource();
39
39
  }
40
40
  function handleConfigProviderProps(j, api, source, localName) {
41
- var showReport = function () {
42
- (0, report_1.report)(api, ": \"".concat(localName, "\" has been changed. Manual changes required: perhaps need to rename \"appearance\" field to \"colorScheme\" in object."));
41
+ const showReport = () => {
42
+ (0, report_1.report)(api, `: "${localName}" has been changed. Manual changes required: perhaps need to rename "appearance" field to "colorScheme" in object.`);
43
43
  };
44
- var types = source.find(j.TSTypeReference, {
44
+ const types = source.find(j.TSTypeReference, {
45
45
  typeName: { type: 'Identifier', name: localName },
46
46
  });
47
47
  if (types.length) {
@@ -49,10 +49,10 @@ function handleConfigProviderProps(j, api, source, localName) {
49
49
  }
50
50
  }
51
51
  function handleUseConfigProvider(j, api, source, localName) {
52
- var showReport = function () {
53
- (0, report_1.report)(api, ": \"".concat(localName, "\" has been changed. Manual changes required: perhaps need to rename \"appearance\" field to \"colorScheme\" in result of hook."));
52
+ const showReport = () => {
53
+ (0, report_1.report)(api, `: "${localName}" has been changed. Manual changes required: perhaps need to rename "appearance" field to "colorScheme" in result of hook.`);
54
54
  };
55
- var identifiers = source.find(j.Identifier, {
55
+ const identifiers = source.find(j.Identifier, {
56
56
  name: localName,
57
57
  });
58
58
  if (identifiers.length) {
@@ -60,8 +60,8 @@ function handleUseConfigProvider(j, api, source, localName) {
60
60
  }
61
61
  }
62
62
  function handleConfigProvider(j, api, source, localName) {
63
- var showReport = function () {
64
- (0, report_1.report)(api, ": \"".concat(localName, "\" has been changed. Manual changes required: perhaps need to rename \"appearance\" field to \"colorScheme\"."));
63
+ const showReport = () => {
64
+ (0, report_1.report)(api, `: "${localName}" has been changed. Manual changes required: perhaps need to rename "appearance" field to "colorScheme".`);
65
65
  };
66
66
  source
67
67
  .find(j.JSXElement, {
@@ -71,14 +71,13 @@ function handleConfigProvider(j, api, source, localName) {
71
71
  },
72
72
  },
73
73
  })
74
- .forEach(function (path) {
75
- var _a, _b;
76
- var appearanceAttribute = (_a = path.node.openingElement.attributes) === null || _a === void 0 ? void 0 : _a.find(function (attr) { return attr.type === 'JSXAttribute' && attr.name && attr.name.name === 'appearance'; });
74
+ .forEach((path) => {
75
+ const appearanceAttribute = path.node.openingElement.attributes?.find((attr) => attr.type === 'JSXAttribute' && attr.name && attr.name.name === 'appearance');
77
76
  if (appearanceAttribute) {
78
77
  appearanceAttribute.name = j.jsxIdentifier('colorScheme');
79
78
  return;
80
79
  }
81
- var spreadAttribute = (_b = path.node.openingElement.attributes) === null || _b === void 0 ? void 0 : _b.find(function (attr) { return attr.type === 'JSXSpreadAttribute'; });
80
+ const spreadAttribute = path.node.openingElement.attributes?.find((attr) => attr.type === 'JSXSpreadAttribute');
82
81
  if (spreadAttribute) {
83
82
  showReport();
84
83
  return;
@@ -87,8 +86,8 @@ function handleConfigProvider(j, api, source, localName) {
87
86
  });
88
87
  }
89
88
  function handleConfigProviderContext(j, api, source, localName) {
90
- var showReport = function () {
91
- (0, report_1.report)(api, ": \"".concat(localName, "\" has been changed. Manual changes required: perhaps need to rename \"appearance\" field to \"colorScheme\"."));
89
+ const showReport = () => {
90
+ (0, report_1.report)(api, `: "${localName}" has been changed. Manual changes required: perhaps need to rename "appearance" field to "colorScheme".`);
92
91
  };
93
92
  source
94
93
  .find(j.JSXElement, {
@@ -99,14 +98,13 @@ function handleConfigProviderContext(j, api, source, localName) {
99
98
  },
100
99
  },
101
100
  })
102
- .forEach(function (path) {
103
- var _a, _b;
104
- var valueAttribute = (_a = path.node.openingElement.attributes) === null || _a === void 0 ? void 0 : _a.find(function (attr) { return attr.type === 'JSXAttribute' && attr.name && attr.name.name === 'value'; });
101
+ .forEach((path) => {
102
+ const valueAttribute = path.node.openingElement.attributes?.find((attr) => attr.type === 'JSXAttribute' && attr.name && attr.name.name === 'value');
105
103
  if (!valueAttribute) {
106
104
  showReport();
107
105
  return;
108
106
  }
109
- var valueExpression = ((_b = valueAttribute.value) === null || _b === void 0 ? void 0 : _b.type) === 'JSXExpressionContainer'
107
+ const valueExpression = valueAttribute.value?.type === 'JSXExpressionContainer'
110
108
  ? valueAttribute.value.expression
111
109
  : undefined;
112
110
  if (!valueExpression) {
@@ -118,11 +116,9 @@ function handleConfigProviderContext(j, api, source, localName) {
118
116
  return;
119
117
  }
120
118
  if (valueExpression.type === 'ObjectExpression') {
121
- var appearanceProp = valueExpression.properties.find(function (prop) {
122
- return prop.type === 'ObjectProperty' &&
123
- prop.key.type === 'Identifier' &&
124
- prop.key.name === 'appearance';
125
- });
119
+ const appearanceProp = valueExpression.properties.find((prop) => prop.type === 'ObjectProperty' &&
120
+ prop.key.type === 'Identifier' &&
121
+ prop.key.name === 'appearance');
126
122
  if (!appearanceProp) {
127
123
  showReport();
128
124
  return;
@@ -2,13 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parser = void 0;
4
4
  exports.default = transformer;
5
- var codemod_helpers_1 = require("../../codemod-helpers");
5
+ const codemod_helpers_1 = require("../../codemod-helpers");
6
6
  exports.parser = 'tsx';
7
7
  function transformer(file, api, options) {
8
- var alias = options.alias;
9
- var j = api.jscodeshift;
10
- var source = j(file.source);
11
- var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'ContentCard', alias).localName;
8
+ const { alias } = options;
9
+ const j = api.jscodeshift;
10
+ const source = j(file.source);
11
+ const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'ContentCard', alias);
12
12
  if (localName) {
13
13
  (0, codemod_helpers_1.renameProp)(j, source, localName, {
14
14
  subtitle: 'overTitle',
@@ -2,32 +2,32 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parser = void 0;
4
4
  exports.default = transformer;
5
- var codemod_helpers_1 = require("../../codemod-helpers");
6
- var report_1 = require("../../report");
5
+ const codemod_helpers_1 = require("../../codemod-helpers");
6
+ const report_1 = require("../../report");
7
7
  exports.parser = 'tsx';
8
8
  function transformer(file, api, options) {
9
- var alias = options.alias;
10
- var j = api.jscodeshift;
11
- var source = j(file.source);
12
- var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'Counter', alias).localName;
9
+ const { alias } = options;
10
+ const j = api.jscodeshift;
11
+ const source = j(file.source);
12
+ const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'Counter', alias);
13
13
  if (!localName) {
14
14
  return source.toSource();
15
15
  }
16
- source.find(j.JSXOpeningElement, { name: { name: localName } }).forEach(function (path) {
17
- var attributes = path.node.attributes;
16
+ source.find(j.JSXOpeningElement, { name: { name: localName } }).forEach((path) => {
17
+ const attributes = path.node.attributes;
18
18
  if (!attributes || !attributes.length) {
19
19
  return;
20
20
  }
21
- var modeProp = attributes.find(function (attr) { return attr.type === 'JSXAttribute' && attr.name.name === 'mode'; });
21
+ const modeProp = attributes.find((attr) => attr.type === 'JSXAttribute' && attr.name.name === 'mode');
22
22
  if (!modeProp) {
23
23
  return;
24
24
  }
25
- var oldMode = (0, codemod_helpers_1.getStringValueFromAttribute)(modeProp);
25
+ const oldMode = (0, codemod_helpers_1.getStringValueFromAttribute)(modeProp);
26
26
  if (!oldMode) {
27
- (0, report_1.report)(api, "Manual changes required for ".concat(localName, "'s \"mode\" prop. Need to replace it to another value and add prop appearance"));
27
+ (0, report_1.report)(api, `Manual changes required for ${localName}'s "mode" prop. Need to replace it to another value and add prop appearance`);
28
28
  return;
29
29
  }
30
- var newMode, newAppearance;
30
+ let newMode, newAppearance;
31
31
  switch (oldMode) {
32
32
  case 'inherit':
33
33
  newMode = 'inherit';
@@ -2,19 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parser = void 0;
4
4
  exports.default = transformer;
5
- var codemod_helpers_1 = require("../../codemod-helpers");
5
+ const codemod_helpers_1 = require("../../codemod-helpers");
6
6
  exports.parser = 'tsx';
7
- var PROPS_TO_REMOVE = ['windowResize', 'autoHideScrollbar', 'autoHideScrollbarDelay'];
7
+ const PROPS_TO_REMOVE = ['windowResize', 'autoHideScrollbar', 'autoHideScrollbarDelay'];
8
8
  function transformer(file, api, options) {
9
- var alias = options.alias;
10
- var j = api.jscodeshift;
11
- var source = j(file.source);
12
- var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'CustomScrollView', alias).localName;
9
+ const { alias } = options;
10
+ const j = api.jscodeshift;
11
+ const source = j(file.source);
12
+ const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'CustomScrollView', alias);
13
13
  if (!localName) {
14
14
  return source.toSource();
15
15
  }
16
- (0, codemod_helpers_1.removeProps)(j, api, source, localName, PROPS_TO_REMOVE, function () {
17
- return "need to remove props ".concat(PROPS_TO_REMOVE.join(', '));
16
+ (0, codemod_helpers_1.removeProps)(j, api, source, localName, PROPS_TO_REMOVE, () => {
17
+ return `need to remove props ${PROPS_TO_REMOVE.join(', ')}`;
18
18
  });
19
19
  (0, codemod_helpers_1.renameProp)(j, source, localName, { boxRef: 'getRootRef' });
20
20
  return source.toSource();