@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,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, '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
|
-
|
|
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, 'CardScroll', alias);
|
|
13
13
|
if (!localName) {
|
|
14
14
|
return source.toSource();
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
|
|
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 (
|
|
22
|
-
|
|
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
|
-
|
|
31
|
-
attributes
|
|
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(
|
|
42
|
-
|
|
43
|
-
|
|
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
|
-
|
|
47
|
+
const attrValue = getValueFromAttribute(noSpacesAttr);
|
|
49
48
|
if (attrValue === null) {
|
|
50
|
-
(0, report_1.report)(api,
|
|
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
|
-
|
|
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, '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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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(
|
|
27
|
-
|
|
26
|
+
.forEach((path) => {
|
|
27
|
+
const component = path.node;
|
|
28
28
|
component.name.name = newAttributeName;
|
|
29
|
-
|
|
29
|
+
const value = (0, codemod_helpers_1.getStringValueFromAttribute)(component);
|
|
30
30
|
if (!value || !modeToAppearance[value]) {
|
|
31
|
-
(0, report_1.report)(api,
|
|
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
|
-
|
|
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, '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
|
-
|
|
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, '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,
|
|
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
|
}
|
|
@@ -1,31 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.moveFromChildrenToLabel = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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(
|
|
13
|
-
|
|
11
|
+
.filter((path) => {
|
|
12
|
+
const elementName = path.node.openingElement.name;
|
|
14
13
|
return elementName.type === 'JSXIdentifier' && elementName.name === localName;
|
|
15
14
|
})
|
|
16
|
-
.forEach(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
20
|
+
const childrenProp = openingElement.attributes?.find((attr) => attr.type === 'JSXAttribute' && attr.name.name === 'children');
|
|
23
21
|
// Получаем содержимое из обычных children
|
|
24
|
-
|
|
25
|
-
|
|
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 (
|
|
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
|
-
|
|
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,
|
|
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
|
-
|
|
55
|
+
openingElement.attributes?.push(j.jsxAttribute(j.jsxIdentifier('label'), labelValue));
|
|
58
56
|
if (needToAddHideLabelProps) {
|
|
59
57
|
// Добавляем проп hideLabelOnVKCom и hideLabelOnIOS, так как раньше children был скрыт визуально
|
|
60
58
|
// и после того как мы перенесли children в label, визуально ничего не должно измениться
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
5
|
-
|
|
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(
|
|
8
|
+
.filter((path) => path.value.name.type === 'JSXIdentifier' && path.value.name.name === componentName)
|
|
10
9
|
.find(j.JSXAttribute)
|
|
11
|
-
.filter(
|
|
12
|
-
|
|
10
|
+
.filter((attribute) => {
|
|
11
|
+
const attributeName = attribute.node.name.name;
|
|
13
12
|
return attributeName === 'size';
|
|
14
13
|
})
|
|
15
|
-
.forEach(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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 (
|
|
23
|
-
|
|
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 (
|
|
27
|
+
if (attribute.node.value?.type === 'StringLiteral') {
|
|
30
28
|
nodeToReplaceValue = attribute.node.value;
|
|
31
29
|
}
|
|
32
30
|
if (nodeToReplaceValue) {
|
|
33
|
-
|
|
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,
|
|
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
|
-
|
|
5
|
-
|
|
4
|
+
const removeChildrenFromComponent = (api, source, localName) => {
|
|
5
|
+
const j = api.jscodeshift;
|
|
6
6
|
source
|
|
7
7
|
.find(j.JSXElement)
|
|
8
|
-
.filter(
|
|
9
|
-
|
|
8
|
+
.filter((path) => {
|
|
9
|
+
const elementName = path.node.openingElement.name;
|
|
10
10
|
return elementName.type === 'JSXIdentifier' && elementName.name === localName;
|
|
11
11
|
})
|
|
12
|
-
.forEach(
|
|
13
|
-
|
|
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
|
-
|
|
4
|
+
const swapGapPropElements = (j, source, componentName) => {
|
|
5
5
|
source
|
|
6
6
|
.find(j.JSXOpeningElement)
|
|
7
|
-
.filter(
|
|
8
|
-
.forEach(
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
14
|
+
const expression = gapAttribute.value.expression;
|
|
15
15
|
if (expression.type === 'ArrayExpression' && expression.elements.length === 2) {
|
|
16
16
|
// Меняем местами элементы массива
|
|
17
|
-
|
|
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
|
-
|
|
6
|
-
|
|
5
|
+
const codemod_helpers_1 = require("../../codemod-helpers");
|
|
6
|
+
const report_1 = require("../../report");
|
|
7
7
|
exports.parser = 'tsx';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
42
|
-
(0, report_1.report)(api,
|
|
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
|
-
|
|
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
|
-
|
|
53
|
-
(0, report_1.report)(api,
|
|
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
|
-
|
|
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
|
-
|
|
64
|
-
(0, report_1.report)(api,
|
|
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(
|
|
75
|
-
|
|
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
|
-
|
|
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
|
-
|
|
91
|
-
(0, report_1.report)(api,
|
|
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(
|
|
103
|
-
|
|
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
|
-
|
|
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
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
|
|
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, '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
|
-
|
|
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, 'Counter', alias);
|
|
13
13
|
if (!localName) {
|
|
14
14
|
return source.toSource();
|
|
15
15
|
}
|
|
16
|
-
source.find(j.JSXOpeningElement, { name: { name: localName } }).forEach(
|
|
17
|
-
|
|
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
|
-
|
|
21
|
+
const modeProp = attributes.find((attr) => attr.type === 'JSXAttribute' && attr.name.name === 'mode');
|
|
22
22
|
if (!modeProp) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
const oldMode = (0, codemod_helpers_1.getStringValueFromAttribute)(modeProp);
|
|
26
26
|
if (!oldMode) {
|
|
27
|
-
(0, report_1.report)(api,
|
|
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
|
-
|
|
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
|
-
|
|
5
|
+
const codemod_helpers_1 = require("../../codemod-helpers");
|
|
6
6
|
exports.parser = 'tsx';
|
|
7
|
-
|
|
7
|
+
const PROPS_TO_REMOVE = ['windowResize', '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, '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,
|
|
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
|
(0, codemod_helpers_1.renameProp)(j, source, localName, { boxRef: 'getRootRef' });
|
|
20
20
|
return source.toSource();
|