@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,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, 'CustomSelect', 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, 'CustomSelect', 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
  }
@@ -2,14 +2,14 @@
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, 'DatePicker', 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, 'DatePicker', alias);
13
13
  if (!localName) {
14
14
  return source.toSource();
15
15
  }
@@ -19,8 +19,8 @@ function transformer(file, api, options) {
19
19
  name: { name: localName },
20
20
  },
21
21
  })
22
- .forEach(function () {
23
- (0, report_1.report)(api, "Manual changes required for ".concat(localName, ". component DatePicker was removed in v7.0.0, please use Input, Select or DateInput component"));
22
+ .forEach(() => {
23
+ (0, report_1.report)(api, `Manual changes required for ${localName}. component DatePicker was removed in v7.0.0, please use Input, Select or DateInput component`);
24
24
  });
25
25
  return source.toSource();
26
26
  }
@@ -2,14 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parser = void 0;
4
4
  exports.default = transformer;
5
- var swapGapPropElements_1 = require("./common/swapGapPropElements");
6
- var codemod_helpers_1 = require("../../codemod-helpers");
5
+ const swapGapPropElements_1 = require("./common/swapGapPropElements");
6
+ const codemod_helpers_1 = require("../../codemod-helpers");
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, 'Flex', 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, 'Flex', alias);
13
13
  if (!localName) {
14
14
  return source.toSource();
15
15
  }
@@ -2,48 +2,45 @@
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, 'FormItem', 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, 'FormItem', alias);
12
12
  if (!localName) {
13
13
  return source.toSource();
14
14
  }
