@atlaskit/codemod-cli 0.23.1 → 0.24.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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/codemod-cli
2
2
 
3
+ ## 0.24.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#99062](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/99062)
8
+ [`b8cd8340331d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b8cd8340331d) -
9
+ Add transform to move away for UNSAFE button APIs.
10
+
3
11
  ## 0.23.1
4
12
 
5
13
  ### Patch 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.23.1", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
308
+ _process$env$_PACKAGE = "0.24.0", _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,114 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = _default;
7
+ var _utils = require("@hypermod/utils");
8
+ var _constants = require("../utils/constants");
9
+ function _default(file, api) {
10
+ var j = api.jscodeshift;
11
+ var source = j(file.source);
12
+
13
+ // Find all new button imports
14
+ var newButtonImportDeclarations = (0, _utils.getImportDeclaration)(j, source, _constants.NEW_BUTTON_ENTRY_POINT);
15
+
16
+ // No imports for new button found, exit early
17
+ if (!newButtonImportDeclarations.length) {
18
+ return source.toSource();
19
+ }
20
+
21
+ // Get all the specifyier names
22
+ // eg ['Button', 'IconButton', 'LinkButton', 'LinkIconButton']
23
+ var newButtonSpecifiers = [];
24
+ newButtonImportDeclarations.forEach(function (newButtonImport) {
25
+ if (!newButtonImport.value.specifiers) {
26
+ return;
27
+ }
28
+ newButtonImport.value.specifiers.map(function (specifier) {
29
+ if (specifier.local && specifier.local.name) {
30
+ newButtonSpecifiers.push(specifier.local.name);
31
+ }
32
+ });
33
+ });
34
+
35
+ // Find all new button JSX elements with an UNSAFE size prop
36
+ var newButtonJXSElements = source.find(j.JSXElement)
37
+ // is a new button?
38
+ .filter(function (path) {
39
+ return path.value.openingElement.name.type === 'JSXIdentifier' && newButtonSpecifiers.includes(path.value.openingElement.name.name);
40
+ })
41
+ // has an usafe size prop?
42
+ .filter(function (path) {
43
+ return Object.keys(_constants.UNSAFE_SIZE_PROPS_MAP).some(function (unsafeSizeProp) {
44
+ return (0, _utils.hasJSXAttributes)(j, path, unsafeSizeProp);
45
+ });
46
+ });
47
+ newButtonJXSElements.forEach(function (newButtonJXSElement) {
48
+ var _loop = function _loop(unsafeSizeProp) {
49
+ var _newButtonJXSElement$;
50
+ var iconProp = _constants.UNSAFE_SIZE_PROPS_MAP[unsafeSizeProp];
51
+
52
+ // Get all icon attributes
53
+ // eg. ['iconBefore', 'iconAfter', 'icon']
54
+ var iconAttributes = (_newButtonJXSElement$ = newButtonJXSElement.value.openingElement.attributes) === null || _newButtonJXSElement$ === void 0 ? void 0 : _newButtonJXSElement$.filter(function (attribute) {
55
+ return attribute.type === 'JSXAttribute' && attribute.name.name === iconProp;
56
+ });
57
+ if (!iconAttributes) {
58
+ return {
59
+ v: void 0
60
+ };
61
+ }
62
+
63
+ // Check if render prop or bounded API
64
+ iconAttributes.forEach(function (iconAttribute) {
65
+ var _newButtonJXSElement$2, _iconAttribute$value;
66
+ var unsafeSizeAttribute = (_newButtonJXSElement$2 = newButtonJXSElement.value.openingElement.attributes) === null || _newButtonJXSElement$2 === void 0 ? void 0 : _newButtonJXSElement$2.find(function (attribute) {
67
+ return attribute.type === 'JSXAttribute' && attribute.name.name === unsafeSizeProp;
68
+ });
69
+ if (iconAttribute.type !== 'JSXAttribute' || ((_iconAttribute$value = iconAttribute.value) === null || _iconAttribute$value === void 0 ? void 0 : _iconAttribute$value.type) !== 'JSXExpressionContainer' || !unsafeSizeAttribute || unsafeSizeAttribute.type !== 'JSXAttribute') {
70
+ return;
71
+ }
72
+ switch (iconAttribute.value.expression.type) {
73
+ // We have a render prop, move the UNSAFE prop to the render prop
74
+ case 'ArrowFunctionExpression':
75
+ // TODO: we have an existing render prop, move size to there
76
+ break;
77
+
78
+ // We have a bounded API, move to render prop
79
+ case 'Identifier':
80
+ var iconName = iconAttribute.value.expression.name;
81
+
82
+ // Create new arrow function (renderProp)
83
+ iconAttribute.value = j.jsxExpressionContainer(j.arrowFunctionExpression.from({
84
+ params: [j.identifier('iconProps')],
85
+ body: j.jsxElement.from({
86
+ openingElement: j.jsxOpeningElement.from({
87
+ name: j.jsxIdentifier(iconName),
88
+ selfClosing: true,
89
+ attributes: [j.jsxSpreadAttribute.from({
90
+ argument: j.identifier('iconProps')
91
+ }), j.jsxAttribute.from({
92
+ name: j.jsxIdentifier('size'),
93
+ value: unsafeSizeAttribute.value
94
+ })]
95
+ })
96
+ })
97
+ }));
98
+ break;
99
+ }
100
+
101
+ // Remove the UNSAFE icon attribute
102
+ j(newButtonJXSElement.value.openingElement).find(j.JSXAttribute).filter(function (attribute) {
103
+ return attribute.value.name.name === unsafeSizeProp;
104
+ }).remove();
105
+ });
106
+ },
107
+ _ret;
108
+ for (var unsafeSizeProp in _constants.UNSAFE_SIZE_PROPS_MAP) {
109
+ _ret = _loop(unsafeSizeProp);
110
+ if (_ret) return _ret.v;
111
+ }
112
+ });
113
+ return source.toSource(_constants.PRINT_SETTINGS);
114
+ }
@@ -10,6 +10,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
10
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
11
  var _nextSplitImports = _interopRequireDefault(require("./codemods/next-split-imports"));
12
12
  var _nextMigrateToNewButtonVariants = _interopRequireDefault(require("./codemods/next-migrate-to-new-button-variants"));
13
+ var _nextRemoveUnsafeSize = _interopRequireDefault(require("./codemods/next-remove-unsafe-size"));
13
14
  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; }
14
15
  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; }
15
16
  function transformer(_x, _x2) {
@@ -21,7 +22,7 @@ function _transformer() {
21
22
  return _regenerator.default.wrap(function _callee$(_context) {
22
23
  while (1) switch (_context.prev = _context.next) {
23
24
  case 0:
24
- transformers = [_nextSplitImports.default, _nextMigrateToNewButtonVariants.default];
25
+ transformers = [_nextSplitImports.default, _nextMigrateToNewButtonVariants.default, _nextRemoveUnsafeSize.default];
25
26
  src = file.source;
26
27
  transformers.forEach(function (transformer) {
27
28
  if (typeof src === 'undefined') {
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.unsupportedProps = exports.migrateFitContainerButtonToIconButtonComment = exports.migrateFitContainerButtonToDefaultButtonComment = exports.linkButtonMissingHrefComment = exports.entryPointsMapping = exports.buttonPropsNoLongerSupportedComment = exports.PRINT_SETTINGS = exports.NEW_BUTTON_VARIANTS = exports.NEW_BUTTON_ENTRY_POINT = exports.BUTTON_TYPES = void 0;
6
+ exports.unsupportedProps = exports.migrateFitContainerButtonToIconButtonComment = exports.migrateFitContainerButtonToDefaultButtonComment = exports.linkButtonMissingHrefComment = exports.entryPointsMapping = exports.buttonPropsNoLongerSupportedComment = exports.UNSAFE_SIZE_PROPS_MAP = exports.PRINT_SETTINGS = 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
  };
@@ -21,6 +21,11 @@ var entryPointsMapping = exports.entryPointsMapping = {
21
21
  CustomThemeButton: '@atlaskit/button/custom-theme-button'
22
22
  };
23
23
  var BUTTON_TYPES = exports.BUTTON_TYPES = ['BaseOwnProps', 'BaseProps', 'ButtonProps', 'LoadingButtonProps', 'LoadingButtonOwnProps', 'ThemeTokens', 'ThemeProps', 'InteractionState', 'CustomThemeButtonProps', 'CustomThemeButtonOwnProps'];
24
+ var UNSAFE_SIZE_PROPS_MAP = exports.UNSAFE_SIZE_PROPS_MAP = {
25
+ UNSAFE_size: 'icon',
26
+ UNSAFE_iconAfter_size: 'iconAfter',
27
+ UNSAFE_iconBefore_size: 'iconBefore'
28
+ };
24
29
  var unsupportedProps = exports.unsupportedProps = ['component', 'css', 'style'];
25
30
  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.";
26
31
  var buttonPropsNoLongerSupportedComment = exports.buttonPropsNoLongerSupportedComment = "Buttons with \"component\", \"css\" or \"style\" prop can't be automatically migrated with codemods. Please migrate it manually.";
@@ -0,0 +1,89 @@
1
+ import { getImportDeclaration, hasJSXAttributes } from '@hypermod/utils';
2
+ import { PRINT_SETTINGS, NEW_BUTTON_ENTRY_POINT, UNSAFE_SIZE_PROPS_MAP } from '../utils/constants';
3
+ export default function (file, api) {
4
+ const j = api.jscodeshift;
5
+ const source = j(file.source);
6
+
7
+ // Find all new button imports
8
+ const newButtonImportDeclarations = getImportDeclaration(j, source, NEW_BUTTON_ENTRY_POINT);
9
+
10
+ // No imports for new button found, exit early
11
+ if (!newButtonImportDeclarations.length) {
12
+ return source.toSource();
13
+ }
14
+
15
+ // Get all the specifyier names
16
+ // eg ['Button', 'IconButton', 'LinkButton', 'LinkIconButton']
17
+ const newButtonSpecifiers = [];
18
+ newButtonImportDeclarations.forEach(newButtonImport => {
19
+ if (!newButtonImport.value.specifiers) {
20
+ return;
21
+ }
22
+ newButtonImport.value.specifiers.map(specifier => {
23
+ if (specifier.local && specifier.local.name) {
24
+ newButtonSpecifiers.push(specifier.local.name);
25
+ }
26
+ });
27
+ });
28
+
29
+ // Find all new button JSX elements with an UNSAFE size prop
30
+ const newButtonJXSElements = source.find(j.JSXElement)
31
+ // is a new button?
32
+ .filter(path => path.value.openingElement.name.type === 'JSXIdentifier' && newButtonSpecifiers.includes(path.value.openingElement.name.name))
33
+ // has an usafe size prop?
34
+ .filter(path => Object.keys(UNSAFE_SIZE_PROPS_MAP).some(unsafeSizeProp => hasJSXAttributes(j, path, unsafeSizeProp)));
35
+ newButtonJXSElements.forEach(newButtonJXSElement => {
36
+ for (const unsafeSizeProp in UNSAFE_SIZE_PROPS_MAP) {
37
+ var _newButtonJXSElement$;
38
+ const iconProp = UNSAFE_SIZE_PROPS_MAP[unsafeSizeProp];
39
+
40
+ // Get all icon attributes
41
+ // eg. ['iconBefore', 'iconAfter', 'icon']
42
+ const iconAttributes = (_newButtonJXSElement$ = newButtonJXSElement.value.openingElement.attributes) === null || _newButtonJXSElement$ === void 0 ? void 0 : _newButtonJXSElement$.filter(attribute => attribute.type === 'JSXAttribute' && attribute.name.name === iconProp);
43
+ if (!iconAttributes) {
44
+ return;
45
+ }
46
+
47
+ // Check if render prop or bounded API
48
+ iconAttributes.forEach(iconAttribute => {
49
+ var _newButtonJXSElement$2, _iconAttribute$value;
50
+ const unsafeSizeAttribute = (_newButtonJXSElement$2 = newButtonJXSElement.value.openingElement.attributes) === null || _newButtonJXSElement$2 === void 0 ? void 0 : _newButtonJXSElement$2.find(attribute => attribute.type === 'JSXAttribute' && attribute.name.name === unsafeSizeProp);
51
+ if (iconAttribute.type !== 'JSXAttribute' || ((_iconAttribute$value = iconAttribute.value) === null || _iconAttribute$value === void 0 ? void 0 : _iconAttribute$value.type) !== 'JSXExpressionContainer' || !unsafeSizeAttribute || unsafeSizeAttribute.type !== 'JSXAttribute') {
52
+ return;
53
+ }
54
+ switch (iconAttribute.value.expression.type) {
55
+ // We have a render prop, move the UNSAFE prop to the render prop
56
+ case 'ArrowFunctionExpression':
57
+ // TODO: we have an existing render prop, move size to there
58
+ break;
59
+
60
+ // We have a bounded API, move to render prop
61
+ case 'Identifier':
62
+ const iconName = iconAttribute.value.expression.name;
63
+
64
+ // Create new arrow function (renderProp)
65
+ iconAttribute.value = j.jsxExpressionContainer(j.arrowFunctionExpression.from({
66
+ params: [j.identifier('iconProps')],
67
+ body: j.jsxElement.from({
68
+ openingElement: j.jsxOpeningElement.from({
69
+ name: j.jsxIdentifier(iconName),
70
+ selfClosing: true,
71
+ attributes: [j.jsxSpreadAttribute.from({
72
+ argument: j.identifier('iconProps')
73
+ }), j.jsxAttribute.from({
74
+ name: j.jsxIdentifier('size'),
75
+ value: unsafeSizeAttribute.value
76
+ })]
77
+ })
78
+ })
79
+ }));
80
+ break;
81
+ }
82
+
83
+ // Remove the UNSAFE icon attribute
84
+ j(newButtonJXSElement.value.openingElement).find(j.JSXAttribute).filter(attribute => attribute.value.name.name === unsafeSizeProp).remove();
85
+ });
86
+ }
87
+ });
88
+ return source.toSource(PRINT_SETTINGS);
89
+ }
@@ -1,7 +1,8 @@
1
1
  import splitImportsTransformer from './codemods/next-split-imports';
2
2
  import migrateToNewButtonVariantsTransformer from './codemods/next-migrate-to-new-button-variants';
3
+ import removeUnsafeSizeTransformer from './codemods/next-remove-unsafe-size';
3
4
  export default async function transformer(file, api) {
4
- const transformers = [splitImportsTransformer, migrateToNewButtonVariantsTransformer];
5
+ const transformers = [splitImportsTransformer, migrateToNewButtonVariantsTransformer, removeUnsafeSizeTransformer];
5
6
  let src = file.source;
6
7
  transformers.forEach(transformer => {
7
8
  if (typeof src === 'undefined') {
@@ -15,6 +15,11 @@ export const entryPointsMapping = {
15
15
  CustomThemeButton: '@atlaskit/button/custom-theme-button'
16
16
  };
17
17
  export const BUTTON_TYPES = ['BaseOwnProps', 'BaseProps', 'ButtonProps', 'LoadingButtonProps', 'LoadingButtonOwnProps', 'ThemeTokens', 'ThemeProps', 'InteractionState', 'CustomThemeButtonProps', 'CustomThemeButtonOwnProps'];
18
+ export const UNSAFE_SIZE_PROPS_MAP = {
19
+ UNSAFE_size: 'icon',
20
+ UNSAFE_iconAfter_size: 'iconAfter',
21
+ UNSAFE_iconBefore_size: 'iconBefore'
22
+ };
18
23
  export const unsupportedProps = ['component', 'css', 'style'];
19
24
  export const 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.`;
20
25
  export const buttonPropsNoLongerSupportedComment = `Buttons with "component", "css" or "style" prop can't be automatically migrated with codemods. Please migrate it manually.`;
package/dist/esm/main.js CHANGED
@@ -298,7 +298,7 @@ function _main() {
298
298
  case 4:
299
299
  _yield$parseArgs = _context5.sent;
300
300
  packages = _yield$parseArgs.packages;
301
- _process$env$_PACKAGE = "0.23.1", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
301
+ _process$env$_PACKAGE = "0.24.0", _PACKAGE_VERSION_ = _process$env$_PACKAGE === void 0 ? '0.0.0-dev' : _process$env$_PACKAGE;
302
302
  logger.log(chalk.bgBlue(chalk.black("\uD83D\uDCDA Atlassian-Frontend codemod library @ ".concat(_PACKAGE_VERSION_, " \uD83D\uDCDA"))));
303
303
  if (packages && packages.length > 0) {
304
304
  logger.log(chalk.gray("Searching for codemods for newer versions of the following packages: ".concat(packages.map(function (pkg) {
@@ -0,0 +1,108 @@
1
+ import { getImportDeclaration, hasJSXAttributes } from '@hypermod/utils';
2
+ import { PRINT_SETTINGS, NEW_BUTTON_ENTRY_POINT, UNSAFE_SIZE_PROPS_MAP } from '../utils/constants';
3
+ export default function (file, api) {
4
+ var j = api.jscodeshift;
5
+ var source = j(file.source);
6
+
7
+ // Find all new button imports
8
+ var newButtonImportDeclarations = getImportDeclaration(j, source, NEW_BUTTON_ENTRY_POINT);
9
+
10
+ // No imports for new button found, exit early
11
+ if (!newButtonImportDeclarations.length) {
12
+ return source.toSource();
13
+ }
14
+
15
+ // Get all the specifyier names
16
+ // eg ['Button', 'IconButton', 'LinkButton', 'LinkIconButton']
17
+ var newButtonSpecifiers = [];
18
+ newButtonImportDeclarations.forEach(function (newButtonImport) {
19
+ if (!newButtonImport.value.specifiers) {
20
+ return;
21
+ }
22
+ newButtonImport.value.specifiers.map(function (specifier) {
23
+ if (specifier.local && specifier.local.name) {
24
+ newButtonSpecifiers.push(specifier.local.name);
25
+ }
26
+ });
27
+ });
28
+
29
+ // Find all new button JSX elements with an UNSAFE size prop
30
+ var newButtonJXSElements = source.find(j.JSXElement)
31
+ // is a new button?
32
+ .filter(function (path) {
33
+ return path.value.openingElement.name.type === 'JSXIdentifier' && newButtonSpecifiers.includes(path.value.openingElement.name.name);
34
+ })
35
+ // has an usafe size prop?
36
+ .filter(function (path) {
37
+ return Object.keys(UNSAFE_SIZE_PROPS_MAP).some(function (unsafeSizeProp) {
38
+ return hasJSXAttributes(j, path, unsafeSizeProp);
39
+ });
40
+ });
41
+ newButtonJXSElements.forEach(function (newButtonJXSElement) {
42
+ var _loop = function _loop(unsafeSizeProp) {
43
+ var _newButtonJXSElement$;
44
+ var iconProp = UNSAFE_SIZE_PROPS_MAP[unsafeSizeProp];
45
+
46
+ // Get all icon attributes
47
+ // eg. ['iconBefore', 'iconAfter', 'icon']
48
+ var iconAttributes = (_newButtonJXSElement$ = newButtonJXSElement.value.openingElement.attributes) === null || _newButtonJXSElement$ === void 0 ? void 0 : _newButtonJXSElement$.filter(function (attribute) {
49
+ return attribute.type === 'JSXAttribute' && attribute.name.name === iconProp;
50
+ });
51
+ if (!iconAttributes) {
52
+ return {
53
+ v: void 0
54
+ };
55
+ }
56
+
57
+ // Check if render prop or bounded API
58
+ iconAttributes.forEach(function (iconAttribute) {
59
+ var _newButtonJXSElement$2, _iconAttribute$value;
60
+ var unsafeSizeAttribute = (_newButtonJXSElement$2 = newButtonJXSElement.value.openingElement.attributes) === null || _newButtonJXSElement$2 === void 0 ? void 0 : _newButtonJXSElement$2.find(function (attribute) {
61
+ return attribute.type === 'JSXAttribute' && attribute.name.name === unsafeSizeProp;
62
+ });
63
+ if (iconAttribute.type !== 'JSXAttribute' || ((_iconAttribute$value = iconAttribute.value) === null || _iconAttribute$value === void 0 ? void 0 : _iconAttribute$value.type) !== 'JSXExpressionContainer' || !unsafeSizeAttribute || unsafeSizeAttribute.type !== 'JSXAttribute') {
64
+ return;
65
+ }
66
+ switch (iconAttribute.value.expression.type) {
67
+ // We have a render prop, move the UNSAFE prop to the render prop
68
+ case 'ArrowFunctionExpression':
69
+ // TODO: we have an existing render prop, move size to there
70
+ break;
71
+
72
+ // We have a bounded API, move to render prop
73
+ case 'Identifier':
74
+ var iconName = iconAttribute.value.expression.name;
75
+
76
+ // Create new arrow function (renderProp)
77
+ iconAttribute.value = j.jsxExpressionContainer(j.arrowFunctionExpression.from({
78
+ params: [j.identifier('iconProps')],
79
+ body: j.jsxElement.from({
80
+ openingElement: j.jsxOpeningElement.from({
81
+ name: j.jsxIdentifier(iconName),
82
+ selfClosing: true,
83
+ attributes: [j.jsxSpreadAttribute.from({
84
+ argument: j.identifier('iconProps')
85
+ }), j.jsxAttribute.from({
86
+ name: j.jsxIdentifier('size'),
87
+ value: unsafeSizeAttribute.value
88
+ })]
89
+ })
90
+ })
91
+ }));
92
+ break;
93
+ }
94
+
95
+ // Remove the UNSAFE icon attribute
96
+ j(newButtonJXSElement.value.openingElement).find(j.JSXAttribute).filter(function (attribute) {
97
+ return attribute.value.name.name === unsafeSizeProp;
98
+ }).remove();
99
+ });
100
+ },
101
+ _ret;
102
+ for (var unsafeSizeProp in UNSAFE_SIZE_PROPS_MAP) {
103
+ _ret = _loop(unsafeSizeProp);
104
+ if (_ret) return _ret.v;
105
+ }
106
+ });
107
+ return source.toSource(PRINT_SETTINGS);
108
+ }
@@ -5,6 +5,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
5
5
  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) { _defineProperty(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; }
6
6
  import splitImportsTransformer from './codemods/next-split-imports';
7
7
  import migrateToNewButtonVariantsTransformer from './codemods/next-migrate-to-new-button-variants';
8
+ import removeUnsafeSizeTransformer from './codemods/next-remove-unsafe-size';
8
9
  export default function transformer(_x, _x2) {
9
10
  return _transformer.apply(this, arguments);
10
11
  }
@@ -14,7 +15,7 @@ function _transformer() {
14
15
  return _regeneratorRuntime.wrap(function _callee$(_context) {
15
16
  while (1) switch (_context.prev = _context.next) {
16
17
  case 0:
17
- transformers = [splitImportsTransformer, migrateToNewButtonVariantsTransformer];
18
+ transformers = [splitImportsTransformer, migrateToNewButtonVariantsTransformer, removeUnsafeSizeTransformer];
18
19
  src = file.source;
19
20
  transformers.forEach(function (transformer) {
20
21
  if (typeof src === 'undefined') {
@@ -15,6 +15,11 @@ export var entryPointsMapping = {
15
15
  CustomThemeButton: '@atlaskit/button/custom-theme-button'
16
16
  };
17
17
  export var BUTTON_TYPES = ['BaseOwnProps', 'BaseProps', 'ButtonProps', 'LoadingButtonProps', 'LoadingButtonOwnProps', 'ThemeTokens', 'ThemeProps', 'InteractionState', 'CustomThemeButtonProps', 'CustomThemeButtonOwnProps'];
18
+ export var UNSAFE_SIZE_PROPS_MAP = {
19
+ UNSAFE_size: 'icon',
20
+ UNSAFE_iconAfter_size: 'iconAfter',
21
+ UNSAFE_iconBefore_size: 'iconBefore'
22
+ };
18
23
  export var unsupportedProps = ['component', 'css', 'style'];
19
24
  export var 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.";
20
25
  export var buttonPropsNoLongerSupportedComment = "Buttons with \"component\", \"css\" or \"style\" prop can't be automatically migrated with codemods. Please migrate it manually.";
@@ -0,0 +1,2 @@
1
+ import { type API, type FileInfo } from 'jscodeshift';
2
+ export default function (file: FileInfo, api: API): string;
@@ -9,6 +9,7 @@ export declare const entryPointsMapping: {
9
9
  [key: string]: string;
10
10
  };
11
11
  export declare const BUTTON_TYPES: string[];
12
+ export declare const UNSAFE_SIZE_PROPS_MAP: Record<string, string>;
12
13
  export declare const unsupportedProps: string[];
13
14
  export declare const 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.";
14
15
  export declare const buttonPropsNoLongerSupportedComment = "Buttons with \"component\", \"css\" or \"style\" prop can't be automatically migrated with codemods. Please migrate it manually.";
@@ -1,4 +1,4 @@
1
- import { API, JSXElement, JSXAttribute, JSXSpreadAttribute } from 'jscodeshift';
1
+ import { type API, type JSXElement, type JSXAttribute, type JSXSpreadAttribute } from 'jscodeshift';
2
2
  import { NEW_BUTTON_VARIANTS } from '../utils/constants';
3
3
  export declare const getIconAttributes: (attributes: (JSXAttribute | JSXSpreadAttribute)[]) => JSXAttribute[] | null;
4
4
  export declare const getIconElement: (iconAttr: JSXAttribute) => JSXElement | null;
@@ -0,0 +1,2 @@
1
+ import { type API, type FileInfo } from 'jscodeshift';
2
+ export default function (file: FileInfo, api: API): string;
@@ -9,6 +9,7 @@ export declare const entryPointsMapping: {
9
9
  [key: string]: string;
10
10
  };
11
11
  export declare const BUTTON_TYPES: string[];
12
+ export declare const UNSAFE_SIZE_PROPS_MAP: Record<string, string>;
12
13
  export declare const unsupportedProps: string[];
13
14
  export declare const 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.";
14
15
  export declare const buttonPropsNoLongerSupportedComment = "Buttons with \"component\", \"css\" or \"style\" prop can't be automatically migrated with codemods. Please migrate it manually.";
@@ -1,4 +1,4 @@
1
- import { API, JSXElement, JSXAttribute, JSXSpreadAttribute } from 'jscodeshift';
1
+ import { type API, type JSXElement, type JSXAttribute, type JSXSpreadAttribute } from 'jscodeshift';
2
2
  import { NEW_BUTTON_VARIANTS } from '../utils/constants';
3
3
  export declare const getIconAttributes: (attributes: (JSXAttribute | JSXSpreadAttribute)[]) => JSXAttribute[] | null;
4
4
  export declare const getIconElement: (iconAttr: JSXAttribute) => JSXElement | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/codemod-cli",
3
- "version": "0.23.1",
3
+ "version": "0.24.0",
4
4
  "description": "A cli for distributing codemods for atlassian-frontend components and services",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -40,7 +40,7 @@
40
40
  "bin": "./bin/codemod-cli.js",
41
41
  "dependencies": {
42
42
  "@atlaskit/codemod-utils": "^4.2.0",
43
- "@atlaskit/tokens": "^1.45.0",
43
+ "@atlaskit/tokens": "^1.48.0",
44
44
  "@babel/runtime": "^7.0.0",
45
45
  "@codeshift/utils": "^0.2.4",
46
46
  "@hypermod/utils": "^0.4.2",