@atlaskit/eslint-plugin-design-system 13.23.4 → 13.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.
Files changed (33) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +1 -0
  3. package/dist/cjs/presets/all-flat.codegen.js +2 -1
  4. package/dist/cjs/presets/all.codegen.js +2 -1
  5. package/dist/cjs/presets/recommended-flat.codegen.js +2 -1
  6. package/dist/cjs/presets/recommended.codegen.js +2 -1
  7. package/dist/cjs/rules/index.codegen.js +3 -1
  8. package/dist/cjs/rules/lozenge-appearance-and-isbold-migration/index.js +267 -0
  9. package/dist/es2019/presets/all-flat.codegen.js +2 -1
  10. package/dist/es2019/presets/all.codegen.js +2 -1
  11. package/dist/es2019/presets/recommended-flat.codegen.js +2 -1
  12. package/dist/es2019/presets/recommended.codegen.js +2 -1
  13. package/dist/es2019/rules/index.codegen.js +3 -1
  14. package/dist/es2019/rules/lozenge-appearance-and-isbold-migration/index.js +261 -0
  15. package/dist/esm/presets/all-flat.codegen.js +2 -1
  16. package/dist/esm/presets/all.codegen.js +2 -1
  17. package/dist/esm/presets/recommended-flat.codegen.js +2 -1
  18. package/dist/esm/presets/recommended.codegen.js +2 -1
  19. package/dist/esm/rules/index.codegen.js +3 -1
  20. package/dist/esm/rules/lozenge-appearance-and-isbold-migration/index.js +261 -0
  21. package/dist/types/presets/all-flat.codegen.d.ts +1 -1
  22. package/dist/types/presets/all.codegen.d.ts +1 -1
  23. package/dist/types/presets/recommended-flat.codegen.d.ts +1 -1
  24. package/dist/types/presets/recommended.codegen.d.ts +1 -1
  25. package/dist/types/rules/index.codegen.d.ts +1 -1
  26. package/dist/types/rules/lozenge-appearance-and-isbold-migration/index.d.ts +2 -0
  27. package/dist/types-ts4.5/presets/all-flat.codegen.d.ts +1 -1
  28. package/dist/types-ts4.5/presets/all.codegen.d.ts +1 -1
  29. package/dist/types-ts4.5/presets/recommended-flat.codegen.d.ts +1 -1
  30. package/dist/types-ts4.5/presets/recommended.codegen.d.ts +1 -1
  31. package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -1
  32. package/dist/types-ts4.5/rules/lozenge-appearance-and-isbold-migration/index.d.ts +2 -0
  33. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/eslint-plugin-design-system
2
2
 
3
+ ## 13.24.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`6346354ff2153`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/6346354ff2153) -
8
+ Add a new rule `lozenge-appearance-and-isbold-migration` to help migrate deprecated Lozenge usages
9
+ to the new API or Tag component as part of the Labelling System Phase 1 migration
10
+
3
11
  ## 13.23.4
4
12
 
5
13
  ### Patch Changes
