@atlaskit/codemod-cli 0.25.0 → 0.25.2

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 (45) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/main.js +1 -1
  3. package/dist/cjs/presets/migrate-to-new-buttons/codemods/next-migrate-link-button-to-link.js +111 -0
  4. package/dist/cjs/presets/migrate-to-new-buttons/codemods/next-migrate-to-new-button-variants.js +58 -15
  5. package/dist/cjs/presets/migrate-to-new-buttons/codemods/next-remove-unsafe-size.js +4 -3
  6. package/dist/cjs/presets/migrate-to-new-buttons/migrate-to-new-buttons.js +2 -1
  7. package/dist/cjs/presets/migrate-to-new-buttons/utils/constants.js +12 -5
  8. package/dist/cjs/presets/migrate-to-new-buttons/utils/find-attribute-with-value.js +17 -0
  9. package/dist/cjs/presets/migrate-to-new-buttons/utils/generate-link-element.js +40 -0
  10. package/dist/cjs/presets/migrate-to-new-buttons/utils/generate-new-button-element.js +19 -2
  11. package/dist/cjs/presets/migrate-to-new-buttons/utils/move-icon-value-from-link-button-to-link-children.js +30 -0
  12. package/dist/es2019/presets/migrate-to-new-buttons/codemods/next-migrate-link-button-to-link.js +95 -0
  13. package/dist/es2019/presets/migrate-to-new-buttons/codemods/next-migrate-to-new-button-variants.js +54 -16
  14. package/dist/es2019/presets/migrate-to-new-buttons/codemods/next-remove-unsafe-size.js +3 -2
  15. package/dist/es2019/presets/migrate-to-new-buttons/migrate-to-new-buttons.js +2 -1
  16. package/dist/es2019/presets/migrate-to-new-buttons/utils/constants.js +11 -4
  17. package/dist/es2019/presets/migrate-to-new-buttons/utils/find-attribute-with-value.js +11 -0
  18. package/dist/es2019/presets/migrate-to-new-buttons/utils/generate-link-element.js +36 -0
  19. package/dist/es2019/presets/migrate-to-new-buttons/utils/generate-new-button-element.js +18 -1
  20. package/dist/es2019/presets/migrate-to-new-buttons/utils/move-icon-value-from-link-button-to-link-children.js +24 -0
  21. package/dist/esm/main.js +1 -1
  22. package/dist/esm/presets/migrate-to-new-buttons/codemods/next-migrate-link-button-to-link.js +103 -0
  23. package/dist/esm/presets/migrate-to-new-buttons/codemods/next-migrate-to-new-button-variants.js +58 -16
  24. package/dist/esm/presets/migrate-to-new-buttons/codemods/next-remove-unsafe-size.js +3 -2
  25. package/dist/esm/presets/migrate-to-new-buttons/migrate-to-new-buttons.js +2 -1
  26. package/dist/esm/presets/migrate-to-new-buttons/utils/constants.js +11 -4
  27. package/dist/esm/presets/migrate-to-new-buttons/utils/find-attribute-with-value.js +11 -0
  28. package/dist/esm/presets/migrate-to-new-buttons/utils/generate-link-element.js +34 -0
  29. package/dist/esm/presets/migrate-to-new-buttons/utils/generate-new-button-element.js +18 -1
  30. package/dist/esm/presets/migrate-to-new-buttons/utils/move-icon-value-from-link-button-to-link-children.js +24 -0
  31. package/dist/types/presets/migrate-to-new-buttons/codemods/next-migrate-link-button-to-link.d.ts +3 -0
  32. package/dist/types/presets/migrate-to-new-buttons/codemods/next-remove-unsafe-size.d.ts +2 -1
  33. package/dist/types/presets/migrate-to-new-buttons/utils/constants.d.ts +10 -3
  34. package/dist/types/presets/migrate-to-new-buttons/utils/find-attribute-with-value.d.ts +2 -0
  35. package/dist/types/presets/migrate-to-new-buttons/utils/generate-link-element.d.ts +3 -0
  36. package/dist/types/presets/migrate-to-new-buttons/utils/generate-new-button-element.d.ts +2 -1
  37. package/dist/types/presets/migrate-to-new-buttons/utils/move-icon-value-from-link-button-to-link-children.d.ts +3 -0
  38. package/dist/types-ts4.5/presets/migrate-to-new-buttons/codemods/next-migrate-link-button-to-link.d.ts +3 -0
  39. package/dist/types-ts4.5/presets/migrate-to-new-buttons/codemods/next-remove-unsafe-size.d.ts +2 -1
  40. package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/constants.d.ts +10 -3
  41. package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/find-attribute-with-value.d.ts +2 -0
  42. package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/generate-link-element.d.ts +3 -0
  43. package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/generate-new-button-element.d.ts +2 -1
  44. package/dist/types-ts4.5/presets/migrate-to-new-buttons/utils/move-icon-value-from-link-button-to-link-children.d.ts +3 -0
  45. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/codemod-cli
2
2
 