15
15
  function processTopLabel(element) {
16
- var _a, _b;
17
16
  if (element.openingElement.name.type === 'JSXMemberExpression' &&
18
- ((_a = element.openingElement.name.property) === null || _a === void 0 ? void 0 : _a.name) === 'TopLabel') {
19
- var multilineValue_1;
20
- element.openingElement.attributes = (_b = element.openingElement.attributes) === null || _b === void 0 ? void 0 : _b.filter(function (attr) {
21
- var _a;
17
+ element.openingElement.name.property?.name === 'TopLabel') {
18
+ let multilineValue;
19
+ element.openingElement.attributes = element.openingElement.attributes?.filter((attr) => {
22
20
  if (attr.type === 'JSXAttribute' && attr.name.name === 'multiline') {
23
21
  if (!attr.value) {
24
- multilineValue_1 = true;
22
+ multilineValue = true;
25
23
  }
26
- else if (((_a = attr.value) === null || _a === void 0 ? void 0 : _a.type) === 'JSXExpressionContainer') {
27
- multilineValue_1 = attr.value;
24
+ else if (attr.value?.type === 'JSXExpressionContainer') {
25
+ multilineValue = attr.value;
28
26
  }
29
27
  return false;
30
28
  }
31
29
  return true;
32
30
  });
33
- return multilineValue_1;
31
+ return multilineValue;
34
32
  }
35
33
  return undefined;
36
34
  }
37
35
  function findTopLabelRecursive(element) {
38
- var result = processTopLabel(element);
36
+ let result = processTopLabel(element);
39
37
  if (result !== undefined) {
40
38
  return result;
41
39
  }
42
40
  if (!element.children) {
43
41
  return undefined;
44
42
  }
45
- for (var _i = 0, _a = element.children; _i < _a.length; _i++) {
46
- var child = _a[_i];
43
+ for (const child of element.children) {
47
44
  if (child.type === 'JSXElement') {
48
45
  result = findTopLabelRecursive(child);
49
46
  if (result !== undefined) {
@@ -54,18 +51,17 @@ function transformer(file, api, options) {
54
51
  return undefined;
55
52
  }
56
53
  (0, codemod_helpers_1.renameProp)(j, source, localName, { topNode: 'top' });
57
- source.find(j.JSXElement, { openingElement: { name: { name: localName } } }).forEach(function (path) {
58
- var formItem = path.node;
59
- var topMultiline;
60
- var topLabelMultiline;
61
- var formItemAttributes = formItem.openingElement.attributes;
62
- var prettifyTopMultilineAttribute = function () {
63
- var _a;
54
+ source.find(j.JSXElement, { openingElement: { name: { name: localName } } }).forEach((path) => {
55
+ const formItem = path.node;
56
+ let topMultiline;
57
+ let topLabelMultiline;
58
+ const formItemAttributes = formItem.openingElement.attributes;
59
+ const prettifyTopMultilineAttribute = () => {
64
60
  // Избавляемся от лишнего:
65
61
  // если topMultiline={false} можно убрать аттрибут
66
62
  // если topMultiline={true} можно убрать {true}
67
- if (topMultiline && (formItemAttributes === null || formItemAttributes === void 0 ? void 0 : formItemAttributes.includes(topMultiline))) {
68
- if (((_a = topMultiline === null || topMultiline === void 0 ? void 0 : topMultiline.value) === null || _a === void 0 ? void 0 : _a.type) === 'JSXExpressionContainer' &&
63
+ if (topMultiline && formItemAttributes?.includes(topMultiline)) {
64
+ if (topMultiline?.value?.type === 'JSXExpressionContainer' &&
69
65
  topMultiline.value.expression.type === 'BooleanLiteral') {
70
66
  if (topMultiline.value.expression.value) {
71
67
  topMultiline.value = null;
@@ -77,19 +73,18 @@ function transformer(file, api, options) {
77
73
  }
78
74
  };
79
75
  // Проверяем существующий topMultiline проп
80
- formItemAttributes === null || formItemAttributes === void 0 ? void 0 : formItemAttributes.forEach(function (attr) {
76
+ formItemAttributes?.forEach((attr) => {
81
77
  if (attr.type === 'JSXAttribute' && attr.name.name === 'topMultiline') {
82
78
  topMultiline = attr;
83
79
  }
84
80
  });
85
81
  // Ищем FormItem.TopLabel в пропе top и topNode
86
- formItemAttributes === null || formItemAttributes === void 0 ? void 0 : formItemAttributes.forEach(function (attr) {
87
- var _a, _b;
82
+ formItemAttributes?.forEach((attr) => {
88
83
  if (attr.type === 'JSXAttribute' && attr.name.name === 'top') {
89
- if (((_a = attr.value) === null || _a === void 0 ? void 0 : _a.type) === 'JSXElement') {
84
+ if (attr.value?.type === 'JSXElement') {
90
85
  topLabelMultiline = findTopLabelRecursive(attr.value);
91
86
  }
92
- else if (((_b = attr.value) === null || _b === void 0 ? void 0 : _b.type) === 'JSXExpressionContainer' &&
87
+ else if (attr.value?.type === 'JSXExpressionContainer' &&
93
88
  attr.value.expression.type === 'JSXElement') {
94
89
  topLabelMultiline = findTopLabelRecursive(attr.value.expression);
95
90
  }
@@ -97,8 +92,7 @@ function transformer(file, api, options) {
97
92
  });
98
93
  // Ищем FormItem.TopLabel в children
99
94
  if (topLabelMultiline === undefined && formItem.children) {
100
- for (var _i = 0, _a = formItem.children; _i < _a.length; _i++) {
101
- var child = _a[_i];
95
+ for (const child of formItem.children) {
102
96
  if (child.type === 'JSXElement') {
103
97
  topLabelMultiline = findTopLabelRecursive(child);
104
98
  if (topLabelMultiline !== undefined) {
@@ -111,7 +105,7 @@ function transformer(file, api, options) {
111
105
  prettifyTopMultilineAttribute();
112
106
  return;
113
107
  }
114
- var newTopMultilineValue = topLabelMultiline === true ? null : topLabelMultiline;
108
+ const newTopMultilineValue = topLabelMultiline === true ? null : topLabelMultiline;
115
109
  // Обновляем или добавляем topMultiline проп
116
110
  if (topMultiline) {
117
111
  // Если у FormItem задан topMultiline -> переопределяем
@@ -120,7 +114,7 @@ function transformer(file, api, options) {
120
114
  else if (topLabelMultiline) {
121
115
  // Если у FormItem не задан topMultiline
122
116
  // добавляем его в аргументы
123
- formItemAttributes === null || formItemAttributes === void 0 ? void 0 : formItemAttributes.push(j.jsxAttribute(j.jsxIdentifier('topMultiline'), newTopMultilineValue));
117
+ formItemAttributes?.push(j.jsxAttribute(j.jsxIdentifier('topMultiline'), newTopMultilineValue));
124
118
  }
125
119
  prettifyTopMultilineAttribute();
126
120
  });
@@ -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, 'FormStatus', 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, 'FormStatus', alias);
12
12
  if (localName) {
13
13
  (0, codemod_helpers_1.renameProp)(j, source, localName, {
14
14
  header: 'title',
@@ -2,17 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parser = void 0;
4
4
  exports.default = transformer;
5
- var report_1 = require("../../report");
6
- var remapSizePropValue_1 = require("./common/remapSizePropValue");
7
- var codemod_helpers_1 = require("../../codemod-helpers");
5
+ const report_1 = require("../../report");
6
+ const remapSizePropValue_1 = require("./common/remapSizePropValue");
7
+ const codemod_helpers_1 = require("../../codemod-helpers");
8
8
  exports.parser = 'tsx';
9
9
  function removePropMode(j, api, source, localName) {
10
- var changeAttributeValue = function (attributes, attribute, attrName, newValue) {
10
+ const changeAttributeValue = (attributes, attribute, attrName, newValue) => {
11
11
  if (attribute) {
12
12
  attribute.value = j.stringLiteral(newValue);
13
13
  }
14
14
  else {
15
- attributes === null || attributes === void 0 ? void 0 : attributes.push(j.jsxAttribute(j.jsxIdentifier(attrName), j.stringLiteral(newValue)));
15
+ attributes?.push(j.jsxAttribute(j.jsxIdentifier(attrName), j.stringLiteral(newValue)));
16
16
  }
17
17
  };
18
18
  source
@@ -21,24 +21,24 @@ function removePropMode(j, api, source, localName) {
21
21
  name: localName,
22
22
  },
23
23
  })
24
- .forEach(function (path) {
25
- var attributes = path.node.attributes;
26
- var modeAttr = (attributes === null || attributes === void 0 ? void 0 : attributes.find(function (attr) { return attr.type === 'JSXAttribute' && attr.name.name === 'mode'; })) || undefined;
27
- var sizeAttr = (attributes === null || attributes === void 0 ? void 0 : attributes.find(function (attr) { return attr.type === 'JSXAttribute' && attr.name.name === 'size'; })) || undefined;
28
- var hasSpread = !!(attributes === null || attributes === void 0 ? void 0 : attributes.some(function (attr) { return attr.type === 'JSXSpreadAttribute'; }));
24
+ .forEach((path) => {
25
+ const attributes = path.node.attributes;
26
+ const modeAttr = attributes?.find((attr) => attr.type === 'JSXAttribute' && attr.name.name === 'mode') || undefined;
27
+ const sizeAttr = attributes?.find((attr) => attr.type === 'JSXAttribute' && attr.name.name === 'size') || undefined;
28
+ const hasSpread = !!attributes?.some((attr) => attr.type === 'JSXSpreadAttribute');
29
29
  if (!modeAttr) {
30
30
  if (hasSpread) {
31
- (0, report_1.report)(api, ": ".concat(localName, " has been changed. Manual changes required: remove mode attribute and replace it by size prop"));
31
+ (0, report_1.report)(api, `: ${localName} has been changed. Manual changes required: remove mode attribute and replace it by size prop`);
32
32
  }
33
33
  return;
34
34
  }
35
35
  (0, codemod_helpers_1.removeAttribute)(attributes, modeAttr);
36
- var modeValue = (0, codemod_helpers_1.getStringValueFromAttribute)(modeAttr);
36
+ const modeValue = (0, codemod_helpers_1.getStringValueFromAttribute)(modeAttr);
37
37
  if (!modeValue) {
38
- (0, report_1.report)(api, ": ".concat(localName, " has been changed. Manual changes required: remove mode attribute and replace it by size prop"));
38
+ (0, report_1.report)(api, `: ${localName} has been changed. Manual changes required: remove mode attribute and replace it by size prop`);
39
39
  return;
40
40
  }
41
- var sizeValue = (0, codemod_helpers_1.getStringValueFromAttribute)(sizeAttr);
41
+ const sizeValue = (0, codemod_helpers_1.getStringValueFromAttribute)(sizeAttr);
42
42
  if (modeValue === 'primary' && sizeValue === 'l') {
43
43
  changeAttributeValue(attributes, sizeAttr, 'size', 'xl');
44
44
  }
@@ -51,17 +51,17 @@ function removePropMode(j, api, source, localName) {
51
51
  });
52
52
  }
53
53
  function transformer(file, api, options) {
54
- var alias = options.alias;
55
- var j = api.jscodeshift;
56
- var source = j(file.source);
57
- var localName = (0, codemod_helpers_1.getImportInfo)(j, file, 'Header', alias).localName;
54
+ const { alias } = options;
55
+ const j = api.jscodeshift;
56
+ const source = j(file.source);
57
+ const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'Header', alias);
58
58
  if (!localName) {
59
59
  return source.toSource();
60
60
  }
61
61
  (0, remapSizePropValue_1.remapSizePropValue)({
62
- j: j,
63
- api: api,
64
- source: source,
62
+ j,
63
+ api,
64
+ source,
65
65
  componentName: localName,
66
66
  sizesMap: {
67
67
  large: 'l',
@@ -2,12 +2,12 @@
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 componentName = 'HorizontalCellShowMore';
8
+ const componentName = 'HorizontalCellShowMore';
9
9
  function compensateLastCellIndentManipulator(api, attribute) {
10
- var node = attribute.node;
10
+ const node = attribute.node;
11
11
  if (!node.value) {
12
12
  api.jscodeshift(attribute).remove();
13
13
  }
@@ -16,37 +16,34 @@ function compensateLastCellIndentManipulator(api, attribute) {
16
16
  api.jscodeshift(attribute).remove();
17
17
  }
18
18
  else {
19
- (0, report_1.report)(api, "Manual changes required for ".concat(componentName, "'s \"compensateLastCellIndent\" prop. You might not need it anymore."));
19
+ (0, report_1.report)(api, `Manual changes required for ${componentName}'s "compensateLastCellIndent" prop. You might not need it anymore.`);
20
20
  }
21
21
  }
22
22
  function sizeManipulator(api, attribute) {
23
- var _a;
24
- var node = attribute.node;
25
- if (((_a = node.value) === null || _a === void 0 ? void 0 : _a.type) === 'StringLiteral') {
23
+ const node = attribute.node;
24
+ if (node.value?.type === 'StringLiteral') {
26
25
  if (node.value.value !== 's') {
27
26
  node.value = api.jscodeshift.stringLiteral('m');
28
27
  }
29
28
  }
30
29
  else {
31
- (0, report_1.report)(api, "Manual changes required for ".concat(componentName, "'s \"size\" prop. Use \"s\" or \"m\" value only."));
30
+ (0, report_1.report)(api, `Manual changes required for ${componentName}'s "size" prop. Use "s" or "m" value only.`);
32
31
  }
33
32
  }
34
33
  function transformer(file, api, options) {
35
- var alias = options.alias;
36
- var j = api.jscodeshift;
37
- var source = j(file.source);
38
- var localName = (0, codemod_helpers_1.getImportInfo)(j, file, componentName, alias).localName;
34
+ const { alias } = options;
35
+ const j = api.jscodeshift;
36
+ const source = j(file.source);
37
+ const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, componentName, alias);
39
38
  if (!localName) {
40
39
  return source.toSource();
41
40
  }
42
41
  source
43
42
  .find(j.JSXOpeningElement)
44
- .filter(function (path) { return path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName; })
45
- .find(j.JSXAttribute, function (attribute) {
46
- return attribute.name.name === 'compensateLastCellIndent' || attribute.name.name === 'size';
47
- })
48
- .forEach(function (attribute) {
49
- var attributeName = attribute.node.name.name;
43
+ .filter((path) => path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName)
44
+ .find(j.JSXAttribute, (attribute) => attribute.name.name === 'compensateLastCellIndent' || attribute.name.name === 'size')
45
+ .forEach((attribute) => {
46
+ const attributeName = attribute.node.name.name;
50
47
  if (attributeName === 'compensateLastCellIndent') {
51
48
  compensateLastCellIndentManipulator(api, attribute);
52
49
  }
@@ -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, 'HorizontalCell', 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, 'HorizontalCell', alias);
12
12
  if (localName) {
13
13
  (0, codemod_helpers_1.renameProp)(j, source, localName, { header: 'title' });
14
14
  }
@@ -2,25 +2,25 @@
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 componentName = 'HorizontalScroll';
8
+ const componentName = 'HorizontalScroll';
9
9
  function transformer(file, api, options) {
10
- var alias = options.alias;
11
- var j = api.jscodeshift;
12
- var source = j(file.source);
13
- var localName = (0, codemod_helpers_1.getImportInfo)(j, file, componentName, alias).localName;
10
+ const { alias } = options;
11
+ const j = api.jscodeshift;
12
+ const source = j(file.source);
13
+ const { localName } = (0, codemod_helpers_1.getImportInfo)(j, file, componentName, alias);
14
14
  if (!localName) {
15
15
  return source.toSource();
16
16
  }
17
17
  source
18
18
  .find(j.JSXOpeningElement)
19
- .filter(function (path) { return path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName; })
19
+ .filter((path) => path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName)
20
20
  .find(j.JSXAttribute)
21
- .filter(function (attribute) { return attribute.node.name.name === 'inline'; })
22
- .forEach(function (attribute) {
23
- var node = attribute.node;
21
+ .filter((attribute) => attribute.node.name.name === 'inline')
22
+ .forEach((attribute) => {
23
+ const node = attribute.node;
24
24
  if (!node.value) {
25
25
  j(attribute).remove();
26
26
  }
@@ -30,7 +30,7 @@ function transformer(file, api, options) {
30
30
  j(attribute).remove();
31
31
  }
32
32
  else {
33
- (0, report_1.report)(api, "Manual changes required for ".concat(componentName, "'s \"inline\" prop."));
33
+ (0, report_1.report)(api, `Manual changes required for ${componentName}'s "inline" prop.`);
34
34
  }
35
35
  }
36
36
  });
@@ -5,40 +5,39 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.parser = void 0;
7
7
  exports.default = transformer;
8
- var chalk_1 = __importDefault(require("chalk"));
9
- var codemod_helpers_1 = require("../../codemod-helpers");
10
- var report_1 = require("../../report");
8
+ const chalk_1 = __importDefault(require("chalk"));
9
+ const codemod_helpers_1 = require("../../codemod-helpers");
10
+ const report_1 = require("../../report");
11
11
  exports.parser = 'tsx';
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 ImageLocalName = (0, codemod_helpers_1.getImportInfo)(j, file, 'Image', alias).localName;
17
- var ImageBaseLocalName = (0, codemod_helpers_1.getImportInfo)(j, file, 'ImageBase', alias).localName;
13
+ const { alias } = options;
14
+ const j = api.jscodeshift;
15
+ const source = j(file.source);
16
+ const { localName: ImageLocalName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'Image', alias);
17
+ const { localName: ImageBaseLocalName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'ImageBase', alias);
18
18
  if (!ImageLocalName && !ImageBaseLocalName) {
19
19
  return source.toSource();
20
20
  }
21
- var findAttribute = function (attributes, attributeName) {
22
- return ((attributes === null || attributes === void 0 ? void 0 : attributes.find(function (attr) {
21
+ const findAttribute = (attributes, attributeName) => {
22
+ return (attributes?.find((attr) => {
23
23
  return attr.type === 'JSXAttribute' && attr.name.name === attributeName;
24
- })) || null);
24
+ }) || null);
25
25
  };
26
- var showReport = function (localName, additionalMessage) {
27
- (0, report_1.report)(api, ": ".concat(chalk_1.default.white.bgBlue("".concat(localName, ".Overlay")), " has been changed. Manual changes required: ").concat(additionalMessage));
26
+ const showReport = (localName, additionalMessage) => {
27
+ (0, report_1.report)(api, `: ${chalk_1.default.white.bgBlue(`${localName}.Overlay`)} has been changed. Manual changes required: ${additionalMessage}`);
28
28
  };
29
- var showDisableInteractivePropReport = function (localName) {
30
- showReport(localName, "\"disableInteractive\" has been removed, please use \"onClick\" if you want to make ".concat(localName, ".Overlay interactive."));
29
+ const showDisableInteractivePropReport = (localName) => {
30
+ showReport(localName, `"disableInteractive" has been removed, please use "onClick" if you want to make ${localName}.Overlay interactive.`);
31
31
  };
32
- var calcDisableInteractiveValue = function (disableInteractiveAttribute) {
33
- var _a, _b;
34
- if (((_a = disableInteractiveAttribute.value) === null || _a === void 0 ? void 0 : _a.type) === 'BooleanLiteral') {
32
+ const calcDisableInteractiveValue = (disableInteractiveAttribute) => {
33
+ if (disableInteractiveAttribute.value?.type === 'BooleanLiteral') {
35
34
  return disableInteractiveAttribute.value.value;
36
35
  }
37
36
  else if (disableInteractiveAttribute.value === null) {
38
37
  return true;
39
38
  }
40
- else if (((_b = disableInteractiveAttribute.value) === null || _b === void 0 ? void 0 : _b.type) === 'JSXExpressionContainer') {
41
- var expression = disableInteractiveAttribute.value.expression;
39
+ else if (disableInteractiveAttribute.value?.type === 'JSXExpressionContainer') {
40
+ const expression = disableInteractiveAttribute.value.expression;
42
41
  if (expression.type === 'BooleanLiteral') {
43
42
  return expression.value;
44
43
  }
@@ -48,7 +47,7 @@ function transformer(file, api, options) {
48
47
  }
49
48
  return null;
50
49
  };
51
- var handleImageComponent = function (localName) {
50
+ const handleImageComponent = (localName) => {
52
51
  source
53
52
  .find(j.JSXElement, {
54
53
  openingElement: {
@@ -59,23 +58,22 @@ function transformer(file, api, options) {
59
58
  },
60
59
  },
61
60
  })
62
- .forEach(function (path) {
63
- var _a;
64
- var overlay = path.node;
65
- var overlayItemAttributes = overlay.openingElement.attributes;
66
- var onClickAttribute = findAttribute(overlayItemAttributes, 'onClick');
67
- var disableInteractiveAttribute = findAttribute(overlayItemAttributes, 'disableInteractive');
61
+ .forEach((path) => {
62
+ const overlay = path.node;
63
+ const overlayItemAttributes = overlay.openingElement.attributes;
64
+ const onClickAttribute = findAttribute(overlayItemAttributes, 'onClick');
65
+ const disableInteractiveAttribute = findAttribute(overlayItemAttributes, 'disableInteractive');
68
66
  // Кейс, когда disableInteractive не был задан, значит overlay interactive.
69
67
  // Сейчас у него обязательно должен быть onClick, чтобы не лоймать обратную совместимость
70
68
  if (!disableInteractiveAttribute) {
71
69
  // Проверяем наличие onClick, и если его нет, то пользователь должен добавить onClick
72
70
  if (!onClickAttribute) {
73
- showReport(localName, "If you want to make ".concat(localName, ".Overlay interactive, please add \"onClick\" prop."));
71
+ showReport(localName, `If you want to make ${localName}.Overlay interactive, please add "onClick" prop.`);
74
72
  }
75
73
  return;
76
74
  }
77
75
  // Рассчитываем значение disableInteractive в boolean
78
- var disableInteractiveValue = calcDisableInteractiveValue(disableInteractiveAttribute);
76
+ const disableInteractiveValue = calcDisableInteractiveValue(disableInteractiveAttribute);
79
77
  if (disableInteractiveValue === null) {
80
78
  // Если у disableInteractive используется сложное выражение,
81
79
  // то пользователь сам должен удалить этот проп, как ему нужно
@@ -100,8 +98,8 @@ function transformer(file, api, options) {
100
98
  // onClick=undefined: надо добавить колбэк
101
99
  // onClick=identifier: все хорошо, оставляем как есть
102
100
  // В остальных случаях надо, чтобы пользователь убедился, что onClick устанавливается корректно
103
- if (((_a = onClickAttribute.value) === null || _a === void 0 ? void 0 : _a.type) === 'JSXExpressionContainer') {
104
- var expression = onClickAttribute.value.expression;
101
+ if (onClickAttribute.value?.type === 'JSXExpressionContainer') {
102
+ const expression = onClickAttribute.value.expression;
105
103
  if (expression.type === 'Identifier') {
106
104
  if (expression.name === 'undefined') {
107
105
  showDisableInteractivePropReport(localName);
@@ -112,7 +110,7 @@ function transformer(file, api, options) {
112
110
  return;
113
111
  }
114
112
  }
115
- showReport(localName, "\"disableInteractive\" has been removed, please validate that \"onClick\" prop value not falsy.");
113
+ showReport(localName, `"disableInteractive" has been removed, please validate that "onClick" prop value not falsy.`);
116
114
  });
117
115
  };
118
116
  if (ImageLocalName) {
@@ -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, 'MiniInfoCell', 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, 'MiniInfoCell', alias);
12
12
  if (localName) {
13
13
  (0, codemod_helpers_1.renameProp)(j, source, localName, {
14
14
  expandable: 'chevron',
@@ -2,20 +2,20 @@
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 RENAME_MAP = {
7
+ const RENAME_MAP = {
8
8
  header: 'title',
9
9
  subheader: 'description',
10
10
  headerComponent: 'titleComponent',
11
11
  subheaderComponent: 'descriptionComponent',
12
12
  };
13
13
  function transformer(file, api, options) {
14
- var alias = options.alias;
15
- var j = api.jscodeshift;
16
- var source = j(file.source);
17
- var modalCardName = (0, codemod_helpers_1.getImportInfo)(j, file, 'ModalCard', alias).localName;
18
- var modalCardBaseName = (0, codemod_helpers_1.getImportInfo)(j, file, 'ModalCardBase', alias).localName;
14
+ const { alias } = options;
15
+ const j = api.jscodeshift;
16
+ const source = j(file.source);
17
+ const { localName: modalCardName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'ModalCard', alias);
18
+ const { localName: modalCardBaseName } = (0, codemod_helpers_1.getImportInfo)(j, file, 'ModalCardBase', alias);
19
19
  if (!modalCardName && !modalCardBaseName) {
20
20
  return source.toSource();
21
21
  }