@atlaskit/eslint-plugin-design-system 13.14.2 → 13.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +63 -63
  3. package/dist/cjs/rules/no-legacy-icons/checks.js +22 -5
  4. package/dist/cjs/rules/no-legacy-icons/helpers.js +122 -46
  5. package/dist/cjs/rules/utils/get-deprecated-config.js +1 -1
  6. package/dist/es2019/rules/no-legacy-icons/checks.js +22 -6
  7. package/dist/es2019/rules/no-legacy-icons/helpers.js +125 -44
  8. package/dist/es2019/rules/utils/get-deprecated-config.js +3 -2
  9. package/dist/esm/rules/no-legacy-icons/checks.js +22 -5
  10. package/dist/esm/rules/no-legacy-icons/helpers.js +121 -45
  11. package/dist/esm/rules/utils/get-deprecated-config.js +2 -2
  12. package/dist/types/rules/no-legacy-icons/helpers.d.ts +12 -4
  13. package/dist/types/rules/use-tokens-typography/transformers/banned-properties.d.ts +1 -1
  14. package/dist/types/rules/use-tokens-typography/transformers/font-family.d.ts +1 -1
  15. package/dist/types/rules/use-tokens-typography/transformers/font-weight.d.ts +1 -1
  16. package/dist/types/rules/use-tokens-typography/transformers/restricted-capitalisation.d.ts +1 -1
  17. package/dist/types/rules/use-tokens-typography/transformers/untokenized-properties.d.ts +1 -1
  18. package/dist/types-ts4.5/rules/no-legacy-icons/helpers.d.ts +12 -4
  19. package/dist/types-ts4.5/rules/use-tokens-typography/transformers/banned-properties.d.ts +1 -1
  20. package/dist/types-ts4.5/rules/use-tokens-typography/transformers/font-family.d.ts +1 -1
  21. package/dist/types-ts4.5/rules/use-tokens-typography/transformers/font-weight.d.ts +1 -1
  22. package/dist/types-ts4.5/rules/use-tokens-typography/transformers/restricted-capitalisation.d.ts +1 -1
  23. package/dist/types-ts4.5/rules/use-tokens-typography/transformers/untokenized-properties.d.ts +1 -1
  24. package/package.json +4 -4