package/README.md CHANGED
@@ -56,6 +56,7 @@ module.exports = {
56
56
  | <a href="./packages/design-system/eslint-plugin/src/rules/ensure-icon-color/README.md">ensure-icon-color</a> | Enforces that upcoming icon components have a color prop set, to enable a migration of the default value. | | | |
57
57
  | <a href="./packages/design-system/eslint-plugin/src/rules/ensure-proper-xcss-usage/README.md">ensure-proper-xcss-usage</a> | Enforces proper xcss usage: migrate from xcss() to cssMap() and use cssMap objects with specific keys. | | | |
58
58
  | <a href="./packages/design-system/eslint-plugin/src/rules/icon-label/README.md">icon-label</a> | Enforces accessible usage of icon labels when composed with Atlassian Design System components. | Yes | Yes | |
59
+ | <a href="./packages/design-system/eslint-plugin/src/rules/lozenge-appearance-and-isbold-migration/README.md">lozenge-appearance-and-isbold-migration</a> | Helps migrate deprecated Lozenge usages to the new API or Tag component as part of the Labelling System Phase 1 migration. | Yes | Yes | |
59
60
  | <a href="./packages/design-system/eslint-plugin/src/rules/no-banned-imports/README.md">no-banned-imports</a> | Disallow importing banned modules. | Yes | | |
60
61
  | <a href="./packages/design-system/eslint-plugin/src/rules/no-boolean-autofocus-on-modal-dialog/README.md">no-boolean-autofocus-on-modal-dialog</a> | Encourages makers to not use boolean values for `autoFocus` on Atlassian Design System's modal dialog component. | Yes | | |
61
62
  | <a href="./packages/design-system/eslint-plugin/src/rules/no-css-tagged-template-expression/README.md">no-css-tagged-template-expression</a> | Disallows any `css` tagged template expressions that originate from Emotion, Styled Components or Compiled | | Yes | |
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  /**
8
8
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
9
- * @codegen <<SignedSource::5aac2d8dc7c2832bcb8a96a143d60db5>>
9
+ * @codegen <<SignedSource::7fae089db9d7d7153fea58c673bd56af>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
11
11
  */
12
12
 
@@ -21,6 +21,7 @@ var rules = {
21
21
  '@atlaskit/design-system/ensure-icon-color': 'error',
22
22
  '@atlaskit/design-system/ensure-proper-xcss-usage': 'error',
23
23
  '@atlaskit/design-system/icon-label': 'warn',
24
+ '@atlaskit/design-system/lozenge-appearance-and-isbold-migration': 'warn',
24
25
  '@atlaskit/design-system/no-banned-imports': 'error',
25
26
  '@atlaskit/design-system/no-boolean-autofocus-on-modal-dialog': 'warn',
26
27
  '@atlaskit/design-system/no-css-tagged-template-expression': 'error',
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  /**
8
8
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
9
- * @codegen <<SignedSource::43ea4411c4e338a916772d4bfda146cc>>
9
+ * @codegen <<SignedSource::655d7f24171da0dff60003d0f235e48a>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
11
11
  */
12
12
 
@@ -20,6 +20,7 @@ var rules = {
20
20
  '@atlaskit/design-system/ensure-icon-color': 'error',
21
21
  '@atlaskit/design-system/ensure-proper-xcss-usage': 'error',
22
22
  '@atlaskit/design-system/icon-label': 'warn',
23
+ '@atlaskit/design-system/lozenge-appearance-and-isbold-migration': 'warn',
23
24
  '@atlaskit/design-system/no-banned-imports': 'error',
24
25
  '@atlaskit/design-system/no-boolean-autofocus-on-modal-dialog': 'warn',
25
26
  '@atlaskit/design-system/no-css-tagged-template-expression': 'error',
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  /**
8
8
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
9
- * @codegen <<SignedSource::3328b9c675a0d09876dcfbc5d29bc63f>>
9
+ * @codegen <<SignedSource::44a03b30a12e3b52d720c16785c9c649>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
11
11
  */
12
12
 
@@ -17,6 +17,7 @@ var rules = {
17
17
  '@atlaskit/design-system/consistent-css-prop-usage': 'error',
18
18
  '@atlaskit/design-system/ensure-design-token-usage': 'error',
19
19
  '@atlaskit/design-system/icon-label': 'warn',
20
+ '@atlaskit/design-system/lozenge-appearance-and-isbold-migration': 'warn',
20
21
  '@atlaskit/design-system/no-banned-imports': 'error',
21
22
  '@atlaskit/design-system/no-boolean-autofocus-on-modal-dialog': 'warn',
22
23
  '@atlaskit/design-system/no-deprecated-apis': 'error',
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  /**
8
8
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
9
- * @codegen <<SignedSource::b28f895280627b7a35f059f90783644a>>
9
+ * @codegen <<SignedSource::0311febdad396820af1b01dd2825b63f>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
11
11
  */
12
12
 
@@ -16,6 +16,7 @@ var rules = {
16
16
  '@atlaskit/design-system/consistent-css-prop-usage': 'error',
17
17
  '@atlaskit/design-system/ensure-design-token-usage': 'error',
18
18
  '@atlaskit/design-system/icon-label': 'warn',
19
+ '@atlaskit/design-system/lozenge-appearance-and-isbold-migration': 'warn',
19
20
  '@atlaskit/design-system/no-banned-imports': 'error',
20
21
  '@atlaskit/design-system/no-boolean-autofocus-on-modal-dialog': 'warn',
21
22
  '@atlaskit/design-system/no-deprecated-apis': 'error',
@@ -12,6 +12,7 @@ var _ensureDesignTokenUsagePreview = _interopRequireDefault(require("./ensure-de
12
12
  var _ensureIconColor = _interopRequireDefault(require("./ensure-icon-color"));
13
13
  var _ensureProperXcssUsage = _interopRequireDefault(require("./ensure-proper-xcss-usage"));
14
14
  var _iconLabel = _interopRequireDefault(require("./icon-label"));
15
+ var _lozengeAppearanceAndIsboldMigration = _interopRequireDefault(require("./lozenge-appearance-and-isbold-migration"));
15
16
  var _noBannedImports = _interopRequireDefault(require("./no-banned-imports"));
16
17
  var _noBooleanAutofocusOnModalDialog = _interopRequireDefault(require("./no-boolean-autofocus-on-modal-dialog"));
17
18
  var _noCssTaggedTemplateExpression = _interopRequireDefault(require("./no-css-tagged-template-expression"));
@@ -75,7 +76,7 @@ var _useTokensTypography = _interopRequireDefault(require("./use-tokens-typograp
75
76
  var _useVisuallyHidden = _interopRequireDefault(require("./use-visually-hidden"));
76
77
  /**
77
78
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
78
- * @codegen <<SignedSource::732bff0fc39d7ff05b6688694101698d>>
79
+ * @codegen <<SignedSource::75f94fc6b6fa998eed54b610e41bb9b1>>
79
80
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
80
81
  */
81
82
 
@@ -87,6 +88,7 @@ var rules = exports.rules = {
87
88
  'ensure-icon-color': _ensureIconColor.default,
88
89
  'ensure-proper-xcss-usage': _ensureProperXcssUsage.default,
89
90
  'icon-label': _iconLabel.default,
91
+ 'lozenge-appearance-and-isbold-migration': _lozengeAppearanceAndIsboldMigration.default,
90
92
  'no-banned-imports': _noBannedImports.default,
91
93
  'no-boolean-autofocus-on-modal-dialog': _noBooleanAutofocusOnModalDialog.default,
92
94
  'no-css-tagged-template-expression': _noCssTaggedTemplateExpression.default,
@@ -0,0 +1,267 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _eslintCodemodUtils = require("eslint-codemod-utils");
8
+ var _createRule = require("../utils/create-rule");
9
+ var rule = (0, _createRule.createLintRule)({
10
+ meta: {
11
+ name: 'lozenge-appearance-and-isbold-migration',
12
+ fixable: 'code',
13
+ type: 'suggestion',
14
+ docs: {
15
+ description: 'Helps migrate deprecated Lozenge usages to the new API or Tag component as part of the Labelling System Phase 1 migration.',
16
+ recommended: true,
17
+ severity: 'warn'
18
+ },
19
+ messages: {
20
+ replaceAppearance: "'appearance' prop on <Lozenge> is deprecated — use 'color' instead.",
21
+ migrateTag: 'Non-bold <Lozenge> variants should migrate to <Tag> component.',
22
+ manualReview: "Dynamic 'isBold' props require manual review before migration."
23
+ }
24
+ },
25
+ create: function create(context) {
26
+ /**
27
+ * Contains a map of imported Lozenge components.
28
+ */
29
+ var lozengeImports = {}; // local name -> import source
30
+ var tagImports = {}; // local name -> import source
31
+
32
+ /**
33
+ * Check if a JSX attribute value is a literal false
34
+ */
35
+ function isLiteralFalse(node) {
36
+ return node && node.type === 'JSXExpressionContainer' && node.expression && node.expression.type === 'Literal' && node.expression.value === false;
37
+ }
38
+
39
+ /**
40
+ * Check if a JSX attribute value is dynamic (not a literal boolean)
41
+ */
42
+ function isDynamicExpression(node) {
43
+ if (!node || node.type !== 'JSXExpressionContainer') {
44
+ return false;
45
+ }
46
+ var expr = node.expression;
47
+ return expr && !(expr.type === 'Literal' && typeof expr.value === 'boolean');
48
+ }
49
+
50
+ /**
51
+ * Get all attributes as an object for easier manipulation
52
+ */
53
+ function getAttributesMap(attributes) {
54
+ var map = {};
55
+ attributes.forEach(function (attr) {
56
+ if (attr.type === 'JSXAttribute' && attr.name.type === 'JSXIdentifier') {
57
+ map[attr.name.name] = attr;
58
+ }
59
+ });
60
+ return map;
61
+ }
62
+
63
+ /**
64
+ * Map Lozenge appearance values to Tag color values
65
+ */
66
+ function mapAppearanceToTagColor(appearanceValue) {
67
+ var mapping = {
68
+ success: 'lime',
69
+ default: 'standard',
70
+ removed: 'red',
71
+ inprogress: 'blue',
72
+ new: 'purple',
73
+ moved: 'orange'
74
+ };
75
+ return mapping[appearanceValue] || appearanceValue;
76
+ }
77
+
78
+ /**
79
+ * Map Lozenge appearance values to Lozenge color values
80
+ */
81
+ function mapAppearanceToLozengeColor(appearanceValue) {
82
+ var mapping = {
83
+ default: 'neutral',
84
+ inprogress: 'information',
85
+ moved: 'warning',
86
+ new: 'discovery',
87
+ removed: 'danger',
88
+ success: 'success'
89
+ };
90
+ return mapping[appearanceValue] || appearanceValue;
91
+ }
92
+
93
+ /**
94
+ * Extract the string value from a JSX attribute value
95
+ */
96
+ function extractStringValue(attrValue) {
97
+ if (!attrValue) {
98
+ return null;
99
+ }
100
+ if (attrValue.type === 'Literal') {
101
+ return attrValue.value;
102
+ }
103
+ if (attrValue.type === 'JSXExpressionContainer' && attrValue.expression && attrValue.expression.type === 'Literal') {
104
+ return attrValue.expression.value;
105
+ }
106
+ return null;
107
+ }
108
+
109
+ /**
110
+ * Generate the replacement JSX element text
111
+ */
112
+ function generateTagReplacement(node, lozengeLocalName) {
113
+ var sourceCode = context.getSourceCode();
114
+ var attributes = node.openingElement.attributes;
115
+
116
+ // Build new attributes array, excluding isBold and mapping appearance to color
117
+ var newAttributes = [];
118
+ attributes.forEach(function (attr) {
119
+ if (attr.type === 'JSXAttribute' && attr.name.type === 'JSXIdentifier') {
120
+ var attrName = attr.name.name;
121
+ if (attrName === 'isBold') {
122
+ // Skip isBold attribute
123
+ return;
124
+ }
125
+ if (attrName === 'appearance') {
126
+ // Map appearance to color with value transformation
127
+ var stringValue = extractStringValue(attr.value);
128
+ if (stringValue && typeof stringValue === 'string') {
129
+ var mappedColor = mapAppearanceToTagColor(stringValue);
130
+ newAttributes.push("color=\"".concat(mappedColor, "\""));
131
+ } else {
132
+ // If we can't extract the string value, keep as-is but rename to color
133
+ var value = attr.value ? sourceCode.getText(attr.value) : '';
134
+ newAttributes.push("color".concat(value ? "=".concat(value) : ''));
135
+ }
136
+ return;
137
+ }
138
+
139
+ // Keep all other attributes
140
+ newAttributes.push(sourceCode.getText(attr));
141
+ } else if (attr.type === 'JSXSpreadAttribute') {
142
+ // Keep spread attributes
143
+ newAttributes.push(sourceCode.getText(attr));
144
+ }
145
+ });
146
+ var attributesText = newAttributes.length > 0 ? " ".concat(newAttributes.join(' ')) : '';
147
+ var children = node.children.length > 0 ? sourceCode.getText().slice(node.openingElement.range[1], node.closingElement ? node.closingElement.range[0] : node.range[1]) : '';
148
+ if (node.closingElement) {
149
+ return "<Tag".concat(attributesText, ">").concat(children, "</Tag>");
150
+ } else {
151
+ return "<Tag".concat(attributesText, " />");
152
+ }
153
+ }
154
+ return {
155
+ ImportDeclaration: function ImportDeclaration(node) {
156
+ var moduleSource = node.source.value;
157
+ if (typeof moduleSource === 'string') {
158
+ // Track Lozenge imports
159
+ if (moduleSource === '@atlaskit/lozenge' || moduleSource.startsWith('@atlaskit/lozenge')) {
160
+ node.specifiers.forEach(function (spec) {
161
+ if (spec.type === 'ImportDefaultSpecifier') {
162
+ lozengeImports[spec.local.name] = moduleSource;
163
+ } else if (spec.type === 'ImportSpecifier' && spec.imported.type === 'Identifier') {
164
+ if (spec.imported.name === 'Lozenge') {
165
+ lozengeImports[spec.local.name] = moduleSource;
166
+ }
167
+ }
168
+ });
169
+ }
170
+ // Track Tag imports
171
+ if (moduleSource === '@atlaskit/tag' || moduleSource.startsWith('@atlaskit/tag/')) {
172
+ node.specifiers.forEach(function (spec) {
173
+ if (spec.type === 'ImportDefaultSpecifier') {
174
+ tagImports[spec.local.name] = moduleSource;
175
+ } else if (spec.type === 'ImportSpecifier' && spec.imported.type === 'Identifier') {
176
+ if (spec.imported.name === 'Tag') {
177
+ tagImports[spec.local.name] = moduleSource;
178
+ }
179
+ }
180
+ });
181
+ }
182
+ }
183
+ },
184
+ JSXElement: function JSXElement(node) {
185
+ if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'JSXElement')) {
186
+ return;
187
+ }
188
+ if (!(0, _eslintCodemodUtils.isNodeOfType)(node.openingElement.name, 'JSXIdentifier')) {
189
+ return;
190
+ }
191
+ var elementName = node.openingElement.name.name;
192
+
193
+ // Only process if this is a Lozenge component we've imported
194
+ if (!lozengeImports[elementName]) {
195
+ return;
196
+ }
197
+ var attributesMap = getAttributesMap(node.openingElement.attributes);
198
+ var appearanceProp = attributesMap.appearance;
199
+ var isBoldProp = attributesMap.isBold;
200
+
201
+ // Handle appearance prop migration
202
+ if (appearanceProp) {
203
+ context.report({
204
+ node: appearanceProp,
205
+ messageId: 'replaceAppearance',
206
+ fix: function fix(fixer) {
207
+ var fixes = [];
208
+ // Always rename the prop name
209
+ fixes.push(fixer.replaceText(appearanceProp.name, 'color'));
210
+
211
+ // Also map the value if it's a string literal and we're not migrating to Tag
212
+ var shouldMigrateToTag = !isBoldProp || isLiteralFalse(isBoldProp.value);
213
+ if (!shouldMigrateToTag) {
214
+ var stringValue = extractStringValue(appearanceProp.value);
215
+ if (stringValue && typeof stringValue === 'string') {
216
+ var mappedColor = mapAppearanceToLozengeColor(stringValue);
217
+ if (mappedColor !== stringValue) {
218
+ // Update the value if it changed
219
+ if (appearanceProp.value.type === 'Literal') {
220
+ fixes.push(fixer.replaceText(appearanceProp.value, "\"".concat(mappedColor, "\"")));
221
+ } else if (appearanceProp.value.type === 'JSXExpressionContainer' && appearanceProp.value.expression && appearanceProp.value.expression.type === 'Literal') {
222
+ fixes.push(fixer.replaceText(appearanceProp.value.expression, "\"".concat(mappedColor, "\"")));
223
+ }
224
+ }
225
+ }
226
+ }
227
+ return fixes;
228
+ }
229
+ });
230
+ }
231
+
232
+ // Handle isBold prop and Tag migration
233
+ if (isBoldProp) {
234
+ if (isLiteralFalse(isBoldProp.value)) {
235
+ // isBold={false} should migrate to Tag
236
+ context.report({
237
+ node: node,
238
+ messageId: 'migrateTag',
239
+ fix: function fix(fixer) {
240
+ var replacement = generateTagReplacement(node, elementName);
241
+ return fixer.replaceText(node, replacement);
242
+ }
243
+ });
244
+ } else if (isDynamicExpression(isBoldProp.value)) {
245
+ // Dynamic isBold requires manual review
246
+ context.report({
247
+ node: isBoldProp,
248
+ messageId: 'manualReview'
249
+ });
250
+ }
251
+ // isBold={true} or isBold (implicit true) - no action needed
252
+ } else {
253
+ // No isBold prop means implicit false, should migrate to Tag
254
+ context.report({
255
+ node: node,
256
+ messageId: 'migrateTag',
257
+ fix: function fix(fixer) {
258
+ var replacement = generateTagReplacement(node, elementName);
259
+ return fixer.replaceText(node, replacement);
260
+ }
261
+ });
262
+ }
263
+ }
264
+ };
265
+ }
266
+ });
267
+ var _default = exports.default = rule;
@@ -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::5aac2d8dc7c2832bcb8a96a143d60db5>>
3
+ * @codegen <<SignedSource::7fae089db9d7d7153fea58c673bd56af>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -15,6 +15,7 @@ const rules = {
15
15
  '@atlaskit/design-system/ensure-icon-color': 'error',
16
16
  '@atlaskit/design-system/ensure-proper-xcss-usage': 'error',
17
17
  '@atlaskit/design-system/icon-label': 'warn',
18
+ '@atlaskit/design-system/lozenge-appearance-and-isbold-migration': 'warn',
18
19
  '@atlaskit/design-system/no-banned-imports': 'error',
19
20
  '@atlaskit/design-system/no-boolean-autofocus-on-modal-dialog': 'warn',
20
21
  '@atlaskit/design-system/no-css-tagged-template-expression': 'error',
@@ -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::43ea4411c4e338a916772d4bfda146cc>>
3
+ * @codegen <<SignedSource::655d7f24171da0dff60003d0f235e48a>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -14,6 +14,7 @@ const rules = {
14
14
  '@atlaskit/design-system/ensure-icon-color': 'error',
15
15
  '@atlaskit/design-system/ensure-proper-xcss-usage': 'error',
16
16
  '@atlaskit/design-system/icon-label': 'warn',
17
+ '@atlaskit/design-system/lozenge-appearance-and-isbold-migration': 'warn',
17
18
  '@atlaskit/design-system/no-banned-imports': 'error',
18
19
  '@atlaskit/design-system/no-boolean-autofocus-on-modal-dialog': 'warn',
19
20
  '@atlaskit/design-system/no-css-tagged-template-expression': 'error',
@@ -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::3328b9c675a0d09876dcfbc5d29bc63f>>
3
+ * @codegen <<SignedSource::44a03b30a12e3b52d720c16785c9c649>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -11,6 +11,7 @@ const rules = {
11
11
  '@atlaskit/design-system/consistent-css-prop-usage': 'error',
12
12
  '@atlaskit/design-system/ensure-design-token-usage': 'error',
13
13
  '@atlaskit/design-system/icon-label': 'warn',
14
+ '@atlaskit/design-system/lozenge-appearance-and-isbold-migration': 'warn',
14
15
  '@atlaskit/design-system/no-banned-imports': 'error',
15
16
  '@atlaskit/design-system/no-boolean-autofocus-on-modal-dialog': 'warn',
16
17
  '@atlaskit/design-system/no-deprecated-apis': 'error',
@@ -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::b28f895280627b7a35f059f90783644a>>
3
+ * @codegen <<SignedSource::0311febdad396820af1b01dd2825b63f>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -10,6 +10,7 @@ const rules = {
10
10
  '@atlaskit/design-system/consistent-css-prop-usage': 'error',
11
11
  '@atlaskit/design-system/ensure-design-token-usage': 'error',
12
12
  '@atlaskit/design-system/icon-label': 'warn',
13
+ '@atlaskit/design-system/lozenge-appearance-and-isbold-migration': 'warn',
13
14
  '@atlaskit/design-system/no-banned-imports': 'error',
14
15
  '@atlaskit/design-system/no-boolean-autofocus-on-modal-dialog': 'warn',
15
16
  '@atlaskit/design-system/no-deprecated-apis': 'error',
@@ -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::732bff0fc39d7ff05b6688694101698d>>
3
+ * @codegen <<SignedSource::75f94fc6b6fa998eed54b610e41bb9b1>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -11,6 +11,7 @@ import ensureDesignTokenUsagePreview from './ensure-design-token-usage-preview';
11
11
  import ensureIconColor from './ensure-icon-color';
12
12
  import ensureProperXcssUsage from './ensure-proper-xcss-usage';
13
13
  import iconLabel from './icon-label';
14
+ import lozengeAppearanceAndIsboldMigration from './lozenge-appearance-and-isbold-migration';
14
15
  import noBannedImports from './no-banned-imports';
15
16
  import noBooleanAutofocusOnModalDialog from './no-boolean-autofocus-on-modal-dialog';
16
17
  import noCssTaggedTemplateExpression from './no-css-tagged-template-expression';
@@ -80,6 +81,7 @@ export const rules = {
80
81
  'ensure-icon-color': ensureIconColor,
81
82
  'ensure-proper-xcss-usage': ensureProperXcssUsage,
82
83
  'icon-label': iconLabel,
84
+ 'lozenge-appearance-and-isbold-migration': lozengeAppearanceAndIsboldMigration,
83
85
  'no-banned-imports': noBannedImports,
84
86
  'no-boolean-autofocus-on-modal-dialog': noBooleanAutofocusOnModalDialog,
85
87
  'no-css-tagged-template-expression': noCssTaggedTemplateExpression,
@@ -0,0 +1,261 @@
1
+ import { isNodeOfType } from 'eslint-codemod-utils';
2
+ import { createLintRule } from '../utils/create-rule';
3
+ const rule = createLintRule({
4
+ meta: {
5
+ name: 'lozenge-appearance-and-isbold-migration',
6
+ fixable: 'code',
7
+ type: 'suggestion',
8
+ docs: {
9
+ description: 'Helps migrate deprecated Lozenge usages to the new API or Tag component as part of the Labelling System Phase 1 migration.',
10
+ recommended: true,
11
+ severity: 'warn'
12
+ },
13
+ messages: {
14
+ replaceAppearance: "'appearance' prop on <Lozenge> is deprecated — use 'color' instead.",
15
+ migrateTag: 'Non-bold <Lozenge> variants should migrate to <Tag> component.',
16
+ manualReview: "Dynamic 'isBold' props require manual review before migration."
17
+ }
18
+ },
19
+ create(context) {
20
+ /**
21
+ * Contains a map of imported Lozenge components.
22
+ */
23
+ const lozengeImports = {}; // local name -> import source
24
+ const tagImports = {}; // local name -> import source
25
+
26
+ /**
27
+ * Check if a JSX attribute value is a literal false
28
+ */
29
+ function isLiteralFalse(node) {
30
+ return node && node.type === 'JSXExpressionContainer' && node.expression && node.expression.type === 'Literal' && node.expression.value === false;
31
+ }
32
+
33
+ /**
34
+ * Check if a JSX attribute value is dynamic (not a literal boolean)
35
+ */
36
+ function isDynamicExpression(node) {
37
+ if (!node || node.type !== 'JSXExpressionContainer') {
38
+ return false;
39
+ }
40
+ const expr = node.expression;
41
+ return expr && !(expr.type === 'Literal' && typeof expr.value === 'boolean');
42
+ }
43
+
44
+ /**
45
+ * Get all attributes as an object for easier manipulation
46
+ */
47
+ function getAttributesMap(attributes) {
48
+ const map = {};
49
+ attributes.forEach(attr => {
50
+ if (attr.type === 'JSXAttribute' && attr.name.type === 'JSXIdentifier') {
51
+ map[attr.name.name] = attr;
52
+ }
53
+ });
54
+ return map;
55
+ }
56
+
57
+ /**
58
+ * Map Lozenge appearance values to Tag color values
59
+ */
60
+ function mapAppearanceToTagColor(appearanceValue) {
61
+ const mapping = {
62
+ success: 'lime',
63
+ default: 'standard',
64
+ removed: 'red',
65
+ inprogress: 'blue',
66
+ new: 'purple',
67
+ moved: 'orange'
68
+ };
69
+ return mapping[appearanceValue] || appearanceValue;
70
+ }
71
+
72
+ /**
73
+ * Map Lozenge appearance values to Lozenge color values
74
+ */
75
+ function mapAppearanceToLozengeColor(appearanceValue) {
76
+ const mapping = {
77
+ default: 'neutral',
78
+ inprogress: 'information',
79
+ moved: 'warning',
80
+ new: 'discovery',
81
+ removed: 'danger',
82
+ success: 'success'
83
+ };
84
+ return mapping[appearanceValue] || appearanceValue;
85
+ }
86
+
87
+ /**
88
+ * Extract the string value from a JSX attribute value
89
+ */
90
+ function extractStringValue(attrValue) {
91
+ if (!attrValue) {
92
+ return null;
93
+ }
94
+ if (attrValue.type === 'Literal') {
95
+ return attrValue.value;
96
+ }
97
+ if (attrValue.type === 'JSXExpressionContainer' && attrValue.expression && attrValue.expression.type === 'Literal') {
98
+ return attrValue.expression.value;
99
+ }
100
+ return null;
101
+ }
102
+
103
+ /**
104
+ * Generate the replacement JSX element text
105
+ */
106
+ function generateTagReplacement(node, lozengeLocalName) {
107
+ const sourceCode = context.getSourceCode();
108
+ const attributes = node.openingElement.attributes;
109
+
110
+ // Build new attributes array, excluding isBold and mapping appearance to color
111
+ const newAttributes = [];
112
+ attributes.forEach(attr => {
113
+ if (attr.type === 'JSXAttribute' && attr.name.type === 'JSXIdentifier') {
114
+ const attrName = attr.name.name;
115
+ if (attrName === 'isBold') {
116
+ // Skip isBold attribute
117
+ return;
118
+ }
119
+ if (attrName === 'appearance') {
120
+ // Map appearance to color with value transformation
121
+ const stringValue = extractStringValue(attr.value);
122
+ if (stringValue && typeof stringValue === 'string') {
123
+ const mappedColor = mapAppearanceToTagColor(stringValue);
124
+ newAttributes.push(`color="${mappedColor}"`);
125
+ } else {
126
+ // If we can't extract the string value, keep as-is but rename to color
127
+ const value = attr.value ? sourceCode.getText(attr.value) : '';
128
+ newAttributes.push(`color${value ? `=${value}` : ''}`);
129
+ }
130
+ return;
131
+ }
132
+
133
+ // Keep all other attributes
134
+ newAttributes.push(sourceCode.getText(attr));
135
+ } else if (attr.type === 'JSXSpreadAttribute') {
136
+ // Keep spread attributes
137
+ newAttributes.push(sourceCode.getText(attr));
138
+ }
139
+ });
140
+ const attributesText = newAttributes.length > 0 ? ` ${newAttributes.join(' ')}` : '';
141
+ const children = node.children.length > 0 ? sourceCode.getText().slice(node.openingElement.range[1], node.closingElement ? node.closingElement.range[0] : node.range[1]) : '';
142
+ if (node.closingElement) {
143
+ return `<Tag${attributesText}>${children}</Tag>`;
144
+ } else {
145
+ return `<Tag${attributesText} />`;
146
+ }
147
+ }
148
+ return {
149
+ ImportDeclaration(node) {
150
+ const moduleSource = node.source.value;
151
+ if (typeof moduleSource === 'string') {
152
+ // Track Lozenge imports
153
+ if (moduleSource === '@atlaskit/lozenge' || moduleSource.startsWith('@atlaskit/lozenge')) {
154
+ node.specifiers.forEach(spec => {
155
+ if (spec.type === 'ImportDefaultSpecifier') {
156
+ lozengeImports[spec.local.name] = moduleSource;
157
+ } else if (spec.type === 'ImportSpecifier' && spec.imported.type === 'Identifier') {
158
+ if (spec.imported.name === 'Lozenge') {
159
+ lozengeImports[spec.local.name] = moduleSource;
160
+ }
161
+ }
162
+ });
163
+ }
164
+ // Track Tag imports
165
+ if (moduleSource === '@atlaskit/tag' || moduleSource.startsWith('@atlaskit/tag/')) {
166
+ node.specifiers.forEach(spec => {
167
+ if (spec.type === 'ImportDefaultSpecifier') {
168
+ tagImports[spec.local.name] = moduleSource;
169
+ } else if (spec.type === 'ImportSpecifier' && spec.imported.type === 'Identifier') {
170
+ if (spec.imported.name === 'Tag') {
171
+ tagImports[spec.local.name] = moduleSource;
172
+ }
173
+ }
174
+ });
175
+ }
176
+ }
177
+ },
178
+ JSXElement(node) {
179
+ if (!isNodeOfType(node, 'JSXElement')) {
180
+ return;
181
+ }
182
+ if (!isNodeOfType(node.openingElement.name, 'JSXIdentifier')) {
183
+ return;
184
+ }
185
+ const elementName = node.openingElement.name.name;
186
+
187
+ // Only process if this is a Lozenge component we've imported
188
+ if (!lozengeImports[elementName]) {
189
+ return;
190
+ }
191
+ const attributesMap = getAttributesMap(node.openingElement.attributes);
192
+ const appearanceProp = attributesMap.appearance;
193
+ const isBoldProp = attributesMap.isBold;
194
+
195
+ // Handle appearance prop migration
196
+ if (appearanceProp) {
197
+ context.report({
198
+ node: appearanceProp,
199
+ messageId: 'replaceAppearance',
200
+ fix: fixer => {
201
+ const fixes = [];
202
+ // Always rename the prop name
203
+ fixes.push(fixer.replaceText(appearanceProp.name, 'color'));
204
+
205
+ // Also map the value if it's a string literal and we're not migrating to Tag
206
+ const shouldMigrateToTag = !isBoldProp || isLiteralFalse(isBoldProp.value);
207
+ if (!shouldMigrateToTag) {
208
+ const stringValue = extractStringValue(appearanceProp.value);
209
+ if (stringValue && typeof stringValue === 'string') {
210
+ const mappedColor = mapAppearanceToLozengeColor(stringValue);
211
+ if (mappedColor !== stringValue) {
212
+ // Update the value if it changed
213
+ if (appearanceProp.value.type === 'Literal') {
214
+ fixes.push(fixer.replaceText(appearanceProp.value, `"${mappedColor}"`));
215
+ } else if (appearanceProp.value.type === 'JSXExpressionContainer' && appearanceProp.value.expression && appearanceProp.value.expression.type === 'Literal') {
216
+ fixes.push(fixer.replaceText(appearanceProp.value.expression, `"${mappedColor}"`));
217
+ }
218
+ }
219
+ }
220
+ }
221
+ return fixes;
222
+ }
223
+ });
224
+ }
225
+
226
+ // Handle isBold prop and Tag migration
227
+ if (isBoldProp) {
228
+ if (isLiteralFalse(isBoldProp.value)) {
229
+ // isBold={false} should migrate to Tag
230
+ context.report({
231
+ node: node,
232
+ messageId: 'migrateTag',
233
+ fix: fixer => {
234
+ const replacement = generateTagReplacement(node, elementName);
235
+ return fixer.replaceText(node, replacement);
236
+ }
237
+ });
238
+ } else if (isDynamicExpression(isBoldProp.value)) {
239
+ // Dynamic isBold requires manual review
240
+ context.report({
241
+ node: isBoldProp,
242
+ messageId: 'manualReview'
243
+ });
244
+ }
245
+ // isBold={true} or isBold (implicit true) - no action needed
246
+ } else {
247
+ // No isBold prop means implicit false, should migrate to Tag
248
+ context.report({
249
+ node: node,
250
+ messageId: 'migrateTag',
251
+ fix: fixer => {
252
+ const replacement = generateTagReplacement(node, elementName);
253
+ return fixer.replaceText(node, replacement);
254
+ }
255
+ });
256
+ }
257
+ }
258
+ };
259
+ }
260
+ });
261
+ export default rule;
@@ -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::5aac2d8dc7c2832bcb8a96a143d60db5>>
3
+ * @codegen <<SignedSource::7fae089db9d7d7153fea58c673bd56af>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -15,6 +15,7 @@ var rules = {
15
15
  '@atlaskit/design-system/ensure-icon-color': 'error',
16
16
  '@atlaskit/design-system/ensure-proper-xcss-usage': 'error',
17
17
  '@atlaskit/design-system/icon-label': 'warn',
18
+ '@atlaskit/design-system/lozenge-appearance-and-isbold-migration': 'warn',
18
19
  '@atlaskit/design-system/no-banned-imports': 'error',
19
20
  '@atlaskit/design-system/no-boolean-autofocus-on-modal-dialog': 'warn',
20
21
  '@atlaskit/design-system/no-css-tagged-template-expression': 'error',
@@ -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::43ea4411c4e338a916772d4bfda146cc>>
3
+ * @codegen <<SignedSource::655d7f24171da0dff60003d0f235e48a>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -14,6 +14,7 @@ var rules = {
14
14
  '@atlaskit/design-system/ensure-icon-color': 'error',
15
15
  '@atlaskit/design-system/ensure-proper-xcss-usage': 'error',
16
16
  '@atlaskit/design-system/icon-label': 'warn',
17
+ '@atlaskit/design-system/lozenge-appearance-and-isbold-migration': 'warn',
17
18
  '@atlaskit/design-system/no-banned-imports': 'error',
18
19
  '@atlaskit/design-system/no-boolean-autofocus-on-modal-dialog': 'warn',
19
20
  '@atlaskit/design-system/no-css-tagged-template-expression': 'error',
@@ -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::3328b9c675a0d09876dcfbc5d29bc63f>>
3
+ * @codegen <<SignedSource::44a03b30a12e3b52d720c16785c9c649>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -11,6 +11,7 @@ var rules = {
11
11
  '@atlaskit/design-system/consistent-css-prop-usage': 'error',
12
12
  '@atlaskit/design-system/ensure-design-token-usage': 'error',
13
13
  '@atlaskit/design-system/icon-label': 'warn',
14
+ '@atlaskit/design-system/lozenge-appearance-and-isbold-migration': 'warn',
14
15
  '@atlaskit/design-system/no-banned-imports': 'error',
15
16
  '@atlaskit/design-system/no-boolean-autofocus-on-modal-dialog': 'warn',
16
17
  '@atlaskit/design-system/no-deprecated-apis': 'error',
@@ -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::b28f895280627b7a35f059f90783644a>>
3
+ * @codegen <<SignedSource::0311febdad396820af1b01dd2825b63f>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -10,6 +10,7 @@ var rules = {
10
10
  '@atlaskit/design-system/consistent-css-prop-usage': 'error',
11
11
  '@atlaskit/design-system/ensure-design-token-usage': 'error',
12
12
  '@atlaskit/design-system/icon-label': 'warn',
13
+ '@atlaskit/design-system/lozenge-appearance-and-isbold-migration': 'warn',
13
14
  '@atlaskit/design-system/no-banned-imports': 'error',
14
15
  '@atlaskit/design-system/no-boolean-autofocus-on-modal-dialog': 'warn',
15
16
  '@atlaskit/design-system/no-deprecated-apis': 'error',
@@ -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::732bff0fc39d7ff05b6688694101698d>>
3
+ * @codegen <<SignedSource::75f94fc6b6fa998eed54b610e41bb9b1>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -11,6 +11,7 @@ import ensureDesignTokenUsagePreview from './ensure-design-token-usage-preview';
11
11
  import ensureIconColor from './ensure-icon-color';
12
12
  import ensureProperXcssUsage from './ensure-proper-xcss-usage';
13
13
  import iconLabel from './icon-label';
14
+ import lozengeAppearanceAndIsboldMigration from './lozenge-appearance-and-isbold-migration';
14
15
  import noBannedImports from './no-banned-imports';
15
16
  import noBooleanAutofocusOnModalDialog from './no-boolean-autofocus-on-modal-dialog';
16
17
  import noCssTaggedTemplateExpression from './no-css-tagged-template-expression';
@@ -80,6 +81,7 @@ export var rules = {
80
81
  'ensure-icon-color': ensureIconColor,
81
82
  'ensure-proper-xcss-usage': ensureProperXcssUsage,
82
83
  'icon-label': iconLabel,
84
+ 'lozenge-appearance-and-isbold-migration': lozengeAppearanceAndIsboldMigration,
83
85
  'no-banned-imports': noBannedImports,
84
86
  'no-boolean-autofocus-on-modal-dialog': noBooleanAutofocusOnModalDialog,
85
87
  'no-css-tagged-template-expression': noCssTaggedTemplateExpression,
@@ -0,0 +1,261 @@
1
+ import { isNodeOfType } from 'eslint-codemod-utils';
2
+ import { createLintRule } from '../utils/create-rule';
3
+ var rule = createLintRule({
4
+ meta: {
5
+ name: 'lozenge-appearance-and-isbold-migration',
6
+ fixable: 'code',
7
+ type: 'suggestion',
8
+ docs: {
9
+ description: 'Helps migrate deprecated Lozenge usages to the new API or Tag component as part of the Labelling System Phase 1 migration.',
10
+ recommended: true,
11
+ severity: 'warn'
12
+ },
13
+ messages: {
14
+ replaceAppearance: "'appearance' prop on <Lozenge> is deprecated — use 'color' instead.",
15
+ migrateTag: 'Non-bold <Lozenge> variants should migrate to <Tag> component.',
16
+ manualReview: "Dynamic 'isBold' props require manual review before migration."
17
+ }
18
+ },
19
+ create: function create(context) {
20
+ /**
21
+ * Contains a map of imported Lozenge components.
22
+ */
23
+ var lozengeImports = {}; // local name -> import source
24
+ var tagImports = {}; // local name -> import source
25
+
26
+ /**
27
+ * Check if a JSX attribute value is a literal false
28
+ */
29
+ function isLiteralFalse(node) {
30
+ return node && node.type === 'JSXExpressionContainer' && node.expression && node.expression.type === 'Literal' && node.expression.value === false;
31
+ }
32
+
33
+ /**
34
+ * Check if a JSX attribute value is dynamic (not a literal boolean)
35
+ */
36
+ function isDynamicExpression(node) {
37
+ if (!node || node.type !== 'JSXExpressionContainer') {
38
+ return false;
39
+ }
40
+ var expr = node.expression;
41
+ return expr && !(expr.type === 'Literal' && typeof expr.value === 'boolean');
42
+ }
43
+
44
+ /**
45
+ * Get all attributes as an object for easier manipulation
46
+ */
47
+ function getAttributesMap(attributes) {
48
+ var map = {};
49
+ attributes.forEach(function (attr) {
50
+ if (attr.type === 'JSXAttribute' && attr.name.type === 'JSXIdentifier') {
51
+ map[attr.name.name] = attr;
52
+ }
53
+ });
54
+ return map;
55
+ }
56
+
57
+ /**
58
+ * Map Lozenge appearance values to Tag color values
59
+ */
60
+ function mapAppearanceToTagColor(appearanceValue) {
61
+ var mapping = {
62
+ success: 'lime',
63
+ default: 'standard',
64
+ removed: 'red',
65
+ inprogress: 'blue',
66
+ new: 'purple',
67
+ moved: 'orange'
68
+ };
69
+ return mapping[appearanceValue] || appearanceValue;
70
+ }
71
+
72
+ /**
73
+ * Map Lozenge appearance values to Lozenge color values
74
+ */
75
+ function mapAppearanceToLozengeColor(appearanceValue) {
76
+ var mapping = {
77
+ default: 'neutral',
78
+ inprogress: 'information',
79
+ moved: 'warning',
80
+ new: 'discovery',
81
+ removed: 'danger',
82
+ success: 'success'
83
+ };
84
+ return mapping[appearanceValue] || appearanceValue;
85
+ }
86
+
87
+ /**
88
+ * Extract the string value from a JSX attribute value
89
+ */
90
+ function extractStringValue(attrValue) {
91
+ if (!attrValue) {
92
+ return null;
93
+ }
94
+ if (attrValue.type === 'Literal') {
95
+ return attrValue.value;
96
+ }
97
+ if (attrValue.type === 'JSXExpressionContainer' && attrValue.expression && attrValue.expression.type === 'Literal') {
98
+ return attrValue.expression.value;
99
+ }
100
+ return null;
101
+ }
102
+
103
+ /**
104
+ * Generate the replacement JSX element text
105
+ */
106
+ function generateTagReplacement(node, lozengeLocalName) {
107
+ var sourceCode = context.getSourceCode();
108
+ var attributes = node.openingElement.attributes;
109
+
110
+ // Build new attributes array, excluding isBold and mapping appearance to color
111
+ var newAttributes = [];
112
+ attributes.forEach(function (attr) {
113
+ if (attr.type === 'JSXAttribute' && attr.name.type === 'JSXIdentifier') {
114
+ var attrName = attr.name.name;
115
+ if (attrName === 'isBold') {
116
+ // Skip isBold attribute
117
+ return;
118
+ }
119
+ if (attrName === 'appearance') {
120
+ // Map appearance to color with value transformation
121
+ var stringValue = extractStringValue(attr.value);
122
+ if (stringValue && typeof stringValue === 'string') {
123
+ var mappedColor = mapAppearanceToTagColor(stringValue);
124
+ newAttributes.push("color=\"".concat(mappedColor, "\""));
125
+ } else {
126
+ // If we can't extract the string value, keep as-is but rename to color
127
+ var value = attr.value ? sourceCode.getText(attr.value) : '';
128
+ newAttributes.push("color".concat(value ? "=".concat(value) : ''));
129
+ }
130
+ return;
131
+ }
132
+
133
+ // Keep all other attributes
134
+ newAttributes.push(sourceCode.getText(attr));
135
+ } else if (attr.type === 'JSXSpreadAttribute') {
136
+ // Keep spread attributes
137
+ newAttributes.push(sourceCode.getText(attr));
138
+ }
139
+ });
140
+ var attributesText = newAttributes.length > 0 ? " ".concat(newAttributes.join(' ')) : '';
141
+ var children = node.children.length > 0 ? sourceCode.getText().slice(node.openingElement.range[1], node.closingElement ? node.closingElement.range[0] : node.range[1]) : '';
142
+ if (node.closingElement) {
143
+ return "<Tag".concat(attributesText, ">").concat(children, "</Tag>");
144
+ } else {
145
+ return "<Tag".concat(attributesText, " />");
146
+ }
147
+ }
148
+ return {
149
+ ImportDeclaration: function ImportDeclaration(node) {
150
+ var moduleSource = node.source.value;
151
+ if (typeof moduleSource === 'string') {
152
+ // Track Lozenge imports
153
+ if (moduleSource === '@atlaskit/lozenge' || moduleSource.startsWith('@atlaskit/lozenge')) {
154
+ node.specifiers.forEach(function (spec) {
155
+ if (spec.type === 'ImportDefaultSpecifier') {
156
+ lozengeImports[spec.local.name] = moduleSource;
157
+ } else if (spec.type === 'ImportSpecifier' && spec.imported.type === 'Identifier') {
158
+ if (spec.imported.name === 'Lozenge') {
159
+ lozengeImports[spec.local.name] = moduleSource;
160
+ }
161
+ }
162
+ });
163
+ }
164
+ // Track Tag imports
165
+ if (moduleSource === '@atlaskit/tag' || moduleSource.startsWith('@atlaskit/tag/')) {
166
+ node.specifiers.forEach(function (spec) {
167
+ if (spec.type === 'ImportDefaultSpecifier') {
168
+ tagImports[spec.local.name] = moduleSource;
169
+ } else if (spec.type === 'ImportSpecifier' && spec.imported.type === 'Identifier') {
170
+ if (spec.imported.name === 'Tag') {
171
+ tagImports[spec.local.name] = moduleSource;
172
+ }
173
+ }
174
+ });
175
+ }
176
+ }
177
+ },
178
+ JSXElement: function JSXElement(node) {
179
+ if (!isNodeOfType(node, 'JSXElement')) {
180
+ return;
181
+ }
182
+ if (!isNodeOfType(node.openingElement.name, 'JSXIdentifier')) {
183
+ return;
184
+ }
185
+ var elementName = node.openingElement.name.name;
186
+
187
+ // Only process if this is a Lozenge component we've imported
188
+ if (!lozengeImports[elementName]) {
189
+ return;
190
+ }
191
+ var attributesMap = getAttributesMap(node.openingElement.attributes);
192
+ var appearanceProp = attributesMap.appearance;
193
+ var isBoldProp = attributesMap.isBold;
194
+
195
+ // Handle appearance prop migration
196
+ if (appearanceProp) {
197
+ context.report({
198
+ node: appearanceProp,
199
+ messageId: 'replaceAppearance',
200
+ fix: function fix(fixer) {
201
+ var fixes = [];
202
+ // Always rename the prop name
203
+ fixes.push(fixer.replaceText(appearanceProp.name, 'color'));
204
+
205
+ // Also map the value if it's a string literal and we're not migrating to Tag
206
+ var shouldMigrateToTag = !isBoldProp || isLiteralFalse(isBoldProp.value);
207
+ if (!shouldMigrateToTag) {
208
+ var stringValue = extractStringValue(appearanceProp.value);
209
+ if (stringValue && typeof stringValue === 'string') {
210
+ var mappedColor = mapAppearanceToLozengeColor(stringValue);
211
+ if (mappedColor !== stringValue) {
212
+ // Update the value if it changed
213
+ if (appearanceProp.value.type === 'Literal') {
214
+ fixes.push(fixer.replaceText(appearanceProp.value, "\"".concat(mappedColor, "\"")));
215
+ } else if (appearanceProp.value.type === 'JSXExpressionContainer' && appearanceProp.value.expression && appearanceProp.value.expression.type === 'Literal') {
216
+ fixes.push(fixer.replaceText(appearanceProp.value.expression, "\"".concat(mappedColor, "\"")));
217
+ }
218
+ }
219
+ }
220
+ }
221
+ return fixes;
222
+ }
223
+ });
224
+ }
225
+
226
+ // Handle isBold prop and Tag migration
227
+ if (isBoldProp) {
228
+ if (isLiteralFalse(isBoldProp.value)) {
229
+ // isBold={false} should migrate to Tag
230
+ context.report({
231
+ node: node,
232
+ messageId: 'migrateTag',
233
+ fix: function fix(fixer) {
234
+ var replacement = generateTagReplacement(node, elementName);
235
+ return fixer.replaceText(node, replacement);
236
+ }
237
+ });
238
+ } else if (isDynamicExpression(isBoldProp.value)) {
239
+ // Dynamic isBold requires manual review
240
+ context.report({
241
+ node: isBoldProp,
242
+ messageId: 'manualReview'
243
+ });
244
+ }
245
+ // isBold={true} or isBold (implicit true) - no action needed
246
+ } else {
247
+ // No isBold prop means implicit false, should migrate to Tag
248
+ context.report({
249
+ node: node,
250
+ messageId: 'migrateTag',
251
+ fix: function fix(fixer) {
252
+ var replacement = generateTagReplacement(node, elementName);
253
+ return fixer.replaceText(node, replacement);
254
+ }
255
+ });
256
+ }
257
+ }
258
+ };
259
+ }
260
+ });
261
+ export default rule;
@@ -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::5aac2d8dc7c2832bcb8a96a143d60db5>>
3
+ * @codegen <<SignedSource::7fae089db9d7d7153fea58c673bd56af>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  import type { Linter } from 'eslint';
@@ -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::43ea4411c4e338a916772d4bfda146cc>>
3
+ * @codegen <<SignedSource::655d7f24171da0dff60003d0f235e48a>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  import type { ESLint } from 'eslint';
@@ -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::3328b9c675a0d09876dcfbc5d29bc63f>>
3
+ * @codegen <<SignedSource::44a03b30a12e3b52d720c16785c9c649>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  import type { Linter } from 'eslint';
@@ -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::b28f895280627b7a35f059f90783644a>>
3
+ * @codegen <<SignedSource::0311febdad396820af1b01dd2825b63f>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  import type { ESLint } from 'eslint';
@@ -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::732bff0fc39d7ff05b6688694101698d>>
3
+ * @codegen <<SignedSource::75f94fc6b6fa998eed54b610e41bb9b1>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  import type { Rule } from 'eslint';
@@ -0,0 +1,2 @@
1
+ declare const rule: import("eslint").Rule.RuleModule;
2
+ export default rule;
@@ -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::5aac2d8dc7c2832bcb8a96a143d60db5>>
3
+ * @codegen <<SignedSource::7fae089db9d7d7153fea58c673bd56af>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  import type { Linter } from 'eslint';
@@ -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::43ea4411c4e338a916772d4bfda146cc>>
3
+ * @codegen <<SignedSource::655d7f24171da0dff60003d0f235e48a>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  import type { ESLint } from 'eslint';
@@ -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::3328b9c675a0d09876dcfbc5d29bc63f>>
3
+ * @codegen <<SignedSource::44a03b30a12e3b52d720c16785c9c649>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  import type { Linter } from 'eslint';
@@ -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::b28f895280627b7a35f059f90783644a>>
3
+ * @codegen <<SignedSource::0311febdad396820af1b01dd2825b63f>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  import type { ESLint } from 'eslint';
@@ -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::732bff0fc39d7ff05b6688694101698d>>
3
+ * @codegen <<SignedSource::75f94fc6b6fa998eed54b610e41bb9b1>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  import type { Rule } from 'eslint';
@@ -0,0 +1,2 @@
1
+ declare const rule: import("eslint").Rule.RuleModule;
2
+ export default rule;
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.23.4",
4
+ "version": "13.24.0",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
7
7
  "publishConfig": {