3
+ ## 0.25.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#123131](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/123131)
8
+ [`862fb8cdd4b71`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/862fb8cdd4b71) -
9
+ Codemod includes new migration pathways for legacy button
10
+
11
+ ## 0.25.1
12
+
13
+ ### Patch Changes
14
+
15
+ - [#120049](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/120049)
16
+ [`77504ff274f72`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/77504ff274f72) -
17
+ DSP-19576: Assign names to anonymous default exports
18
+
3
19
  ## 0.25.0
4
20
 
5
21
  ### Minor Changes
package/dist/cjs/main.js CHANGED
@@ -305,7 +305,7 @@ function _main() {
305
305
  case 4:
306
306
  _yield$parseArgs = _context5.sent;
307
307
  packages = _yield$parseArgs.packages;
308
- _process$env$_PACKAGE = "0.25.0", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
308
+ _process$env$_PACKAGE = "0.25.2", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
309
309
  logger.log(_chalk.default.bgBlue(_chalk.default.black("\uD83D\uDCDA Atlassian-Frontend codemod library @ ".concat(_PACKAGE_VERSION_, " \uD83D\uDCDA"))));
310
310
  if (packages && packages.length > 0) {
311
311
  logger.log(_chalk.default.gray("Searching for codemods for newer versions of the following packages: ".concat(packages.map(function (pkg) {
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _utils = require("@hypermod/utils");
9
+ var _codemodUtils = require("@atlaskit/codemod-utils");
10
+ var _constants = require("../utils/constants");
11
+ var _findAttributeWithValue = require("../utils/find-attribute-with-value");
12
+ var _generateLinkElement = require("../utils/generate-link-element");
13
+ var _moveIconValueFromLinkButtonToLinkChildren = _interopRequireDefault(require("../utils/move-icon-value-from-link-button-to-link-children"));
14
+ /* eslint-disable @repo/internal/fs/filename-pattern-match */
15
+
16
+ function transformer(file, api) {
17
+ var j = api.jscodeshift;
18
+ var source = j(file.source);
19
+
20
+ // Find all new button imports
21
+ var newButtonImportDeclarations = (0, _utils.getImportDeclaration)(j, source, _constants.NEW_BUTTON_ENTRY_POINT);
22
+
23
+ // No imports for new button found, exit early
24
+ if (!newButtonImportDeclarations.length) {
25
+ return source.toSource();
26
+ }
27
+ var linkButtonSpecifier = '';
28
+ var linkButtonDeclaration;
29
+ newButtonImportDeclarations.forEach(function (newButtonImport) {
30
+ if (!newButtonImport.value.specifiers) {
31
+ return;
32
+ }
33
+ newButtonImport.value.specifiers.map(function (specifier) {
34
+ if (specifier.type === 'ImportSpecifier' && specifier.imported && specifier.imported.name === _constants.NEW_BUTTON_VARIANTS['link']) {
35
+ var _specifier$local;
36
+ linkButtonDeclaration = newButtonImport;
37
+ linkButtonSpecifier = ((_specifier$local = specifier.local) === null || _specifier$local === void 0 ? void 0 : _specifier$local.name) || '';
38
+ }
39
+ });
40
+ });
41
+ if (!linkButtonSpecifier) {
42
+ return source.toSource();
43
+ }
44
+ var hasLink = false;
45
+ var allLinkButtons = source.find(j.JSXElement).filter(function (path) {
46
+ return path.value.openingElement.name.type === 'JSXIdentifier' && path.value.openingElement.name.name === linkButtonSpecifier;
47
+ });
48
+ allLinkButtons.filter(function (path) {
49
+ return (0, _findAttributeWithValue.findJSXAttributeWithValue)(path.value.openingElement, 'appearance', 'link') || (0, _findAttributeWithValue.findJSXAttributeWithValue)(path.value.openingElement, 'appearance', 'subtle-link');
50
+ }).forEach(function (path) {
51
+ var hasSpacingNone = (0, _findAttributeWithValue.findJSXAttributeWithValue)(path.value.openingElement, 'spacing', 'none');
52
+ if (!hasSpacingNone) {
53
+ var oldAppearanceValue;
54
+ j(path).find(j.JSXAttribute).filter(function (path) {
55
+ var _path$node$value;
56
+ if (path.node.name.name === 'appearance' && ((_path$node$value = path.node.value) === null || _path$node$value === void 0 ? void 0 : _path$node$value.type) === 'StringLiteral' && (path.node.value.value === 'subtle-link' || path.node.value.value === 'link')) {
57
+ oldAppearanceValue = path.node.value.value;
58
+ return true;
59
+ }
60
+ return false;
61
+ }).replaceWith(j.jsxAttribute(j.jsxIdentifier('appearance'), j.stringLiteral('subtle')));
62
+ if (oldAppearanceValue) {
63
+ var _path$value$openingEl;
64
+ var attribute = (_path$value$openingEl = path.value.openingElement.attributes) === null || _path$value$openingEl === void 0 ? void 0 : _path$value$openingEl.find(function (node) {
65
+ return node.type === 'JSXAttribute' && node.name.name === 'appearance';
66
+ });
67
+ if (attribute) {
68
+ (0, _codemodUtils.addCommentBefore)(j, j(attribute), oldAppearanceValue === 'link' ? _constants.migrateButtonToSubtleLinkButton : _constants.migrateSubtleButtonToSubtleLinkButton, 'line');
69
+ }
70
+ }
71
+ }
72
+ if (hasSpacingNone) {
73
+ var attributes = path.node.openingElement.attributes;
74
+ (0, _generateLinkElement.modifyLinkAttributes)(path.node, j);
75
+ j(path).find(j.JSXAttribute).filter(function (attribute) {
76
+ var _attribute$node$value;
77
+ var isIconAttribute = attribute.node.name.name === 'iconBefore' || attribute.node.name.name === 'iconAfter';
78
+ if (((_attribute$node$value = attribute.node.value) === null || _attribute$node$value === void 0 ? void 0 : _attribute$node$value.type) === 'JSXExpressionContainer' && isIconAttribute) {
79
+ (0, _moveIconValueFromLinkButtonToLinkChildren.default)(j, path, attribute.node.value, attribute.node.name.name);
80
+ }
81
+ return isIconAttribute;
82
+ }).remove();
83
+ hasLink = true;
84
+ j(path).replaceWith(j.jsxElement.from({
85
+ openingElement: j.jsxOpeningElement(j.jsxIdentifier('Link'), attributes, false),
86
+ closingElement: j.jsxClosingElement(j.jsxIdentifier('Link')),
87
+ children: path.node.children
88
+ }));
89
+ }
90
+ });
91
+
92
+ // add link import and remove link button import if no link button is found
93
+ if (hasLink && linkButtonDeclaration) {
94
+ var linkImport = j.importDeclaration([j.importDefaultSpecifier(j.identifier('Link'))], j.stringLiteral('@atlaskit/link'));
95
+ j(linkButtonDeclaration).insertAfter(linkImport);
96
+ var remainingLinkButton = source.find(j.JSXElement).filter(function (path) {
97
+ return path.value.openingElement.name.type === 'JSXIdentifier' && path.value.openingElement.name.name === linkButtonSpecifier;
98
+ });
99
+ if (!remainingLinkButton.length) {
100
+ var _value$specifiers;
101
+ j(linkButtonDeclaration).find(j.ImportSpecifier).filter(function (path) {
102
+ return path.node.imported.name === _constants.NEW_BUTTON_VARIANTS['link'];
103
+ }).remove();
104
+ if (((_value$specifiers = linkButtonDeclaration.value.specifiers) === null || _value$specifiers === void 0 ? void 0 : _value$specifiers.length) === 0) {
105
+ j(linkButtonDeclaration).remove();
106
+ }
107
+ }
108
+ }
109
+ return source.toSource(_constants.PRINT_SETTINGS);
110
+ }
111
+ var _default = exports.default = transformer;
@@ -6,19 +6,23 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.default = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
- var _codemodUtils = require("@atlaskit/codemod-utils");
10
9
  var _utils = require("@hypermod/utils");
10
+ var _codemodUtils = require("@atlaskit/codemod-utils");
11
+ var _addCommentForCustomThemeButtons = require("../utils/add-comment-for-custom-theme-buttons");
12
+ var _addCommentForOverlayProp = require("../utils/add-comment-for-overlay-prop");
11
13
  var _constants = require("../utils/constants");
14
+ var _findAttributeWithValue = require("../utils/find-attribute-with-value");
15
+ var _generateLinkElement = require("../utils/generate-link-element");
16
+ var _generateNewButtonElement = require("../utils/generate-new-button-element");
12
17
  var _getDefaultImports = _interopRequireDefault(require("../utils/get-default-imports"));
13
18
  var _getSpecifierNames = _interopRequireDefault(require("../utils/get-specifier-names"));
14
- var _generateNewButtonElement = require("../utils/generate-new-button-element");
15
19
  var _hasUnsupportedProps = require("../utils/has-unsupported-props");
16
20
  var _ifVariantAlreadyImported = require("../utils/if-variant-already-imported");
17
- var _renameDefaultButtonToLegacyButton = require("../utils/rename-default-button-to-legacy-button");
18
- var _migrateFitContainerIconButton = require("../utils/migrate-fit-container-icon-button");
19
21
  var _importTypesFromNewEntryPoint = require("../utils/import-types-from-new-entry-point");
20
- var _addCommentForCustomThemeButtons = require("../utils/add-comment-for-custom-theme-buttons");
21
- var _addCommentForOverlayProp = require("../utils/add-comment-for-overlay-prop");
22
+ var _migrateFitContainerIconButton = require("../utils/migrate-fit-container-icon-button");
23
+ var _renameDefaultButtonToLegacyButton = require("../utils/rename-default-button-to-legacy-button");
24
+ /* eslint-disable @repo/internal/fs/filename-pattern-match */
25
+
22
26
  var transformer = function transformer(file, api) {
23
27
  var j = api.jscodeshift;
24
28
  var fileSource = j(file.source);
@@ -52,7 +56,8 @@ var transformer = function transformer(file, api) {
52
56
  defaultButton: (0, _ifVariantAlreadyImported.checkIfVariantAlreadyImported)(_constants.NEW_BUTTON_VARIANTS.default, _constants.NEW_BUTTON_ENTRY_POINT, fileSource, j, true),
53
57
  linkButton: (0, _ifVariantAlreadyImported.checkIfVariantAlreadyImported)(_constants.NEW_BUTTON_VARIANTS.link, _constants.NEW_BUTTON_ENTRY_POINT, fileSource, j),
54
58
  iconButton: (0, _ifVariantAlreadyImported.checkIfVariantAlreadyImported)(_constants.NEW_BUTTON_VARIANTS.icon, _constants.NEW_BUTTON_ENTRY_POINT, fileSource, j),
55
- linkIconButton: (0, _ifVariantAlreadyImported.checkIfVariantAlreadyImported)(_constants.NEW_BUTTON_VARIANTS.linkIcon, _constants.NEW_BUTTON_ENTRY_POINT, fileSource, j)
59
+ linkIconButton: (0, _ifVariantAlreadyImported.checkIfVariantAlreadyImported)(_constants.NEW_BUTTON_VARIANTS.linkIcon, _constants.NEW_BUTTON_ENTRY_POINT, fileSource, j),
60
+ link: (0, _ifVariantAlreadyImported.checkIfVariantAlreadyImported)('link', '@atlaskit/link', fileSource, j)
56
61
  };
57
62
  var oldButtonElements = fileSource.find(j.JSXElement).filter(function (path) {
58
63
  return path.value.openingElement.name.type === 'JSXIdentifier' && ((oldDefaultImportSpecifiers === null || oldDefaultImportSpecifiers === void 0 ? void 0 : oldDefaultImportSpecifiers.includes(path.value.openingElement.name.name)) || Object.values(_constants.OLD_BUTTON_VARIANTS).includes(path.value.openingElement.name.name));
@@ -73,18 +78,24 @@ var transformer = function transformer(file, api) {
73
78
  var hasHref = buttonAttributes.includes('href');
74
79
  var hasIcon = buttonAttributes.includes('iconBefore') || buttonAttributes.includes('iconAfter');
75
80
  var hasNoChildren = ((_element$value$childr = element.value.children) === null || _element$value$childr === void 0 ? void 0 : _element$value$childr.length) === 0;
81
+ var hasSpacing = attributes.find(function (attr) {
82
+ var _attr$value;
83
+ return attr.type === 'JSXAttribute' && attr.name.name === 'spacing' && ((_attr$value = attr.value) === null || _attr$value === void 0 ? void 0 : _attr$value.type) === 'StringLiteral' && attr.value.value !== 'none';
84
+ }) || !buttonAttributes.includes('spacing');
85
+ var hasSpacingNone = (0, _findAttributeWithValue.findJSXAttributeWithValue)(element.value.openingElement, 'spacing', 'none');
76
86
  var isFitContainerIconButton = hasIcon && hasNoChildren && buttonAttributes.includes('shouldFitContainer');
77
- var isLinkIconButton = hasHref && hasIcon && hasNoChildren && !isFitContainerIconButton;
78
- var isLinkButton = hasHref && !isLinkIconButton;
79
- var isIconButton = !hasHref && hasIcon && hasNoChildren && !isFitContainerIconButton;
80
- var isDefaultButton = !isLinkButton && !isLinkIconButton && !isIconButton && !isFitContainerIconButton;
81
- var isDefaultVariantWithAnIcon = !isLinkIconButton && !isIconButton && !isFitContainerIconButton && hasIcon;
82
- var isLoadingButton = element.value.openingElement.name.type === 'JSXIdentifier' && element.value.openingElement.name.name === loadingButtonDirectImportName;
83
87
  var linkAppearanceAttribute = attributes.find(function (node) {
84
88
  var _node$value, _node$name, _node$value2, _node$value3;
85
89
  return node.type === 'JSXAttribute' && ((_node$value = node.value) === null || _node$value === void 0 ? void 0 : _node$value.type) === 'StringLiteral' && (node === null || node === void 0 || (_node$name = node.name) === null || _node$name === void 0 ? void 0 : _node$name.name) === 'appearance' && ((node === null || node === void 0 || (_node$value2 = node.value) === null || _node$value2 === void 0 ? void 0 : _node$value2.value) === 'link' || (node === null || node === void 0 || (_node$value3 = node.value) === null || _node$value3 === void 0 ? void 0 : _node$value3.value) === 'subtle-link');
86
90
  });
87
- if (isDefaultVariantWithAnIcon) {
91
+ var isLinkIconButton = hasHref && hasIcon && hasNoChildren && !isFitContainerIconButton;
92
+ var isLinkButton = hasHref && !isLinkIconButton && !hasNoChildren && hasSpacing;
93
+ var isLink = hasHref && !isLinkIconButton && !hasNoChildren && hasSpacingNone && linkAppearanceAttribute;
94
+ var isIconButton = !hasHref && hasIcon && hasNoChildren && !isFitContainerIconButton && !isLink;
95
+ var isDefaultButton = !isLinkButton && !isLinkIconButton && !isIconButton && !isFitContainerIconButton && !isLink;
96
+ var isDefaultVariantWithAnIcon = !isLinkIconButton && !isIconButton && !isFitContainerIconButton && hasIcon && !isLink;
97
+ var isLoadingButton = element.value.openingElement.name.type === 'JSXIdentifier' && element.value.openingElement.name.name === loadingButtonDirectImportName;
98
+ if (isDefaultVariantWithAnIcon && !isLink) {
88
99
  (0, _generateNewButtonElement.handleIconAttributes)(element.value, j);
89
100
  }
90
101
  if (isFitContainerIconButton) {
@@ -102,8 +113,26 @@ var transformer = function transformer(file, api) {
102
113
  j(element).replaceWith((0, _generateNewButtonElement.generateNewElement)(_constants.NEW_BUTTON_VARIANTS.icon, element.value, j));
103
114
  }
104
115
  if (isLinkButton && !isLoadingButton) {
116
+ var _element$node$attribu;
105
117
  hasVariant.linkButton = true;
106
118
  j(element).replaceWith((0, _generateNewButtonElement.generateNewElement)(_constants.NEW_BUTTON_VARIANTS.link, element.value, j));
119
+ var attribute = (_element$node$attribu = element.node.attributes) === null || _element$node$attribu === void 0 ? void 0 : _element$node$attribu.find(function (node) {
120
+ return node.type === 'JSXAttribute' && node.name.name === 'appearance';
121
+ });
122
+ if (attribute) {
123
+ var _linkAppearanceAttrib;
124
+ if ((linkAppearanceAttribute === null || linkAppearanceAttribute === void 0 ? void 0 : linkAppearanceAttribute.type) === 'JSXAttribute' && ((_linkAppearanceAttrib = linkAppearanceAttribute.value) === null || _linkAppearanceAttrib === void 0 ? void 0 : _linkAppearanceAttrib.type) === 'StringLiteral') {
125
+ if (linkAppearanceAttribute.value.value === 'link') {
126
+ (0, _codemodUtils.addCommentBefore)(j, j(attribute), _constants.migrateButtonToSubtleLinkButton, 'line');
127
+ } else if (linkAppearanceAttribute.value.value === 'subtle-link') {
128
+ (0, _codemodUtils.addCommentBefore)(j, j(attribute), _constants.migrateSubtleButtonToSubtleLinkButton, 'line');
129
+ }
130
+ }
131
+ }
132
+ }
133
+ if (isLink && !isLoadingButton) {
134
+ hasVariant.link = true;
135
+ j(element).replaceWith((0, _generateLinkElement.generateLinkComponent)(element.node, j));
107
136
  }
108
137
  if (isDefaultButton && !isLoadingButton) {
109
138
  hasVariant.defaultButton = true;
@@ -153,7 +182,14 @@ var transformer = function transformer(file, api) {
153
182
  }), 'block');
154
183
  }
155
184
  } else if (!hasHref && linkAppearanceAttribute) {
156
- (0, _codemodUtils.addCommentBefore)(j, j(linkAppearanceAttribute), _constants.linkButtonMissingHrefComment, 'line');
185
+ var _element$node$attribu2;
186
+ (0, _generateNewButtonElement.modifyButtonAttributes)(element.node, j, hasSpacingNone);
187
+ var _attribute = (_element$node$attribu2 = element.node.attributes) === null || _element$node$attribu2 === void 0 ? void 0 : _element$node$attribu2.find(function (node) {
188
+ return node.type === 'JSXAttribute' && node.name.name === 'appearance';
189
+ });
190
+ if (_attribute) {
191
+ (0, _codemodUtils.addCommentBefore)(j, j(_attribute), hasSpacingNone ? _constants.noSpacinglinkButtonMissingHrefComment : _constants.linkButtonMissingHrefComment, 'line');
192
+ }
157
193
  }
158
194
  });
159
195
 
@@ -216,6 +252,13 @@ var transformer = function transformer(file, api) {
216
252
  (0, _renameDefaultButtonToLegacyButton.renameDefaultButtonToLegacyButtonImport)(oldButtonImports, oldButtonsWithUnsupportedProps, j);
217
253
  }
218
254
  }
255
+ if (hasVariant.link) {
256
+ var linkImport = j.importDeclaration([j.importDefaultSpecifier(j.identifier('Link'))], j.stringLiteral('@atlaskit/link'));
257
+ oldButtonImports.at(0).insertBefore(linkImport);
258
+ if (!remainingDefaultButtons && !oldButtonsWithUnsupportedProps.length) {
259
+ oldButtonImports.at(0).remove();
260
+ }
261
+ }
219
262
  if (specifiers.length) {
220
263
  var existingNewButtonImports = fileSource.find(j.ImportDeclaration).filter(function (path) {
221
264
  return path.node.source.value === _constants.NEW_BUTTON_ENTRY_POINT;
@@ -3,10 +3,10 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = _default;
6
+ exports.default = void 0;
7
7
  var _utils = require("@hypermod/utils");
8
8
  var _constants = require("../utils/constants");
9
- function _default(file, api) {
9
+ function transformer(file, api) {
10
10
  var j = api.jscodeshift;
11
11
  var source = j(file.source);
12
12
 
@@ -118,4 +118,5 @@ function _default(file, api) {
118
118
  }
119
119
  });
120
120
  return source.toSource(_constants.PRINT_SETTINGS);
121
- }
121
+ }
122
+ var _default = exports.default = transformer;
@@ -11,6 +11,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
11
11
  var _nextSplitImports = _interopRequireDefault(require("./codemods/next-split-imports"));
12
12
  var _nextMigrateToNewButtonVariants = _interopRequireDefault(require("./codemods/next-migrate-to-new-button-variants"));
13
13
  var _nextRemoveUnsafeSize = _interopRequireDefault(require("./codemods/next-remove-unsafe-size"));
14
+ var _nextMigrateLinkButtonToLink = _interopRequireDefault(require("./codemods/next-migrate-link-button-to-link"));
14
15
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
16
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
17
  function transformer(_x, _x2) {
@@ -22,7 +23,7 @@ function _transformer() {
22
23
  return _regenerator.default.wrap(function _callee$(_context) {
23
24
  while (1) switch (_context.prev = _context.next) {
24
25
  case 0:
25
- transformers = [_nextSplitImports.default, _nextMigrateToNewButtonVariants.default, _nextRemoveUnsafeSize.default];
26
+ transformers = [_nextSplitImports.default, _nextMigrateToNewButtonVariants.default, _nextRemoveUnsafeSize.default, _nextMigrateLinkButtonToLink.default];
26
27
  src = file.source;
27
28
  transformers.forEach(function (transformer) {
28
29
  if (typeof src === 'undefined') {
@@ -3,12 +3,14 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.unsupportedProps = exports.overlayPropComment = exports.migrateFitContainerButtonToIconButtonComment = exports.migrateFitContainerButtonToDefaultButtonComment = exports.loadingButtonComment = exports.linkButtonMissingHrefComment = exports.entryPointsMapping = exports.customThemeButtonComment = exports.buttonPropsNoLongerSupportedComment = exports.UNSAFE_SIZE_PROPS_MAP = exports.PRINT_SETTINGS = exports.OLD_BUTTON_VARIANTS = exports.OLD_BUTTON_ENTRY_POINT = exports.NEW_BUTTON_VARIANTS = exports.NEW_BUTTON_ENTRY_POINT = exports.BUTTON_TYPES = void 0;
6
+ exports.unsupportedProps = exports.overlayPropComment = exports.noSpacinglinkButtonMissingHrefComment = exports.migrateSubtleButtonToSubtleLinkButton = exports.migrateFitContainerButtonToIconButtonComment = exports.migrateFitContainerButtonToDefaultButtonComment = exports.migrateButtonToSubtleLinkButton = exports.loadingButtonComment = exports.linkButtonMissingHrefComment = exports.entryPointsMapping = exports.customThemeButtonComment = exports.buttonPropsNoLongerSupportedComment = exports.UNSAFE_SIZE_PROPS_MAP = exports.PRINT_SETTINGS = exports.OLD_BUTTON_VARIANTS = exports.OLD_BUTTON_ENTRY_POINT = exports.NEW_BUTTON_VARIANTS = exports.NEW_BUTTON_ENTRY_POINT = exports.BUTTON_TYPES = void 0;
7
7
  var PRINT_SETTINGS = exports.PRINT_SETTINGS = {
8
8
  quote: 'single'
9
9
  };
10
10
 
11
- /** NEW button **/
11
+ /**
12
+ * NEW button *
13
+ */
12
14
  var NEW_BUTTON_ENTRY_POINT = exports.NEW_BUTTON_ENTRY_POINT = '@atlaskit/button/new';
13
15
  var NEW_BUTTON_VARIANTS = exports.NEW_BUTTON_VARIANTS = {
14
16
  default: 'Button',
@@ -17,7 +19,9 @@ var NEW_BUTTON_VARIANTS = exports.NEW_BUTTON_VARIANTS = {
17
19
  linkIcon: 'LinkIconButton'
18
20
  };
19
21
 
20
- /** OLD button **/
22
+ /**
23
+ * OLD button *
24
+ */
21
25
  var OLD_BUTTON_ENTRY_POINT = exports.OLD_BUTTON_ENTRY_POINT = '@atlaskit/button';
22
26
  var OLD_BUTTON_VARIANTS = exports.OLD_BUTTON_VARIANTS = {
23
27
  loading: 'LoadingButton'
@@ -35,7 +39,8 @@ var UNSAFE_SIZE_PROPS_MAP = exports.UNSAFE_SIZE_PROPS_MAP = {
35
39
  UNSAFE_iconBefore_size: 'iconBefore'
36
40
  };
37
41
  var unsupportedProps = exports.unsupportedProps = ['component', 'css', 'style'];
38
- var linkButtonMissingHrefComment = exports.linkButtonMissingHrefComment = "\"link\" and \"subtle-link\" appearances are only available in LinkButton, please either provide a href prop then migrate to LinkButton, or remove the appearance from the default button.";
42
+ var linkButtonMissingHrefComment = exports.linkButtonMissingHrefComment = "\"link\" and \"subtle-link\" appearances are not available in the new Button, appearance should be \"subtle\" or \"default\".";
43
+ var noSpacinglinkButtonMissingHrefComment = exports.noSpacinglinkButtonMissingHrefComment = "\"link\" and \"subtle-link\" appearances are not available in the new Button, appearance should be \"subtle\" or \"default\", or provide a href prop then migrate to Link.";
39
44
  var buttonPropsNoLongerSupportedComment = exports.buttonPropsNoLongerSupportedComment = "Buttons with \"component\", \"css\" or \"style\" prop can't be automatically migrated with codemods. Please migrate it manually.";
40
45
  var migrateFitContainerButtonToDefaultButtonComment = exports.migrateFitContainerButtonToDefaultButtonComment = "Migrated to a default button with text which is from the icon label.";
41
46
  var migrateFitContainerButtonToIconButtonComment = exports.migrateFitContainerButtonToIconButtonComment = "\"shouldFitContainer\" is not available in icon buttons, please consider using a default button with text.";
@@ -45,4 +50,6 @@ var loadingButtonComment = exports.loadingButtonComment = function loadingButton
45
50
  var hasLinkAppearance = _ref.hasLinkAppearance,
46
51
  hasHref = _ref.hasHref;
47
52
  return "This should be migrated to a new Button with a `isLoading` prop. ".concat(hasLinkAppearance ? "\"link\" and \"subtle-link\" appearances are not available for new loading buttons.\"" : '').concat(hasHref ? "The `href` attribute it not compatible with new loading buttons, because links should not need loading states." : '', " Please reconsider the design or change the appearance of the button.");
48
- };
53
+ };
54
+ var migrateButtonToSubtleLinkButton = exports.migrateButtonToSubtleLinkButton = "\"link\" and \"subtle-link\" appearances are not available in the new Button. Appearance should be migrated to \"subtle\" or \"default\" for Link Button, or use Link with \"default\" appearance.";
55
+ var migrateSubtleButtonToSubtleLinkButton = exports.migrateSubtleButtonToSubtleLinkButton = "\"link\" and \"subtle-link\" appearances are not available in the new Button. Appearance should be migrated to \"subtle\" or \"default\" for Link Button, or use Link with \"subtle\" appearance.";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.findJSXAttributeWithValue = void 0;
7
+ var findJSXAttributeWithValue = exports.findJSXAttributeWithValue = function findJSXAttributeWithValue(path, attributeName, attributeValue) {
8
+ var _path$attributes;
9
+ if (!path || path.type === 'JSXSpreadAttribute') {
10
+ return false;
11
+ }
12
+ var attribute = path === null || path === void 0 || (_path$attributes = path.attributes) === null || _path$attributes === void 0 ? void 0 : _path$attributes.find(function (attribute) {
13
+ var _attribute$value;
14
+ return attribute.type === 'JSXAttribute' && attribute.name.name === attributeName && ((_attribute$value = attribute.value) === null || _attribute$value === void 0 ? void 0 : _attribute$value.type) === 'StringLiteral' && attribute.value.value === attributeValue;
15
+ });
16
+ return Boolean(attribute);
17
+ };
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.modifyLinkAttributes = exports.generateLinkComponent = void 0;
7
+ var modifyLinkAttributes = exports.modifyLinkAttributes = function modifyLinkAttributes(element, j) {
8
+ j(element).find(j.JSXAttribute).filter(function (path) {
9
+ var _path$node$value, _path$node$value2;
10
+ return path.node.name.name === 'appearance' && ((_path$node$value = path.node.value) === null || _path$node$value === void 0 ? void 0 : _path$node$value.type) === 'StringLiteral' && path.node.value.value === 'link' || path.node.name.name === 'spacing' && ((_path$node$value2 = path.node.value) === null || _path$node$value2 === void 0 ? void 0 : _path$node$value2.type) === 'StringLiteral' && path.node.value.value === 'none';
11
+ }).remove();
12
+ j(element).find(j.JSXAttribute).filter(function (path) {
13
+ var _path$node$value3;
14
+ return path.node.name.name === 'appearance' && ((_path$node$value3 = path.node.value) === null || _path$node$value3 === void 0 ? void 0 : _path$node$value3.type) === 'StringLiteral' && path.node.value.value === 'subtle-link';
15
+ }).replaceWith(j.jsxAttribute(j.jsxIdentifier('appearance'), j.stringLiteral('subtle')));
16
+ };
17
+ var generateLinkComponent = exports.generateLinkComponent = function generateLinkComponent(element, j) {
18
+ var attributes = element.openingElement.attributes;
19
+ if (!element.children) {
20
+ return;
21
+ }
22
+ modifyLinkAttributes(element, j);
23
+ j(element).find(j.JSXAttribute).filter(function (attribute) {
24
+ var _attribute$node$value;
25
+ var isIconAttribute = attribute.node.name.name === 'iconBefore' || attribute.node.name.name === 'iconAfter';
26
+ if (((_attribute$node$value = attribute.node.value) === null || _attribute$node$value === void 0 ? void 0 : _attribute$node$value.type) === 'JSXExpressionContainer' && isIconAttribute) {
27
+ var iconNode = attribute.node.value;
28
+ if (iconNode && iconNode.type === 'JSXExpressionContainer' && iconNode.expression.type === 'JSXElement' && element.children) {
29
+ var icon = iconNode.expression;
30
+ attribute.node.name.name === 'iconBefore' ? element.children.unshift(icon) : element.children.push(icon);
31
+ }
32
+ }
33
+ return isIconAttribute;
34
+ }).remove();
35
+ return j.jsxElement.from({
36
+ openingElement: j.jsxOpeningElement(j.jsxIdentifier('Link'), attributes, false),
37
+ closingElement: j.jsxClosingElement(j.jsxIdentifier('Link')),
38
+ children: element.children
39
+ });
40
+ };
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.handleIconAttributes = exports.getIconElement = exports.getIconAttributes = exports.generateNewElement = void 0;
6
+ exports.modifyButtonAttributes = exports.handleIconAttributes = exports.getIconElement = exports.getIconAttributes = exports.generateNewElement = void 0;
7
7
  var _constants = require("../utils/constants");
8
8
  var getIconAttributes = exports.getIconAttributes = function getIconAttributes(attributes) {
9
9
  var iconAttr = attributes === null || attributes === void 0 ? void 0 : attributes.filter(function (attribute) {
@@ -38,7 +38,6 @@ var getIconElement = exports.getIconElement = function getIconElement(iconAttr)
38
38
  var handleIconAttributes = exports.handleIconAttributes = function handleIconAttributes(element, j) {
39
39
  var iconRenamed = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
40
40
  var buttonAttributes = element.openingElement.attributes;
41
-
42
41
  // Get iconBefore and iconAfter attributes
43
42
  var buttonIconAttributes = buttonAttributes && getIconAttributes(buttonAttributes);
44
43
  buttonIconAttributes === null || buttonIconAttributes === void 0 || buttonIconAttributes.forEach(function (iconAttribute) {
@@ -113,6 +112,12 @@ var generateNewElement = exports.generateNewElement = function generateNewElemen
113
112
  var attributes = element.openingElement.attributes;
114
113
  var iconAttrs = attributes && getIconAttributes(attributes);
115
114
  var isIconOrLinkIcon = variant === _constants.NEW_BUTTON_VARIANTS.icon || variant === _constants.NEW_BUTTON_VARIANTS.linkIcon;
115
+ if (variant === _constants.NEW_BUTTON_VARIANTS.link) {
116
+ j(element).find(j.JSXAttribute).filter(function (path) {
117
+ var _path$node$value;
118
+ return path.node.name.name === 'appearance' && ((_path$node$value = path.node.value) === null || _path$node$value === void 0 ? void 0 : _path$node$value.type) === 'StringLiteral' && (path.node.value.value === 'subtle-link' || path.node.value.value === 'link');
119
+ }).replaceWith(j.jsxAttribute(j.jsxIdentifier('appearance'), j.stringLiteral('subtle')));
120
+ }
116
121
  if (isIconOrLinkIcon && iconAttrs !== null && iconAttrs !== void 0 && iconAttrs.length) {
117
122
  handleIconAttributes(element, j, true);
118
123
 
@@ -140,4 +145,16 @@ var generateNewElement = exports.generateNewElement = function generateNewElemen
140
145
  closingElement: isIconOrLinkIcon ? null : j.jsxClosingElement(j.jsxIdentifier(variant)),
141
146
  children: element.children
142
147
  });
148
+ };
149
+ var modifyButtonAttributes = exports.modifyButtonAttributes = function modifyButtonAttributes(element, j, hasSpacingNone) {
150
+ j(element).find(j.JSXAttribute).filter(function (path) {
151
+ var _path$node$value2;
152
+ return path.node.name.name === 'appearance' && ((_path$node$value2 = path.node.value) === null || _path$node$value2 === void 0 ? void 0 : _path$node$value2.type) === 'StringLiteral' && (path.node.value.value === 'link' || path.node.value.value === 'subtle-link');
153
+ }).replaceWith(j.jsxAttribute(j.jsxIdentifier('appearance'), j.stringLiteral('subtle')));
154
+ if (hasSpacingNone) {
155
+ j(element).find(j.JSXAttribute).filter(function (path) {
156
+ var _path$node$value3;
157
+ return path.node.name.name === 'spacing' && ((_path$node$value3 = path.node.value) === null || _path$node$value3 === void 0 ? void 0 : _path$node$value3.type) === 'StringLiteral' && path.node.value.value === 'none';
158
+ }).remove();
159
+ }
143
160
  };
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var moveIcon = function moveIcon(j, path, iconNode, beforeOrAfter) {
8
+ var element;
9
+ if (!iconNode) {
10
+ return;
11
+ }
12
+ if (iconNode.type === 'JSXExpressionContainer') {
13
+ // when iconBefore={(iconProps) => <AddIcon {...iconProps} />}
14
+ if (iconNode.expression.type === 'ArrowFunctionExpression' && iconNode.expression.body.type === 'JSXElement') {
15
+ // remove {...iconProps} spread attribute
16
+ element = iconNode.expression.body;
17
+ j(element).find(j.JSXSpreadAttribute).remove();
18
+ j(element).find(j.JSXAttribute).insertBefore(j.jsxAttribute(j.jsxIdentifier('label'), j.stringLiteral('')));
19
+ }
20
+
21
+ // when iconBefore={AddIcon}
22
+ if (iconNode.expression.type === 'Identifier') {
23
+ element = j.jsxElement(j.jsxOpeningElement(j.jsxIdentifier(iconNode.expression.name), [j.jsxAttribute(j.jsxIdentifier('label'), j.stringLiteral(''))], true));
24
+ }
25
+ if (element && path.node.children) {
26
+ beforeOrAfter === 'iconBefore' ? path.node.children.unshift(element) : path.node.children.push(element);
27
+ }
28
+ }
29
+ };
30
+ var _default = exports.default = moveIcon;
@@ -0,0 +1,95 @@
1
+ /* eslint-disable @repo/internal/fs/filename-pattern-match */
2
+ import { getImportDeclaration } from '@hypermod/utils';
3
+ import { addCommentBefore } from '@atlaskit/codemod-utils';
4
+ import { migrateButtonToSubtleLinkButton, migrateSubtleButtonToSubtleLinkButton, NEW_BUTTON_ENTRY_POINT, NEW_BUTTON_VARIANTS, PRINT_SETTINGS } from '../utils/constants';
5
+ import { findJSXAttributeWithValue } from '../utils/find-attribute-with-value';
6
+ import { modifyLinkAttributes } from '../utils/generate-link-element';
7
+ import moveIconValueFromLinkButtonPropsToLinkChildren from '../utils/move-icon-value-from-link-button-to-link-children';
8
+ function transformer(file, api) {
9
+ const j = api.jscodeshift;
10
+ const source = j(file.source);
11
+
12
+ // Find all new button imports
13
+ const newButtonImportDeclarations = getImportDeclaration(j, source, NEW_BUTTON_ENTRY_POINT);
14
+
15
+ // No imports for new button found, exit early
16
+ if (!newButtonImportDeclarations.length) {
17
+ return source.toSource();
18
+ }
19
+ let linkButtonSpecifier = '';
20
+ let linkButtonDeclaration;
21
+ newButtonImportDeclarations.forEach(newButtonImport => {
22
+ if (!newButtonImport.value.specifiers) {
23
+ return;
24
+ }
25
+ newButtonImport.value.specifiers.map(specifier => {
26
+ if (specifier.type === 'ImportSpecifier' && specifier.imported && specifier.imported.name === NEW_BUTTON_VARIANTS['link']) {
27
+ var _specifier$local;
28
+ linkButtonDeclaration = newButtonImport;
29
+ linkButtonSpecifier = ((_specifier$local = specifier.local) === null || _specifier$local === void 0 ? void 0 : _specifier$local.name) || '';
30
+ }
31
+ });
32
+ });
33
+ if (!linkButtonSpecifier) {
34
+ return source.toSource();
35
+ }
36
+ let hasLink = false;
37
+ const allLinkButtons = source.find(j.JSXElement).filter(path => path.value.openingElement.name.type === 'JSXIdentifier' && path.value.openingElement.name.name === linkButtonSpecifier);
38
+ allLinkButtons.filter(path => findJSXAttributeWithValue(path.value.openingElement, 'appearance', 'link') || findJSXAttributeWithValue(path.value.openingElement, 'appearance', 'subtle-link')).forEach(path => {
39
+ const hasSpacingNone = findJSXAttributeWithValue(path.value.openingElement, 'spacing', 'none');
40
+ if (!hasSpacingNone) {
41
+ let oldAppearanceValue;
42
+ j(path).find(j.JSXAttribute).filter(path => {
43
+ var _path$node$value;
44
+ if (path.node.name.name === 'appearance' && ((_path$node$value = path.node.value) === null || _path$node$value === void 0 ? void 0 : _path$node$value.type) === 'StringLiteral' && (path.node.value.value === 'subtle-link' || path.node.value.value === 'link')) {
45
+ oldAppearanceValue = path.node.value.value;
46
+ return true;
47
+ }
48
+ return false;
49
+ }).replaceWith(j.jsxAttribute(j.jsxIdentifier('appearance'), j.stringLiteral('subtle')));
50
+ if (oldAppearanceValue) {
51
+ var _path$value$openingEl;
52
+ const attribute = (_path$value$openingEl = path.value.openingElement.attributes) === null || _path$value$openingEl === void 0 ? void 0 : _path$value$openingEl.find(node => node.type === 'JSXAttribute' && node.name.name === 'appearance');
53
+ if (attribute) {
54
+ addCommentBefore(j, j(attribute), oldAppearanceValue === 'link' ? migrateButtonToSubtleLinkButton : migrateSubtleButtonToSubtleLinkButton, 'line');
55
+ }
56
+ }
57
+ }
58
+ if (hasSpacingNone) {
59
+ const {
60
+ attributes
61
+ } = path.node.openingElement;
62
+ modifyLinkAttributes(path.node, j);
63
+ j(path).find(j.JSXAttribute).filter(attribute => {
64
+ var _attribute$node$value;
65
+ const isIconAttribute = attribute.node.name.name === 'iconBefore' || attribute.node.name.name === 'iconAfter';
66
+ if (((_attribute$node$value = attribute.node.value) === null || _attribute$node$value === void 0 ? void 0 : _attribute$node$value.type) === 'JSXExpressionContainer' && isIconAttribute) {
67
+ moveIconValueFromLinkButtonPropsToLinkChildren(j, path, attribute.node.value, attribute.node.name.name);
68
+ }
69
+ return isIconAttribute;
70
+ }).remove();
71
+ hasLink = true;
72
+ j(path).replaceWith(j.jsxElement.from({
73
+ openingElement: j.jsxOpeningElement(j.jsxIdentifier('Link'), attributes, false),
74
+ closingElement: j.jsxClosingElement(j.jsxIdentifier('Link')),
75
+ children: path.node.children
76
+ }));
77
+ }
78
+ });
79
+
80
+ // add link import and remove link button import if no link button is found
81
+ if (hasLink && linkButtonDeclaration) {
82
+ const linkImport = j.importDeclaration([j.importDefaultSpecifier(j.identifier('Link'))], j.stringLiteral('@atlaskit/link'));
83
+ j(linkButtonDeclaration).insertAfter(linkImport);
84
+ const remainingLinkButton = source.find(j.JSXElement).filter(path => path.value.openingElement.name.type === 'JSXIdentifier' && path.value.openingElement.name.name === linkButtonSpecifier);
85
+ if (!remainingLinkButton.length) {
86
+ var _value$specifiers;
87
+ j(linkButtonDeclaration).find(j.ImportSpecifier).filter(path => path.node.imported.name === NEW_BUTTON_VARIANTS['link']).remove();
88
+ if (((_value$specifiers = linkButtonDeclaration.value.specifiers) === null || _value$specifiers === void 0 ? void 0 : _value$specifiers.length) === 0) {
89
+ j(linkButtonDeclaration).remove();
90
+ }
91
+ }
92
+ }
93
+ return source.toSource(PRINT_SETTINGS);
94
+ }
95
+ export default transformer;