@atlaskit/eslint-plugin-design-system 15.0.0 → 15.1.1

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.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::4cd2dfd73ed3cdd152ee6481087c49ee>>
3
+ * @codegen <<SignedSource::eb0cc6324a0dfa4a3a11b16ab0a6cd4f>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -81,6 +81,7 @@ var rules = {
81
81
  '@atlaskit/design-system/use-spotlight-package': 'warn',
82
82
  '@atlaskit/design-system/use-tag-group-label': 'warn',
83
83
  '@atlaskit/design-system/use-textfield-autocomplete': 'warn',
84
+ '@atlaskit/design-system/use-tokens-motion': 'warn',
84
85
  '@atlaskit/design-system/use-tokens-shape': 'error',
85
86
  '@atlaskit/design-system/use-tokens-space': 'error',
86
87
  '@atlaskit/design-system/use-tokens-typography': 'warn',
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::8efae2c2e169f84381b978b4bc47433d>>
3
+ * @codegen <<SignedSource::80cbd12c57061c4fb2660da2e808210f>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -80,6 +80,7 @@ var rules = {
80
80
  '@atlaskit/design-system/use-spotlight-package': 'warn',
81
81
  '@atlaskit/design-system/use-tag-group-label': 'warn',
82
82
  '@atlaskit/design-system/use-textfield-autocomplete': 'warn',
83
+ '@atlaskit/design-system/use-tokens-motion': 'warn',
83
84
  '@atlaskit/design-system/use-tokens-shape': 'error',
84
85
  '@atlaskit/design-system/use-tokens-space': 'error',
85
86
  '@atlaskit/design-system/use-tokens-typography': 'warn',
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::b90bcf0b2fb6429faae59c7a454e3260>>
3
+ * @codegen <<SignedSource::d404a0bd62a78d4bad7ee376df0bd475>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -78,6 +78,7 @@ import useSimpleForm from './use-simple-form';
78
78
  import useSpotlightPackage from './use-spotlight-package';
79
79
  import useTagGroupLabel from './use-tag-group-label';
80
80
  import useTextfieldAutocomplete from './use-textfield-autocomplete';
81
+ import useTokensMotion from './use-tokens-motion';
81
82
  import useTokensShape from './use-tokens-shape';
82
83
  import useTokensSpace from './use-tokens-space';
83
84
  import useTokensTypography from './use-tokens-typography';
@@ -157,6 +158,7 @@ export var rules = {
157
158
  'use-spotlight-package': useSpotlightPackage,
158
159
  'use-tag-group-label': useTagGroupLabel,
159
160
  'use-textfield-autocomplete': useTextfieldAutocomplete,
161
+ 'use-tokens-motion': useTokensMotion,
160
162
  'use-tokens-shape': useTokensShape,
161
163
  'use-tokens-space': useTokensSpace,
162
164
  'use-tokens-typography': useTokensTypography,
@@ -15,9 +15,7 @@ var rule = createLintRule({
15
15
  },
16
16
  messages: {
17
17
  updateAppearance: 'Update appearance value to new semantic value.',
18
- migrateTag: 'Non-bold <Lozenge> variants should migrate to <Tag> component. For safe, staged rollout, use the `migration_fallback="lozenge"` prop which renders as Lozenge when the feature flag is off.',
19
- manualReview: "Dynamic 'isBold' props require manual review before migration.",
20
- dynamicLozengeAppearance: "Dynamic 'appearance' prop values require manual review before migrating to Tag. Please verify the appearance value and manually convert it to the appropriate color prop value.",
18
+ migrateTag: '<SimpleTag> and <RemovableTag> components should migrate to the new <Tag> or <AvatarTag> component.',
21
19
  updateBadgeAppearance: 'Update Badge appearance value "{{oldValue}}" to new semantic value "{{newValue}}".',
22
20
  dynamicBadgeAppearance: 'Dynamic appearance prop values require manual review to ensure they use the new semantic values: neutral, information, inverse, danger, success.'
23
21
  }
@@ -63,13 +61,6 @@ var rule = createLintRule({
63
61
  */
64
62
  var newTagImports = {};
65
63
 
66
- /**
67
- * Check if a JSX attribute value is a literal false
68
- */
69
- function isLiteralFalse(node) {
70
- return node && node.type === 'JSXExpressionContainer' && node.expression && node.expression.type === 'Literal' && node.expression.value === false;
71
- }
72
-
73
64
  /**
74
65
  * Check if a JSX attribute value is dynamic (not a static literal value)
75
66
  * Can be used for any prop type (boolean, string, etc.)
@@ -106,37 +97,22 @@ var rule = createLintRule({
106
97
  }
107
98
 
108
99
  /**
109
- * Map old appearance values to new semantic appearance values
110
- * Both Lozenge and Tag now use the same appearance prop with new semantic values
100
+ * Map old Lozenge appearance values to new semantic appearance values.
101
+ * The new Lozenge no longer uses legacy values it uses semantic color names
102
+ * that align with the new labelling system.
111
103
  */
112
104
  function mapToNewAppearanceValue(oldValue) {
113
105
  var mapping = {
114
- success: 'success',
115
- default: 'default',
116
- removed: 'removed',
117
- inprogress: 'inprogress',
118
- new: 'new',
119
- moved: 'moved'
106
+ default: 'neutral',
107
+ inprogress: 'information',
108
+ moved: 'warning',
109
+ removed: 'danger',
110
+ new: 'discovery',
111
+ success: 'success'
120
112
  };
121
113
  return mapping[oldValue] || oldValue;
122
114
  }
123
115
 
124
- /**
125
- * Map Lozenge appearance values to Tag color values
126
- * Used when migrating Lozenge to Tag component
127
- */
128
- function mapLozengeAppearanceToTagColor(appearanceValue) {
129
- var mapping = {
130
- success: 'lime',
131
- default: 'gray',
132
- removed: 'red',
133
- inprogress: 'blue',
134
- new: 'purple',
135
- moved: 'yellow'
136
- };
137
- return mapping[appearanceValue] || appearanceValue;
138
- }
139
-
140
116
  /**
141
117
  * Map Badge old appearance values to new semantic appearance values
142
118
  */
@@ -262,7 +238,7 @@ var rule = createLintRule({
262
238
 
263
239
  /**
264
240
  * Generate the replacement JSX element text for Tag migration
265
- * Handles both regular Tag and avatarTag migrations
241
+ * Handles both regular Tag and AvatarTag migrations for SimpleTag/RemovableTag.
266
242
  */
267
243
  function generateTagReplacement(node) {
268
244
  var _context$sourceCode;
@@ -281,20 +257,7 @@ var rule = createLintRule({
281
257
  return;
282
258
  }
283
259
  if (attrName === 'appearance') {
284
- // For Lozenge migrations, convert appearance to color prop
285
- // For SimpleTag/RemovableTag migrations, delete appearance prop
286
- if (options.isLozengeMigration) {
287
- // Map Lozenge appearance value to Tag color value and change prop name from appearance to color
288
- var stringValue = extractStringValue(attr.value);
289
- if (stringValue && typeof stringValue === 'string') {
290
- var mappedColor = mapLozengeAppearanceToTagColor(stringValue);
291
- newAttributes.push("color=\"".concat(mappedColor, "\""));
292
- }
293
- // If we can't extract the string value (dynamic expression), skip it
294
- // Dynamic expressions should be caught earlier and require manual review
295
- // This code path shouldn't be reached, but we skip to be safe
296
- }
297
- // For SimpleTag/RemovableTag migrations, skip appearance prop (delete it)
260
+ // Delete appearance prop not used in new Tag/AvatarTag API
298
261
  return;
299
262
  }
300
263
  if (attrName === 'color') {
@@ -303,10 +266,10 @@ var rule = createLintRule({
303
266
  if (options.isAvatarTag) {
304
267
  return;
305
268
  }
306
- var _stringValue = extractStringValue(attr.value);
307
- if (_stringValue && typeof _stringValue === 'string') {
308
- var _mappedColor = mapTagColorValue(_stringValue);
309
- newAttributes.push("color=\"".concat(_mappedColor, "\""));
269
+ var stringValue = extractStringValue(attr.value);
270
+ if (stringValue && typeof stringValue === 'string') {
271
+ var mappedColor = mapTagColorValue(stringValue);
272
+ newAttributes.push("color=\"".concat(mappedColor, "\""));
310
273
  } else {
311
274
  // If we can't extract the string value, keep as-is
312
275
  var value = attr.value ? sourceCode.getText(attr.value) : '';
@@ -356,15 +319,10 @@ var rule = createLintRule({
356
319
  }
357
320
  });
358
321
 
359
- // Add isRemovable={false} for SimpleTag migrations and Lozenge migrations
360
- if (options.isSimpleTag || options.isLozengeMigration) {
322
+ // Add isRemovable={false} for SimpleTag migrations
323
+ if (options.isSimpleTag) {
361
324
  newAttributes.push('isRemovable={false}');
362
325
  }
363
-
364
- // Add migration_fallback="lozenge" for Lozenge migrations to enable safe staged rollout
365
- if (options.isLozengeMigration) {
366
- newAttributes.push('migration_fallback="lozenge"');
367
- }
368
326
  var attributesText = newAttributes.length > 0 ? " ".concat(newAttributes.join(' ')) : '';
369
327
  var children = node.children.length > 0 ? sourceCode.getText().slice(node.openingElement.range[1], node.closingElement ? node.closingElement.range[0] : node.range[1]) : '';
370
328
  var componentName = options.preserveComponentName ? node.openingElement.name.name : options.isAvatarTag ? 'AvatarTag' : 'Tag';
@@ -635,77 +593,22 @@ var rule = createLintRule({
635
593
  }
636
594
  var attributesMap = getAttributesMap(node.openingElement.attributes);
637
595
  var appearanceProp = attributesMap.appearance;
638
- var isBoldProp = attributesMap.isBold;
639
596
 
640
- // Handle appearance prop value migration
597
+ // Handle appearance prop value migration — always update to new semantic values.
598
+ // isBold is intentionally not flagged: users may still need it while the feature flag
599
+ // platform-dst-lozenge-tag-badge-visual-uplifts is OFF (subtle variant still rendered).
641
600
  if (appearanceProp) {
642
- var shouldMigrateToTag = !isBoldProp || isLiteralFalse(isBoldProp.value);
643
- if (!shouldMigrateToTag) {
644
- // Only update appearance values for Lozenge components that stay as Lozenge
645
- var _stringValue2 = extractStringValue(appearanceProp.value);
646
- if (_stringValue2 && typeof _stringValue2 === 'string') {
647
- var _mappedValue = mapToNewAppearanceValue(_stringValue2);
648
- if (_mappedValue !== _stringValue2) {
649
- context.report({
650
- node: appearanceProp,
651
- messageId: 'updateAppearance',
652
- fix: createAppearanceFixer(appearanceProp.value, _mappedValue)
653
- });
654
- }
655
- }
656
- }
657
- }
658
-
659
- // Handle isBold prop and Tag migration
660
- if (isBoldProp) {
661
- if (isLiteralFalse(isBoldProp.value)) {
662
- // isBold={false} should migrate to Tag
663
- // Check if appearance is dynamic - if so, require manual review
664
- if (appearanceProp && isDynamicExpression(appearanceProp.value)) {
601
+ var _stringValue = extractStringValue(appearanceProp.value);
602
+ if (_stringValue && typeof _stringValue === 'string') {
603
+ var _mappedValue = mapToNewAppearanceValue(_stringValue);
604
+ if (_mappedValue !== _stringValue) {
665
605
  context.report({
666
606
  node: appearanceProp,
667
- messageId: 'dynamicLozengeAppearance'
607
+ messageId: 'updateAppearance',
608
+ fix: createAppearanceFixer(appearanceProp.value, _mappedValue)
668
609
  });
669
- return;
670
610
  }
671
- context.report({
672
- node: node,
673
- messageId: 'migrateTag',
674
- fix: function fix(fixer) {
675
- var replacement = generateTagReplacement(node, {
676
- isLozengeMigration: true
677
- });
678
- return fixer.replaceText(node, replacement);
679
- }
680
- });
681
- } else if (isDynamicExpression(isBoldProp.value)) {
682
- // Dynamic isBold requires manual review
683
- context.report({
684
- node: isBoldProp,
685
- messageId: 'manualReview'
686
- });
687
611
  }
688
- // isBold={true} or isBold (implicit true) - no action needed
689
- } else {
690
- // No isBold prop means implicit false, should migrate to Tag
691
- // Check if appearance is dynamic - if so, require manual review
692
- if (appearanceProp && isDynamicExpression(appearanceProp.value)) {
693
- context.report({
694
- node: appearanceProp,
695
- messageId: 'dynamicLozengeAppearance'
696
- });
697
- return;
698
- }
699
- context.report({
700
- node: node,
701
- messageId: 'migrateTag',
702
- fix: function fix(fixer) {
703
- var replacement = generateTagReplacement(node, {
704
- isLozengeMigration: true
705
- });
706
- return fixer.replaceText(node, replacement);
707
- }
708
- });
709
612
  }
710
613
  }
711
614
  };