@@ -56,7 +56,7 @@ var getIconKey = function getIconKey(iconPackage) {
56
56
  * Checks if a new icon can be auto-migrated based on guidance from the migration map
57
57
  */
58
58
  export var canAutoMigrateNewIconBasedOnSize = function canAutoMigrateNewIconBasedOnSize(guidance) {
59
- return ['swap', 'swap-slight-visual-change', 'swap-visual-change', 'swap-size-shift-utility'].includes(guidance || '');
59
+ return guidance ? ['swap', 'swap-slight-visual-change', 'swap-visual-change'].includes(guidance) : false;
60
60
  };
61
61
 
62
62
  /**
@@ -84,8 +84,10 @@ var getNewIconNameAndImportPath = function getNewIconNameAndImportPath(iconPacka
84
84
  export var createGuidance = function createGuidance(_ref) {
85
85
  var iconPackage = _ref.iconPackage,
86
86
  insideNewButton = _ref.insideNewButton,
87
- size = _ref.size,
88
- shouldUseMigrationPath = _ref.shouldUseMigrationPath;
87
+ initialSize = _ref.size,
88
+ shouldUseMigrationPath = _ref.shouldUseMigrationPath,
89
+ shouldForceSmallIcon = _ref.shouldForceSmallIcon;
90
+ var size = shouldForceSmallIcon ? 'small' : initialSize;
89
91
  var migrationMapObject = getMigrationMapObject(iconPackage);
90
92
  var upcomingIcon = getUpcomingIcons(iconPackage);
91
93
  if (upcomingIcon) {
@@ -145,8 +147,18 @@ export var createGuidance = function createGuidance(_ref) {
145
147
  }
146
148
  if (insideNewButton) {
147
149
  _guidance += buttonGuidanceStr;
148
- } else if (size && size === 'medium') {
149
- _guidance += "Setting the spacing property to 'spacious' will maintain the icon's box dimensions - but consider setting spacing='none' as it allows for easier control of spacing by parent elements.\n";
150
+ } else if (size === 'medium') {
151
+ _guidance += "Setting the spacing='spacious' will maintain the icon's box dimensions - but consider setting spacing='none' as it allows for easier control of spacing by parent elements.\n";
152
+ } else if (size === 'small') {
153
+ if (initialSize !== 'small' && shouldForceSmallIcon) {
154
+ _guidance += "For this icon, it's recommended to use a smaller size using size='small'. Alternatively, for special cases where a larger version is needed size='medium' can be used, but it is generally discouraged for this icon.\n";
155
+ } else if (initialSize === 'small') {
156
+ if (shouldForceSmallIcon) {
157
+ _guidance += "Setting spacing='compact' will maintain the icon's box dimensions - but consider setting spacing='none' as it allows for easier control of spacing by parent elements.\n";
158
+ } else {
159
+ _guidance += "It's recommended to upscale to a medium icon with no spacing. Alternatively for special cases where smaller icons are required, the original icon size and dimensions can be maintained by using size='small' and spacing='compact'.\n";
160
+ }
161
+ }
150
162
  } else if (size) {
151
163
  _guidance += "In the new icon, please use spacing='none'.\n";
152
164
  }
@@ -270,7 +282,8 @@ export var createAutoMigrationError = function createAutoMigrationError(_ref4) {
270
282
  iconName = _ref4.iconName,
271
283
  errors = _ref4.errors,
272
284
  spacing = _ref4.spacing,
273
- insideNewButton = _ref4.insideNewButton;
285
+ insideNewButton = _ref4.insideNewButton,
286
+ shouldForceSmallIcon = _ref4.shouldForceSmallIcon;
274
287
  var myError = {
275
288
  node: node,
276
289
  messageId: 'noLegacyIconsAutoMigration',
@@ -279,7 +292,8 @@ export var createAutoMigrationError = function createAutoMigrationError(_ref4) {
279
292
  iconName: iconName,
280
293
  spacing: spacing !== null && spacing !== void 0 ? spacing : '',
281
294
  // value type need to be a string in Rule.ReportDescriptor
282
- insideNewButton: String(insideNewButton)
295
+ insideNewButton: String(insideNewButton),
296
+ shouldForceSmallIcon: String(shouldForceSmallIcon)
283
297
  }
284
298
  };
285
299
  errors[locToString(node)] = myError;
@@ -434,7 +448,7 @@ var getNewIconNameForRenaming = function getNewIconNameForRenaming(isInManualArr
434
448
  var newIconName;
435
449
  if (isInManualArray) {
436
450
  newIconName = getNewIconNameAndImportPath(importSource).iconName;
437
- var keyToName = newIconName ? newIconName[0].toUpperCase() + newIconName.slice(1) + 'Icon' : undefined;
451
+ var keyToName = newIconName ? getComponentName(newIconName) : undefined;
438
452
  newIconName = keyToName;
439
453
  if (newIconName === undefined || importSpecifier === keyToName) {
440
454
  newIconName = "".concat(keyToName, "New");
@@ -442,6 +456,11 @@ var getNewIconNameForRenaming = function getNewIconNameForRenaming(isInManualArr
442
456
  }
443
457
  return newIconName;
444
458
  };
459
+ export var getComponentName = function getComponentName(name) {
460
+ return name.split(/\W/).map(function (part) {
461
+ return "".concat(part[0].toUpperCase()).concat(part.slice(1));
462
+ }).join('').concat('Icon');
463
+ };
445
464
 
446
465
  /**
447
466
  *
@@ -507,7 +526,8 @@ var createPropFixes = function createPropFixes(_ref7) {
507
526
  migrationImportNode = _ref7.migrationImportNode,
508
527
  newIconName = _ref7.newIconName;
509
528
  var fixes = [];
510
- var spacing = metadata.spacing;
529
+ var spacing = metadata.spacing,
530
+ size = metadata.size;
511
531
  if (shouldUseMigrationPath && !legacyImportNode) {
512
532
  return fixes;
513
533
  }
@@ -523,24 +543,31 @@ var createPropFixes = function createPropFixes(_ref7) {
523
543
  if (primaryColor && primaryColor.type === 'JSXAttribute') {
524
544
  fixes.push(fixer.replaceText(primaryColor.name, 'color'));
525
545
  }
526
-
527
- // rename or remove size prop based on shouldUseMigrationPath,
528
- // add spacing="spacious" if
529
- // 1. it's in error metadata, which means size is medium
530
- // 2. no existing spacing prop
531
- // 3. iconType is "core"
532
- // 4. icon is not imported from migration entrypoint
533
546
  var sizeProp = findProp(attributes, 'size');
534
547
  var spacingProp = findProp(attributes, 'spacing');
535
- if (spacing && !spacingProp && !migrationImportNode) {
536
- fixes.push(fixer.insertTextAfter(sizeProp || openingElement.name, " spacing=\"".concat(spacing, "\"")));
537
- }
538
548
  if (sizeProp && sizeProp.type === 'JSXAttribute') {
539
- fixes.push(shouldUseMigrationPath ?
540
- // replace size prop with LEGACY_size,
541
- fixer.replaceText(sizeProp.name, 'LEGACY_size') :
542
- // remove size prop if shouldUseMigrationPath is false
543
- fixer.remove(sizeProp));
549
+ if (shouldUseMigrationPath) {
550
+ // Rename existing size prop to LEGACY_size and add new size prop if applicable
551
+ fixes.push(fixer.replaceText(sizeProp.name, 'LEGACY_size'));
552
+ if (size) {
553
+ fixes.push(fixer.insertTextAfter(sizeProp, " size=\"".concat(size, "\"")));
554
+ }
555
+ } else {
556
+ if (size && sizeProp.value) {
557
+ // update size prop with new replacement size
558
+ fixes.push(fixer.replaceText(sizeProp.value, "\"".concat(size, "\"")));
559
+ } else {
560
+ // remove size prop if no new replacement size is specified
561
+ fixes.push(fixer.remove(sizeProp));
562
+ }
563
+ }
564
+ } else if (size) {
565
+ fixes.push(fixer.insertTextAfter(openingElement.name, " size=\"".concat(size, "\"")));
566
+ }
567
+
568
+ // Add spacing prop if no existing spacing prop and icon is not imported from migration entrypoint
569
+ if (spacing && spacing !== 'none' && !spacingProp && !migrationImportNode) {
570
+ fixes.push(fixer.insertTextAfter(sizeProp || openingElement.name, " spacing=\"".concat(spacing, "\"")));
544
571
  }
545
572
 
546
573
  // rename or remove secondaryColor prop based on shouldUseMigrationPath
@@ -637,6 +664,7 @@ export var throwManualErrors = function throwManualErrors(_ref9) {
637
664
  export var throwAutoErrors = function throwAutoErrors(_ref10) {
638
665
  var errorsManual = _ref10.errorsManual,
639
666
  errorsAuto = _ref10.errorsAuto,
667
+ iconSizesInfo = _ref10.iconSizesInfo,
640
668
  legacyIconImports = _ref10.legacyIconImports,
641
669
  guidance = _ref10.guidance,
642
670
  migrationIconImports = _ref10.migrationIconImports,
@@ -692,7 +720,7 @@ export var throwAutoErrors = function throwAutoErrors(_ref10) {
692
720
  _step2;
693
721
  try {
694
722
  var _loop2 = function _loop2() {
695
- var _legacyIconImports$er, _legacyIconImports$er2, _migrationIconImports;
723
+ var _iconSizesInfo$import, _iconSizesInfo$import2, _iconSizesInfo$import3, _legacyIconImports$er, _error$data2, _legacyIconImports$er2, _migrationIconImports;
696
724
  var _step2$value = _slicedToArray(_step2.value, 2),
697
725
  _ = _step2$value[0],
698
726
  error = _step2$value[1];
@@ -702,8 +730,20 @@ export var throwAutoErrors = function throwAutoErrors(_ref10) {
702
730
  // If that is the case we'll need to provide a suggestion instead of auto-fixing as the suggestion will
703
731
  // add another import without removing the old import and this needs to be validated
704
732
  var isInManualArray = allManualErrorSources.has(importSource);
733
+
734
+ // Check if the icon has size of small, if so it cannot be automatically migrated. Two suggestions will be provided
735
+ // 1. Use core icon with no spacing
736
+ // 2. Use utility icon with compact spacing
737
+ var isSizeSmall = (_iconSizesInfo$import = iconSizesInfo[importSource]) === null || _iconSizesInfo$import === void 0 ? void 0 : _iconSizesInfo$import.small.includes(key);
738
+ var isMixedSizeUsage = ((_iconSizesInfo$import2 = iconSizesInfo[importSource]) === null || _iconSizesInfo$import2 === void 0 ? void 0 : _iconSizesInfo$import2.small.length) > 0 && ((_iconSizesInfo$import3 = iconSizesInfo[importSource]) === null || _iconSizesInfo$import3 === void 0 ? void 0 : _iconSizesInfo$import3.small.length) < iconSizesInfo[importSource].usageCount;
739
+
740
+ // Icon should be renamed
741
+ // 1. If the icon is in the manual array OR
742
+ // 2. If there is mixed size usages of this icon with size small
743
+ var shouldRenameIcon = isInManualArray || isMixedSizeUsage;
744
+
705
745
  // New icon name for renaming if the icon is in the manual array
706
- var newIconName = getNewIconNameForRenaming(isInManualArray, importSource, errorList[0].data ? (_legacyIconImports$er = legacyIconImports[errorList[0].data.iconName]) === null || _legacyIconImports$er === void 0 ? void 0 : _legacyIconImports$er.importSpecifier : undefined);
746
+ var newIconName = getNewIconNameForRenaming(shouldRenameIcon, importSource, errorList[0].data ? (_legacyIconImports$er = legacyIconImports[errorList[0].data.iconName]) === null || _legacyIconImports$er === void 0 ? void 0 : _legacyIconImports$er.importSpecifier : undefined);
707
747
  if (!node) {
708
748
  return 0; // continue
709
749
  }
@@ -711,22 +751,43 @@ export var throwAutoErrors = function throwAutoErrors(_ref10) {
711
751
  if (Object.keys(error).includes('data') && error.data) {
712
752
  error.data.guidance = guidanceMessage;
713
753
  }
754
+ var shouldForceSmallIcon = ((_error$data2 = error.data) === null || _error$data2 === void 0 ? void 0 : _error$data2.shouldForceSmallIcon) === 'true';
714
755
  var fixArguments = error.data ? {
715
- metadata: error.data,
756
+ metadata: _objectSpread(_objectSpread({}, error.data), {}, {
757
+ spacing: error.data.isInNewButton ? 'none' : error.data.spacing,
758
+ size: shouldForceSmallIcon ? 'small' : error.data.size
759
+ }),
716
760
  legacyImportNode: (_legacyIconImports$er2 = legacyIconImports[error.data.iconName]) === null || _legacyIconImports$er2 === void 0 ? void 0 : _legacyIconImports$er2.importNode,
717
761
  migrationImportNode: (_migrationIconImports = migrationIconImports[error.data.iconName]) === null || _migrationIconImports === void 0 ? void 0 : _migrationIconImports.importNode,
718
762
  shouldUseMigrationPath: shouldUseMigrationPath,
719
- newIconName: isInManualArray ? newIconName : undefined
763
+ newIconName: shouldRenameIcon ? newIconName : undefined
720
764
  } : null;
721
765
  if (!error.data || shouldUseMigrationPath && !checkIfNewIconExist(error) || !fixArguments) {
722
766
  return 0; // continue
723
767
  }
724
- if (isInManualArray) {
725
- // provide suggestion if there is a manual error for the same import source and thus the legacy import can't be removed
768
+ var isInNewButton = fixArguments.metadata.insideNewButton === 'true';
769
+ if (isSizeSmall && !shouldForceSmallIcon) {
726
770
  error.suggest = [{
727
- desc: 'Rename icon import, import from the new package, and update props.',
771
+ desc: isInNewButton ? 'Replace with medium core icon (Recommended)' : 'Replace with medium core icon and no spacing (Recommended)',
772
+ fix: function fix(fixer) {
773
+ return [].concat(_toConsumableArray(createPropFixes(_objectSpread(_objectSpread({}, fixArguments), {}, {
774
+ metadata: _objectSpread(_objectSpread({}, fixArguments.metadata), {}, {
775
+ spacing: 'none'
776
+ }),
777
+ node: node,
778
+ fixer: fixer
779
+ }))), _toConsumableArray(createImportFix(_objectSpread(_objectSpread({}, fixArguments), {}, {
780
+ fixer: fixer
781
+ }))));
782
+ }
783
+ }, {
784
+ desc: isInNewButton ? 'Replace with small core icon' : 'Replace with small core icon and compact spacing',
728
785
  fix: function fix(fixer) {
729
786
  return [].concat(_toConsumableArray(createPropFixes(_objectSpread(_objectSpread({}, fixArguments), {}, {
787
+ metadata: _objectSpread(_objectSpread({}, fixArguments.metadata), {}, {
788
+ spacing: 'compact',
789
+ size: 'small'
790
+ }),
730
791
  node: node,
731
792
  fixer: fixer
732
793
  }))), _toConsumableArray(createImportFix(_objectSpread(_objectSpread({}, fixArguments), {}, {
@@ -735,25 +796,40 @@ export var throwAutoErrors = function throwAutoErrors(_ref10) {
735
796
  }
736
797
  }];
737
798
  } else {
738
- // Update Guidance message for auto-fixing
739
- if (error.data) {
740
- error.data.guidance = error.data.guidance + "\nTo automatically fix this icon, run the auto-fixer attached to the first use of ".concat(importSource, " in this file - either manually, or by saving this file.");
741
- }
742
- // There should only be 1 import fix for each import source and thus only add this at the start of the list
743
- if (autoFixers.length === 0) {
799
+ if (isInManualArray) {
800
+ // provide suggestion if there is a manual error for the same import source and thus the legacy import can't be removed
801
+ error.suggest = [{
802
+ desc: 'Rename icon import, import from the new package, and update props.',
803
+ fix: function fix(fixer) {
804
+ return [].concat(_toConsumableArray(createPropFixes(_objectSpread(_objectSpread({}, fixArguments), {}, {
805
+ node: node,
806
+ fixer: fixer
807
+ }))), _toConsumableArray(createImportFix(_objectSpread(_objectSpread({}, fixArguments), {}, {
808
+ fixer: fixer
809
+ }))));
810
+ }
811
+ }];
812
+ } else {
813
+ // Update Guidance message for auto-fixing
814
+ if (error.data) {
815
+ error.data.guidance = error.data.guidance + "\nTo automatically fix this icon, run the auto-fixer attached to the first use of ".concat(importSource, " in this file - either manually, or by saving this file.");
816
+ }
817
+ // There should only be 1 import fix for each import source and thus only add this at the start of the list
818
+ if (autoFixers.length === 0) {
819
+ autoFixers.push(function (fixer) {
820
+ return createImportFix(_objectSpread(_objectSpread({}, fixArguments), {}, {
821
+ fixer: fixer
822
+ }));
823
+ });
824
+ }
825
+ // Push the prop fix regardless
744
826
  autoFixers.push(function (fixer) {
745
- return createImportFix(_objectSpread(_objectSpread({}, fixArguments), {}, {
827
+ return createPropFixes(_objectSpread(_objectSpread({}, fixArguments), {}, {
828
+ node: node,
746
829
  fixer: fixer
747
830
  }));
748
831
  });
749
832
  }
750
- // Push the prop fix regardless
751
- autoFixers.push(function (fixer) {
752
- return createPropFixes(_objectSpread(_objectSpread({}, fixArguments), {}, {
753
- node: node,
754
- fixer: fixer
755
- }));
756
- });
757
833
  }
758
834
  // Add the error to the appliedErrorsForImport, ready to be thrown later
759
835
  appliedErrorsForImport.push(error);
@@ -3,14 +3,14 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
3
3
  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; }
4
4
  import fs from 'fs';
5
5
  import path from 'path';
6
- import { deprecatedCore as deprecatedIconLabCore } from '@atlaskit/icon-lab/deprecated-map';
6
+ import { deprecatedCore as deprecatedIconLabCore, deprecatedUtility as deprecatedIconLabUtility } from '@atlaskit/icon-lab/deprecated-map';
7
7
  import { deprecatedCore as deprecatedIconCore, deprecatedUtility as deprecatedIconUtility } from '@atlaskit/icon/deprecated-map';
8
8
  export var getConfig = function getConfig(specifier) {
9
9
  var configPath = path.resolve(__dirname, '..', '..', '..', 'configs', 'deprecated.json');
10
10
  var source = fs.readFileSync(configPath, 'utf8');
11
11
  var parsedConfig = JSON.parse(source);
12
12
  var combinedConfig = _objectSpread(_objectSpread({}, parsedConfig), {}, {
13
- imports: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, parsedConfig.imports), deprecatedIconCore), deprecatedIconUtility), deprecatedIconLabCore)
13
+ imports: _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, parsedConfig.imports), deprecatedIconCore), deprecatedIconUtility), deprecatedIconLabCore), deprecatedIconLabUtility)
14
14
  });
15
15
  return combinedConfig[specifier];
16
16
  };
@@ -49,6 +49,7 @@ export declare const getMigrationMapObject: (iconPackage: string) => {
49
49
  type: string;
50
50
  package: string;
51
51
  isMigrationUnsafe?: boolean | undefined;
52
+ shouldForceSmallIcon?: boolean | undefined;
52
53
  } | undefined;
53
54
  additionalIcons?: {
54
55
  name: string;
@@ -63,15 +64,16 @@ export declare const getUpcomingIcons: (iconPackage: string) => {
63
64
  /**
64
65
  * Checks if a new icon can be auto-migrated based on guidance from the migration map
65
66
  */
66
- export declare const canAutoMigrateNewIconBasedOnSize: (guidance?: string) => boolean;
67
+ export declare const canAutoMigrateNewIconBasedOnSize: (guidance?: IconMigrationSizeGuidance) => boolean;
67
68
  /**
68
69
  * Creates the written guidance for migrating a legacy icon to a new icon
69
70
  */
70
- export declare const createGuidance: ({ iconPackage, insideNewButton, size, shouldUseMigrationPath, }: {
71
+ export declare const createGuidance: ({ iconPackage, insideNewButton, size: initialSize, shouldUseMigrationPath, shouldForceSmallIcon, }: {
71
72
  iconPackage: string;
72
73
  insideNewButton?: boolean | undefined;
73
74
  size?: "small" | "medium" | "large" | "xlarge" | undefined;
74
75
  shouldUseMigrationPath?: boolean | undefined;
76
+ shouldForceSmallIcon?: boolean | undefined;
75
77
  }) => string;
76
78
  /**
77
79
  * Checks if the color can be migrated
@@ -88,13 +90,14 @@ export declare const createCantMigrateFunctionUnknownError: (node: Node, importS
88
90
  export declare const createCantMigrateColorError: (node: Node, colorValue: string, errors: ErrorListManual, importSource: string, iconName: string) => void;
89
91
  export declare const createCantMigrateSpreadPropsError: (node: Node, missingProps: string[], errors: ErrorListManual, importSource: string, iconName: string) => void;
90
92
  export declare const createCantMigrateSizeUnknown: (node: Node, errors: ErrorListManual, importSource: string, iconName: string) => void;
91
- export declare const createAutoMigrationError: ({ node, importSource, iconName, errors, spacing, insideNewButton, }: {
93
+ export declare const createAutoMigrationError: ({ node, importSource, iconName, errors, spacing, insideNewButton, shouldForceSmallIcon, }: {
92
94
  node: Node;
93
95
  importSource: string;
94
96
  iconName: string;
95
97
  errors: ErrorListAuto;
96
98
  spacing?: string | undefined;
97
99
  insideNewButton?: boolean | undefined;
100
+ shouldForceSmallIcon?: boolean | undefined;
98
101
  }) => void;
99
102
  export declare const createHelpers: (ctx: Rule.RuleContext) => {
100
103
  /**
@@ -126,6 +129,7 @@ export declare const isInsideLegacyButton: (node: Rule.Node, legacyButtonImports
126
129
  * @returns if Icon is inside a legacy button
127
130
  */
128
131
  export declare const isInsideIconOnlyLegacyButton: (node: Rule.Node, legacyButtonImports: Set<string>) => boolean;
132
+ export declare const getComponentName: (name: string) => string;
129
133
  export declare const throwManualErrors: ({ errorsManual, errorRanges, guidance, context, isQuietMode, }: {
130
134
  errorsManual: ErrorListManual;
131
135
  errorRanges: RangeList;
@@ -133,9 +137,13 @@ export declare const throwManualErrors: ({ errorsManual, errorRanges, guidance,
133
137
  context: Rule.RuleContext;
134
138
  isQuietMode: boolean;
135
139
  }) => void;
136
- export declare const throwAutoErrors: ({ errorsManual, errorsAuto, legacyIconImports, guidance, migrationIconImports, shouldUseMigrationPath, context, }: {
140
+ export declare const throwAutoErrors: ({ errorsManual, errorsAuto, iconSizesInfo, legacyIconImports, guidance, migrationIconImports, shouldUseMigrationPath, context, }: {
137
141
  errorsManual: ErrorListManual;
138
142
  errorsAuto: ErrorListAuto;
143
+ iconSizesInfo: Record<string, {
144
+ small: string[];
145
+ usageCount: number;
146
+ }>;
139
147
  legacyIconImports: LegacyIconImportList;
140
148
  guidance: GuidanceList;
141
149
  migrationIconImports: MigrationIconImportList;
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { Property } from 'eslint-codemod-utils';
2
+ import { type Property } from 'eslint-codemod-utils';
3
3
  import { type RuleConfig } from '../config';
4
4
  interface MetaData {
5
5
  context: Rule.RuleContext;
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { Property } from 'eslint-codemod-utils';
2
+ import { type Property } from 'eslint-codemod-utils';
3
3
  import { type RuleConfig } from '../config';
4
4
  interface MetaData {
5
5
  context: Rule.RuleContext;
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { Property } from 'eslint-codemod-utils';
2
+ import { type Property } from 'eslint-codemod-utils';
3
3
  import { type RuleConfig } from '../config';
4
4
  interface MetaData {
5
5
  context: Rule.RuleContext;
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { Property } from 'eslint-codemod-utils';
2
+ import { type Property } from 'eslint-codemod-utils';
3
3
  import { type RuleConfig } from '../config';
4
4
  interface MetaData {
5
5
  context: Rule.RuleContext;
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { Property } from 'eslint-codemod-utils';
2
+ import { type Property } from 'eslint-codemod-utils';
3
3
  import { type RuleConfig } from '../config';
4
4
  interface MetaData {
5
5
  context: Rule.RuleContext;
@@ -54,6 +54,7 @@ export declare const getMigrationMapObject: (iconPackage: string) => {
54
54
  type: string;
55
55
  package: string;
56
56
  isMigrationUnsafe?: boolean | undefined;
57
+ shouldForceSmallIcon?: boolean | undefined;
57
58
  } | undefined;
58
59
  additionalIcons?: {
59
60
  name: string;
@@ -68,15 +69,16 @@ export declare const getUpcomingIcons: (iconPackage: string) => {
68
69
  /**
69
70
  * Checks if a new icon can be auto-migrated based on guidance from the migration map
70
71
  */
71
- export declare const canAutoMigrateNewIconBasedOnSize: (guidance?: string) => boolean;
72
+ export declare const canAutoMigrateNewIconBasedOnSize: (guidance?: IconMigrationSizeGuidance) => boolean;
72
73
  /**
73
74
  * Creates the written guidance for migrating a legacy icon to a new icon
74
75
  */
75
- export declare const createGuidance: ({ iconPackage, insideNewButton, size, shouldUseMigrationPath, }: {
76
+ export declare const createGuidance: ({ iconPackage, insideNewButton, size: initialSize, shouldUseMigrationPath, shouldForceSmallIcon, }: {
76
77
  iconPackage: string;
77
78
  insideNewButton?: boolean | undefined;
78
79
  size?: "small" | "medium" | "large" | "xlarge" | undefined;
79
80
  shouldUseMigrationPath?: boolean | undefined;
81
+ shouldForceSmallIcon?: boolean | undefined;
80
82
  }) => string;
81
83
  /**
82
84
  * Checks if the color can be migrated
@@ -93,13 +95,14 @@ export declare const createCantMigrateFunctionUnknownError: (node: Node, importS
93
95
  export declare const createCantMigrateColorError: (node: Node, colorValue: string, errors: ErrorListManual, importSource: string, iconName: string) => void;
94
96
  export declare const createCantMigrateSpreadPropsError: (node: Node, missingProps: string[], errors: ErrorListManual, importSource: string, iconName: string) => void;
95
97
  export declare const createCantMigrateSizeUnknown: (node: Node, errors: ErrorListManual, importSource: string, iconName: string) => void;
96
- export declare const createAutoMigrationError: ({ node, importSource, iconName, errors, spacing, insideNewButton, }: {
98
+ export declare const createAutoMigrationError: ({ node, importSource, iconName, errors, spacing, insideNewButton, shouldForceSmallIcon, }: {
97
99
  node: Node;
98
100
  importSource: string;
99
101
  iconName: string;
100
102
  errors: ErrorListAuto;
101
103
  spacing?: string | undefined;
102
104
  insideNewButton?: boolean | undefined;
105
+ shouldForceSmallIcon?: boolean | undefined;
103
106
  }) => void;
104
107
  export declare const createHelpers: (ctx: Rule.RuleContext) => {
105
108
  /**
@@ -131,6 +134,7 @@ export declare const isInsideLegacyButton: (node: Rule.Node, legacyButtonImports
131
134
  * @returns if Icon is inside a legacy button
132
135
  */
133
136
  export declare const isInsideIconOnlyLegacyButton: (node: Rule.Node, legacyButtonImports: Set<string>) => boolean;
137
+ export declare const getComponentName: (name: string) => string;
134
138
  export declare const throwManualErrors: ({ errorsManual, errorRanges, guidance, context, isQuietMode, }: {
135
139
  errorsManual: ErrorListManual;
136
140
  errorRanges: RangeList;
@@ -138,9 +142,13 @@ export declare const throwManualErrors: ({ errorsManual, errorRanges, guidance,
138
142
  context: Rule.RuleContext;
139
143
  isQuietMode: boolean;
140
144
  }) => void;
141
- export declare const throwAutoErrors: ({ errorsManual, errorsAuto, legacyIconImports, guidance, migrationIconImports, shouldUseMigrationPath, context, }: {
145
+ export declare const throwAutoErrors: ({ errorsManual, errorsAuto, iconSizesInfo, legacyIconImports, guidance, migrationIconImports, shouldUseMigrationPath, context, }: {
142
146
  errorsManual: ErrorListManual;
143
147
  errorsAuto: ErrorListAuto;
148
+ iconSizesInfo: Record<string, {
149
+ small: string[];
150
+ usageCount: number;
151
+ }>;
144
152
  legacyIconImports: LegacyIconImportList;
145
153
  guidance: GuidanceList;
146
154
  migrationIconImports: MigrationIconImportList;
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { Property } from 'eslint-codemod-utils';
2
+ import { type Property } from 'eslint-codemod-utils';
3
3
  import { type RuleConfig } from '../config';
4
4
  interface MetaData {
5
5
  context: Rule.RuleContext;
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { Property } from 'eslint-codemod-utils';
2
+ import { type Property } from 'eslint-codemod-utils';
3
3
  import { type RuleConfig } from '../config';
4
4
  interface MetaData {
5
5
  context: Rule.RuleContext;
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { Property } from 'eslint-codemod-utils';
2
+ import { type Property } from 'eslint-codemod-utils';
3
3
  import { type RuleConfig } from '../config';
4
4
  interface MetaData {
5
5
  context: Rule.RuleContext;
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { Property } from 'eslint-codemod-utils';
2
+ import { type Property } from 'eslint-codemod-utils';
3
3
  import { type RuleConfig } from '../config';
4
4
  interface MetaData {
5
5
  context: Rule.RuleContext;
@@ -1,5 +1,5 @@
1
1
  import type { Rule } from 'eslint';
2
- import { Property } from 'eslint-codemod-utils';
2
+ import { type Property } from 'eslint-codemod-utils';
3
3
  import { type RuleConfig } from '../config';
4
4
  interface MetaData {
5
5
  context: Rule.RuleContext;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-design-system",
3
3
  "description": "The essential plugin for use with the Atlassian Design System.",
4
- "version": "13.14.2",
4
+ "version": "13.15.0",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
7
7
  "publishConfig": {
@@ -44,9 +44,9 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@atlaskit/eslint-utils": "^2.0.0",
47
- "@atlaskit/icon": "^26.0.0",
48
- "@atlaskit/icon-lab": "^4.12.0",
49
- "@atlaskit/tokens": "^4.8.0",
47
+ "@atlaskit/icon": "^26.1.0",
48
+ "@atlaskit/icon-lab": "^4.13.0",
49
+ "@atlaskit/tokens": "^4.9.0",
50
50
  "@babel/runtime": "^7.0.0",
51
51
  "@typescript-eslint/utils": "^7.1.0",
52
52
  "ajv": "^6.12.6",