@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.
- package/dist/autoDetectVKUIVersion.js +16 -24
- package/dist/cli.js +97 -160
- package/dist/codemod-helpers.js +41 -43
- package/dist/getAvailableCodemods.js +13 -14
- package/dist/helpers/logger.js +17 -17
- package/dist/index.js +76 -147
- package/dist/report.js +4 -4
- package/dist/testHelpers/testHelper.js +17 -88
- package/dist/transforms/v6/accordion.js +10 -10
- package/dist/transforms/v6/action-sheet-item.js +5 -5
- package/dist/transforms/v6/action-sheet.js +15 -15
- package/dist/transforms/v6/alert.js +14 -14
- package/dist/transforms/v6/appearance-provider.js +8 -10
- package/dist/transforms/v6/banner.js +10 -10
- package/dist/transforms/v6/calendar-range.js +6 -6
- package/dist/transforms/v6/calendar.js +6 -6
- package/dist/transforms/v6/card-scroll.js +5 -5
- package/dist/transforms/v6/chip.js +6 -6
- package/dist/transforms/v6/chips-input.js +6 -6
- package/dist/transforms/v6/config-provider.js +20 -20
- package/dist/transforms/v6/content-card.js +7 -7
- package/dist/transforms/v6/custom-scroll-view.js +11 -13
- package/dist/transforms/v6/date-input.js +6 -6
- package/dist/transforms/v6/date-range-input.js +6 -6
- package/dist/transforms/v6/fixed-layout.js +11 -11
- package/dist/transforms/v6/forbid-imports.js +8 -8
- package/dist/transforms/v6/form-item.js +9 -9
- package/dist/transforms/v6/form-layout.js +10 -10
- package/dist/transforms/v6/gallery.js +5 -5
- package/dist/transforms/v6/gradient-prop-change.js +12 -12
- package/dist/transforms/v6/horizontal-cell-show-more.js +7 -11
- package/dist/transforms/v6/image-base.js +7 -7
- package/dist/transforms/v6/modal-card.js +16 -18
- package/dist/transforms/v6/modal-page-header.js +11 -11
- package/dist/transforms/v6/pagination.js +12 -12
- package/dist/transforms/v6/panel-header-content.js +10 -10
- package/dist/transforms/v6/panel-header.js +11 -11
- package/dist/transforms/v6/placeholder.js +5 -5
- package/dist/transforms/v6/popout-wrapper.js +9 -9
- package/dist/transforms/v6/popover.js +45 -54
- package/dist/transforms/v6/popper.js +35 -44
- package/dist/transforms/v6/range-slider.js +14 -25
- package/dist/transforms/v6/rich-tooltip.js +10 -10
- package/dist/transforms/v6/search.js +6 -6
- package/dist/transforms/v6/select.js +7 -7
- package/dist/transforms/v6/simple-cell.js +13 -15
- package/dist/transforms/v6/split-col.js +9 -9
- package/dist/transforms/v6/tabbar.js +5 -5
- package/dist/transforms/v6/tappable.js +13 -15
- package/dist/transforms/v6/text-tooltip.js +47 -58
- package/dist/transforms/v6/tooltip-container.js +14 -14
- package/dist/transforms/v6/tooltip.js +63 -72
- package/dist/transforms/v6/typography.js +19 -21
- package/dist/transforms/v6/users-stack.js +13 -13
- package/dist/transforms/v6/visually-hidden-input.js +13 -24
- package/dist/transforms/v7/action-sheet.js +5 -5
- package/dist/transforms/v7/alert.js +5 -5
- package/dist/transforms/v7/appearance-provider.js +12 -12
- package/dist/transforms/v7/appearance.js +16 -16
- package/dist/transforms/v7/banner.js +13 -14
- package/dist/transforms/v7/calendar.js +5 -5
- package/dist/transforms/v7/card-grid.js +5 -5
- package/dist/transforms/v7/card-scroll.js +17 -18
- package/dist/transforms/v7/cell-button.js +13 -13
- package/dist/transforms/v7/cell.js +5 -5
- package/dist/transforms/v7/chips-select.js +8 -8
- package/dist/transforms/v7/common/moveFromChildrenToLabel.js +19 -21
- package/dist/transforms/v7/common/remapSizePropValue.js +14 -16
- package/dist/transforms/v7/common/removeChildrenFromComponent.js +6 -6
- package/dist/transforms/v7/common/swapGapPropElements.js +7 -7
- package/dist/transforms/v7/config-provider.js +32 -36
- package/dist/transforms/v7/content-card.js +5 -5
- package/dist/transforms/v7/counter.js +12 -12
- package/dist/transforms/v7/custom-scroll-view.js +8 -8
- package/dist/transforms/v7/custom-select.js +8 -8
- package/dist/transforms/v7/date-picker.js +8 -8
- package/dist/transforms/v7/flex.js +6 -6
- package/dist/transforms/v7/form-item.js +29 -35
- package/dist/transforms/v7/form-status.js +5 -5
- package/dist/transforms/v7/header.js +21 -21
- package/dist/transforms/v7/horizontal-cell-show-more.js +16 -19
- package/dist/transforms/v7/horizontal-cell.js +5 -5
- package/dist/transforms/v7/horizontal-scroll.js +12 -12
- package/dist/transforms/v7/image-overlay.js +30 -32
- package/dist/transforms/v7/mini-info-cell.js +5 -5
- package/dist/transforms/v7/modal-card.js +7 -7
- package/dist/transforms/v7/onboarding-tooltip.js +5 -5
- package/dist/transforms/v7/panel-header-back.js +6 -6
- package/dist/transforms/v7/panel-header-close.js +6 -6
- package/dist/transforms/v7/panel-header-content.js +5 -5
- package/dist/transforms/v7/panel-header-edit.js +6 -6
- package/dist/transforms/v7/panel-header-submit.js +6 -6
- package/dist/transforms/v7/panel-spinner.js +10 -10
- package/dist/transforms/v7/placeholder.js +5 -5
- package/dist/transforms/v7/rich-cell.js +5 -5
- package/dist/transforms/v7/screen-spinner.js +7 -7
- package/dist/transforms/v7/scroll-arrow.js +20 -23
- package/dist/transforms/v7/select.js +8 -8
- package/dist/transforms/v7/separator.js +6 -6
- package/dist/transforms/v7/simple-cell.js +5 -5
- package/dist/transforms/v7/simple-grid.js +6 -6
- package/dist/transforms/v7/spacing.js +9 -9
- package/dist/transforms/v7/spinner.js +9 -9
- package/dist/transforms/v7/subnavigation-bar.js +10 -10
- package/dist/transforms/v7/subnavigation-button.js +5 -5
- package/dist/transforms/v7/tabbar-item.js +5 -5
- package/dist/transforms/v7/tooltip.js +5 -5
- package/dist/transforms/v7/typography.js +16 -17
- package/dist/transforms/v7/users-stack.js +13 -13
- package/dist/transforms/v8/action-sheet.js +6 -6
- package/dist/transforms/v8/alert.js +5 -5
- package/dist/transforms/v8/checkbox.js +12 -12
- package/dist/transforms/v8/chips-input.js +7 -7
- package/dist/transforms/v8/chips-select.js +7 -7
- package/dist/transforms/v8/common/moveAllPropsIntoSlotProp.js +6 -16
- package/dist/transforms/v8/common/moveInputPropsIntoSlotProps.js +8 -8
- package/dist/transforms/v8/common/movePropIntoSlotProps.js +44 -63
- package/dist/transforms/v8/custom-select.js +7 -7
- package/dist/transforms/v8/file.js +7 -7
- package/dist/transforms/v8/input.js +8 -7
- package/dist/transforms/v8/native-select.js +7 -7
- package/dist/transforms/v8/popout-wrapper.js +12 -12
- package/dist/transforms/v8/radio.js +12 -12
- package/dist/transforms/v8/rich-cell.js +11 -11
- package/dist/transforms/v8/search.js +8 -7
- package/dist/transforms/v8/select.js +7 -7
- package/dist/transforms/v8/snackbar.js +6 -6
- package/dist/transforms/v8/split-layout.js +7 -7
- package/dist/transforms/v8/switch.js +7 -7
- package/dist/transforms/v8/text-area.js +7 -7
- package/dist/transforms/v8/write-bar.js +7 -7
- 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
|
-
|
|
5
|
+
const codemod_helpers_1 = require("../../codemod-helpers");
|
|
6
6
|
exports.parser = 'tsx';
|
|
7
|
-
|
|
7
|
+
const PROPS_TO_REMOVE = ['autoHideScrollbar', 'autoHideScrollbarDelay'];
|
|
8
8
|
function transformer(file, api, options) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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,
|
|
17
|
-
return
|
|
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
|
-
|
|
6
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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(
|
|
23
|
-
(0, report_1.report)(api,
|
|
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
|
-
|
|
6
|
-
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
5
|
+
const codemod_helpers_1 = require("../../codemod-helpers");
|
|
6
6
|
exports.parser = 'tsx';
|
|
7
7
|
function transformer(file, api, options) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
element.openingElement.attributes =
|
|
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
|
-
|
|
22
|
+
multilineValue = true;
|
|
25
23
|
}
|
|
26
|
-
else if (
|
|
27
|
-
|
|
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
|
|
31
|
+
return multilineValue;
|
|
34
32
|
}
|
|
35
33
|
return undefined;
|
|
36
34
|
}
|
|
37
35
|
function findTopLabelRecursive(element) {
|
|
38
|
-
|
|
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 (
|
|
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(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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 &&
|
|
68
|
-
if (
|
|
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
|
|
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
|
|
87
|
-
var _a, _b;
|
|
82
|
+
formItemAttributes?.forEach((attr) => {
|
|
88
83
|
if (attr.type === 'JSXAttribute' && attr.name.name === 'top') {
|
|
89
|
-
if (
|
|
84
|
+
if (attr.value?.type === 'JSXElement') {
|
|
90
85
|
topLabelMultiline = findTopLabelRecursive(attr.value);
|
|
91
86
|
}
|
|
92
|
-
else if (
|
|
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 (
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
5
|
+
const codemod_helpers_1 = require("../../codemod-helpers");
|
|
6
6
|
exports.parser = 'tsx';
|
|
7
7
|
function transformer(file, api, options) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
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
|
|
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(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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,
|
|
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
|
-
|
|
36
|
+
const modeValue = (0, codemod_helpers_1.getStringValueFromAttribute)(modeAttr);
|
|
37
37
|
if (!modeValue) {
|
|
38
|
-
(0, report_1.report)(api,
|
|
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
|
-
|
|
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
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
|
63
|
-
api
|
|
64
|
-
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
|
-
|
|
6
|
-
|
|
5
|
+
const codemod_helpers_1 = require("../../codemod-helpers");
|
|
6
|
+
const report_1 = require("../../report");
|
|
7
7
|
exports.parser = 'tsx';
|
|
8
|
-
|
|
8
|
+
const componentName = 'HorizontalCellShowMore';
|
|
9
9
|
function compensateLastCellIndentManipulator(api, attribute) {
|
|
10
|
-
|
|
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,
|
|
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
|
-
|
|
24
|
-
|
|
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,
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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(
|
|
45
|
-
.find(j.JSXAttribute,
|
|
46
|
-
|
|
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
|
-
|
|
5
|
+
const codemod_helpers_1 = require("../../codemod-helpers");
|
|
6
6
|
exports.parser = 'tsx';
|
|
7
7
|
function transformer(file, api, options) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
6
|
-
|
|
5
|
+
const codemod_helpers_1 = require("../../codemod-helpers");
|
|
6
|
+
const report_1 = require("../../report");
|
|
7
7
|
exports.parser = 'tsx';
|
|
8
|
-
|
|
8
|
+
const componentName = 'HorizontalScroll';
|
|
9
9
|
function transformer(file, api, options) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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(
|
|
19
|
+
.filter((path) => path.value.name.type === 'JSXIdentifier' && path.value.name.name === localName)
|
|
20
20
|
.find(j.JSXAttribute)
|
|
21
|
-
.filter(
|
|
22
|
-
.forEach(
|
|
23
|
-
|
|
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,
|
|
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
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
22
|
-
return (
|
|
21
|
+
const findAttribute = (attributes, attributeName) => {
|
|
22
|
+
return (attributes?.find((attr) => {
|
|
23
23
|
return attr.type === 'JSXAttribute' && attr.name.name === attributeName;
|
|
24
|
-
})
|
|
24
|
+
}) || null);
|
|
25
25
|
};
|
|
26
|
-
|
|
27
|
-
(0, report_1.report)(api,
|
|
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
|
-
|
|
30
|
-
showReport(localName, "
|
|
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
|
-
|
|
33
|
-
|
|
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 (
|
|
41
|
-
|
|
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
|
-
|
|
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(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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,
|
|
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
|
-
|
|
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 (
|
|
104
|
-
|
|
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, "
|
|
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
|
-
|
|
5
|
+
const codemod_helpers_1 = require("../../codemod-helpers");
|
|
6
6
|
exports.parser = 'tsx';
|
|
7
7
|
function transformer(file, api, options) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
5
|
+
const codemod_helpers_1 = require("../../codemod-helpers");
|
|
6
6
|
exports.parser = 'tsx';
|
|
7
|
-
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
}
|