@atlaskit/eslint-plugin-design-system 13.24.0 → 13.24.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/eslint-plugin-design-system
2
2
 
3
+ ## 13.24.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`9e8597d0a762f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9e8597d0a762f) -
8
+ Update lozenge-appearance-and-isbold-migration rule to preserve appearance prop (no color prop
9
+ change)
10
+
3
11
  ## 13.24.0
4
12
 
5
13
  ### Minor Changes
package/README.md CHANGED
@@ -112,7 +112,7 @@ module.exports = {
112
112
  | <a href="./packages/design-system/eslint-plugin/src/rules/use-primitives/README.md">use-primitives</a> | Encourage the usage of primitives components. | | Yes | Yes |
113
113
  | <a href="./packages/design-system/eslint-plugin/src/rules/use-primitives-text/README.md">use-primitives-text</a> | Encourage the usage of text components. | | Yes | Yes |
114
114
  | <a href="./packages/design-system/eslint-plugin/src/rules/use-should-render-to-parent/README.md">use-should-render-to-parent</a> | Encourages makers to use the `shouldRenderToParent` where possible in Atlassian Design System `Popup` and `DropdownMenu` components. | Yes | | Yes |
115
- | <a href="./packages/design-system/eslint-plugin/src/rules/use-spotlight-package/README.md">use-spotlight-package</a> | Discourage the use of deprecated imports from @atlaskit/onboarding in favor of @atlaskit/spotlight. | | Yes | Yes |
115
+ | <a href="./packages/design-system/eslint-plugin/src/rules/use-spotlight-package/README.md">use-spotlight-package</a> | Discourage the use of @atlaskit/onboarding in favor of @atlaskit/spotlight. | | Yes | Yes |
116
116
  | <a href="./packages/design-system/eslint-plugin/src/rules/use-tag-group-label/README.md">use-tag-group-label</a> | Ensures tag groups are described to assistive technology by a direct label or by another element. | Yes | | Yes |
117
117
  | <a href="./packages/design-system/eslint-plugin/src/rules/use-tokens-shape/README.md">use-tokens-shape</a> | Enforces usage of shape design tokens rather than hard-coded values. | | Yes | Yes |
118
118
  | <a href="./packages/design-system/eslint-plugin/src/rules/use-tokens-space/README.md">use-tokens-space</a> | Enforces usage of space design tokens rather than hard-coded values. | | Yes | Yes |
@@ -17,7 +17,7 @@ var rule = (0, _createRule.createLintRule)({
17
17
  severity: 'warn'
18
18
  },
19
19
  messages: {
20
- replaceAppearance: "'appearance' prop on <Lozenge> is deprecated — use 'color' instead.",
20
+ updateAppearance: 'Update appearance value to new semantic value.',
21
21
  migrateTag: 'Non-bold <Lozenge> variants should migrate to <Tag> component.',
22
22
  manualReview: "Dynamic 'isBold' props require manual review before migration."
23
23
  }
@@ -27,7 +27,6 @@ var rule = (0, _createRule.createLintRule)({
27
27
  * Contains a map of imported Lozenge components.
28
28
  */
29
29
  var lozengeImports = {}; // local name -> import source
30
- var tagImports = {}; // local name -> import source
31
30
 
32
31
  /**
33
32
  * Check if a JSX attribute value is a literal false
@@ -61,33 +60,20 @@ var rule = (0, _createRule.createLintRule)({
61
60
  }
62
61
 
63
62
  /**
64
- * Map Lozenge appearance values to Tag color values
63
+ * Map old appearance values to new semantic appearance values
64
+ * Both Lozenge and Tag now use the same appearance prop with new semantic values
65
65
  */
66
- function mapAppearanceToTagColor(appearanceValue) {
66
+ function mapToNewAppearanceValue(oldValue) {
67
67
  var mapping = {
68
- success: 'lime',
69
- default: 'standard',
70
- removed: 'red',
71
- inprogress: 'blue',
72
- new: 'purple',
73
- moved: 'orange'
68
+ success: 'success',
69
+ default: 'default',
70
+ removed: 'removed',
71
+ inprogress: 'inprogress',
72
+ new: 'new',
73
+ moved: 'moved'
74
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;
75
+ // TODO: Update this mapping based on actual new semantic values when provided
76
+ return mapping[oldValue] || oldValue;
91
77
  }
92
78
 
93
79
  /**
@@ -109,11 +95,11 @@ var rule = (0, _createRule.createLintRule)({
109
95
  /**
110
96
  * Generate the replacement JSX element text
111
97
  */
112
- function generateTagReplacement(node, lozengeLocalName) {
98
+ function generateTagReplacement(node) {
113
99
  var sourceCode = context.getSourceCode();
114
100
  var attributes = node.openingElement.attributes;
115
101
 
116
- // Build new attributes array, excluding isBold and mapping appearance to color
102
+ // Build new attributes array, excluding isBold and mapping appearance values to new semantics
117
103
  var newAttributes = [];
118
104
  attributes.forEach(function (attr) {
119
105
  if (attr.type === 'JSXAttribute' && attr.name.type === 'JSXIdentifier') {
@@ -123,15 +109,15 @@ var rule = (0, _createRule.createLintRule)({
123
109
  return;
124
110
  }
125
111
  if (attrName === 'appearance') {
126
- // Map appearance to color with value transformation
112
+ // Map appearance value to new semantic value but keep the prop name as appearance
127
113
  var stringValue = extractStringValue(attr.value);
128
114
  if (stringValue && typeof stringValue === 'string') {
129
- var mappedColor = mapAppearanceToTagColor(stringValue);
130
- newAttributes.push("color=\"".concat(mappedColor, "\""));
115
+ var mappedAppearance = mapToNewAppearanceValue(stringValue);
116
+ newAttributes.push("appearance=\"".concat(mappedAppearance, "\""));
131
117
  } else {
132
- // If we can't extract the string value, keep as-is but rename to color
118
+ // If we can't extract the string value, keep as-is with appearance prop
133
119
  var value = attr.value ? sourceCode.getText(attr.value) : '';
134
- newAttributes.push("color".concat(value ? "=".concat(value) : ''));
120
+ newAttributes.push("appearance".concat(value ? "=".concat(value) : ''));
135
121
  }
136
122
  return;
137
123
  }
@@ -167,18 +153,6 @@ var rule = (0, _createRule.createLintRule)({
167
153
  }
168
154
  });
169
155
  }
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
156
  }
183
157
  },
184
158
  JSXElement: function JSXElement(node) {
@@ -198,35 +172,30 @@ var rule = (0, _createRule.createLintRule)({
198
172
  var appearanceProp = attributesMap.appearance;
199
173
  var isBoldProp = attributesMap.isBold;
200
174
 
201
- // Handle appearance prop migration
175
+ // Handle appearance prop value migration
202
176
  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
177
+ var shouldMigrateToTag = !isBoldProp || isLiteralFalse(isBoldProp.value);
178
+ if (!shouldMigrateToTag) {
179
+ // Only update appearance values for Lozenge components that stay as Lozenge
180
+ var stringValue = extractStringValue(appearanceProp.value);
181
+ if (stringValue && typeof stringValue === 'string') {
182
+ var mappedValue = mapToNewAppearanceValue(stringValue);
183
+ if (mappedValue !== stringValue) {
184
+ context.report({
185
+ node: appearanceProp,
186
+ messageId: 'updateAppearance',
187
+ fix: function fix(fixer) {
219
188
  if (appearanceProp.value.type === 'Literal') {
220
- fixes.push(fixer.replaceText(appearanceProp.value, "\"".concat(mappedColor, "\"")));
189
+ return fixer.replaceText(appearanceProp.value, "\"".concat(mappedValue, "\""));
221
190
  } else if (appearanceProp.value.type === 'JSXExpressionContainer' && appearanceProp.value.expression && appearanceProp.value.expression.type === 'Literal') {
222
- fixes.push(fixer.replaceText(appearanceProp.value.expression, "\"".concat(mappedColor, "\"")));
191
+ return fixer.replaceText(appearanceProp.value.expression, "\"".concat(mappedValue, "\""));
223
192
  }
193
+ return null;
224
194
  }
225
- }
195
+ });
226
196
  }
227
- return fixes;
228
197
  }
229
- });
198
+ }
230
199
  }
231
200
 
232
201
  // Handle isBold prop and Tag migration
@@ -237,7 +206,7 @@ var rule = (0, _createRule.createLintRule)({
237
206
  node: node,
238
207
  messageId: 'migrateTag',
239
208
  fix: function fix(fixer) {
240
- var replacement = generateTagReplacement(node, elementName);
209
+ var replacement = generateTagReplacement(node);
241
210
  return fixer.replaceText(node, replacement);
242
211
  }
243
212
  });
@@ -255,7 +224,7 @@ var rule = (0, _createRule.createLintRule)({
255
224
  node: node,
256
225
  messageId: 'migrateTag',
257
226
  fix: function fix(fixer) {
258
- var replacement = generateTagReplacement(node, elementName);
227
+ var replacement = generateTagReplacement(node);
259
228
  return fixer.replaceText(node, replacement);
260
229
  }
261
230
  });
@@ -11,7 +11,7 @@ const rule = createLintRule({
11
11
  severity: 'warn'
12
12
  },
13
13
  messages: {
14
- replaceAppearance: "'appearance' prop on <Lozenge> is deprecated — use 'color' instead.",
14
+ updateAppearance: 'Update appearance value to new semantic value.',
15
15
  migrateTag: 'Non-bold <Lozenge> variants should migrate to <Tag> component.',
16
16
  manualReview: "Dynamic 'isBold' props require manual review before migration."
17
17
  }
@@ -21,7 +21,6 @@ const rule = createLintRule({
21
21
  * Contains a map of imported Lozenge components.
22
22
  */
23
23
  const lozengeImports = {}; // local name -> import source
24
- const tagImports = {}; // local name -> import source
25
24
 
26
25
  /**
27
26
  * Check if a JSX attribute value is a literal false
@@ -55,33 +54,20 @@ const rule = createLintRule({
55
54
  }
56
55
 
57
56
  /**
58
- * Map Lozenge appearance values to Tag color values
57
+ * Map old appearance values to new semantic appearance values
58
+ * Both Lozenge and Tag now use the same appearance prop with new semantic values
59
59
  */
60
- function mapAppearanceToTagColor(appearanceValue) {
60
+ function mapToNewAppearanceValue(oldValue) {
61
61
  const mapping = {
62
- success: 'lime',
63
- default: 'standard',
64
- removed: 'red',
65
- inprogress: 'blue',
66
- new: 'purple',
67
- moved: 'orange'
62
+ success: 'success',
63
+ default: 'default',
64
+ removed: 'removed',
65
+ inprogress: 'inprogress',
66
+ new: 'new',
67
+ moved: 'moved'
68
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;
69
+ // TODO: Update this mapping based on actual new semantic values when provided
70
+ return mapping[oldValue] || oldValue;
85
71
  }
86
72
 
87
73
  /**
@@ -103,11 +89,11 @@ const rule = createLintRule({
103
89
  /**
104
90
  * Generate the replacement JSX element text
105
91
  */
106
- function generateTagReplacement(node, lozengeLocalName) {
92
+ function generateTagReplacement(node) {
107
93
  const sourceCode = context.getSourceCode();
108
94
  const attributes = node.openingElement.attributes;
109
95
 
110
- // Build new attributes array, excluding isBold and mapping appearance to color
96
+ // Build new attributes array, excluding isBold and mapping appearance values to new semantics
111
97
  const newAttributes = [];
112
98
  attributes.forEach(attr => {
113
99
  if (attr.type === 'JSXAttribute' && attr.name.type === 'JSXIdentifier') {
@@ -117,15 +103,15 @@ const rule = createLintRule({
117
103
  return;
118
104
  }
119
105
  if (attrName === 'appearance') {
120
- // Map appearance to color with value transformation
106
+ // Map appearance value to new semantic value but keep the prop name as appearance
121
107
  const stringValue = extractStringValue(attr.value);
122
108
  if (stringValue && typeof stringValue === 'string') {
123
- const mappedColor = mapAppearanceToTagColor(stringValue);
124
- newAttributes.push(`color="${mappedColor}"`);
109
+ const mappedAppearance = mapToNewAppearanceValue(stringValue);
110
+ newAttributes.push(`appearance="${mappedAppearance}"`);
125
111
  } else {
126
- // If we can't extract the string value, keep as-is but rename to color
112
+ // If we can't extract the string value, keep as-is with appearance prop
127
113
  const value = attr.value ? sourceCode.getText(attr.value) : '';
128
- newAttributes.push(`color${value ? `=${value}` : ''}`);
114
+ newAttributes.push(`appearance${value ? `=${value}` : ''}`);
129
115
  }
130
116
  return;
131
117
  }
@@ -161,18 +147,6 @@ const rule = createLintRule({
161
147
  }
162
148
  });
163
149
  }
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
150
  }
177
151
  },
178
152
  JSXElement(node) {
@@ -192,35 +166,30 @@ const rule = createLintRule({
192
166
  const appearanceProp = attributesMap.appearance;
193
167
  const isBoldProp = attributesMap.isBold;
194
168
 
195
- // Handle appearance prop migration
169
+ // Handle appearance prop value migration
196
170
  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
171
+ const shouldMigrateToTag = !isBoldProp || isLiteralFalse(isBoldProp.value);
172
+ if (!shouldMigrateToTag) {
173
+ // Only update appearance values for Lozenge components that stay as Lozenge
174
+ const stringValue = extractStringValue(appearanceProp.value);
175
+ if (stringValue && typeof stringValue === 'string') {
176
+ const mappedValue = mapToNewAppearanceValue(stringValue);
177
+ if (mappedValue !== stringValue) {
178
+ context.report({
179
+ node: appearanceProp,
180
+ messageId: 'updateAppearance',
181
+ fix: fixer => {
213
182
  if (appearanceProp.value.type === 'Literal') {
214
- fixes.push(fixer.replaceText(appearanceProp.value, `"${mappedColor}"`));
183
+ return fixer.replaceText(appearanceProp.value, `"${mappedValue}"`);
215
184
  } else if (appearanceProp.value.type === 'JSXExpressionContainer' && appearanceProp.value.expression && appearanceProp.value.expression.type === 'Literal') {
216
- fixes.push(fixer.replaceText(appearanceProp.value.expression, `"${mappedColor}"`));
185
+ return fixer.replaceText(appearanceProp.value.expression, `"${mappedValue}"`);
217
186
  }
187
+ return null;
218
188
  }
219
- }
189
+ });
220
190
  }
221
- return fixes;
222
191
  }
223
- });
192
+ }
224
193
  }
225
194
 
226
195
  // Handle isBold prop and Tag migration
@@ -231,7 +200,7 @@ const rule = createLintRule({
231
200
  node: node,
232
201
  messageId: 'migrateTag',
233
202
  fix: fixer => {
234
- const replacement = generateTagReplacement(node, elementName);
203
+ const replacement = generateTagReplacement(node);
235
204
  return fixer.replaceText(node, replacement);
236
205
  }
237
206
  });
@@ -249,7 +218,7 @@ const rule = createLintRule({
249
218
  node: node,
250
219
  messageId: 'migrateTag',
251
220
  fix: fixer => {
252
- const replacement = generateTagReplacement(node, elementName);
221
+ const replacement = generateTagReplacement(node);
253
222
  return fixer.replaceText(node, replacement);
254
223
  }
255
224
  });
@@ -11,7 +11,7 @@ var rule = createLintRule({
11
11
  severity: 'warn'
12
12
  },
13
13
  messages: {
14
- replaceAppearance: "'appearance' prop on <Lozenge> is deprecated — use 'color' instead.",
14
+ updateAppearance: 'Update appearance value to new semantic value.',
15
15
  migrateTag: 'Non-bold <Lozenge> variants should migrate to <Tag> component.',
16
16
  manualReview: "Dynamic 'isBold' props require manual review before migration."
17
17
  }
@@ -21,7 +21,6 @@ var rule = createLintRule({
21
21
  * Contains a map of imported Lozenge components.
22
22
  */
23
23
  var lozengeImports = {}; // local name -> import source
24
- var tagImports = {}; // local name -> import source
25
24
 
26
25
  /**
27
26
  * Check if a JSX attribute value is a literal false
@@ -55,33 +54,20 @@ var rule = createLintRule({
55
54
  }
56
55
 
57
56
  /**
58
- * Map Lozenge appearance values to Tag color values
57
+ * Map old appearance values to new semantic appearance values
58
+ * Both Lozenge and Tag now use the same appearance prop with new semantic values
59
59
  */
60
- function mapAppearanceToTagColor(appearanceValue) {
60
+ function mapToNewAppearanceValue(oldValue) {
61
61
  var mapping = {
62
- success: 'lime',
63
- default: 'standard',
64
- removed: 'red',
65
- inprogress: 'blue',
66
- new: 'purple',
67
- moved: 'orange'
62
+ success: 'success',
63
+ default: 'default',
64
+ removed: 'removed',
65
+ inprogress: 'inprogress',
66
+ new: 'new',
67
+ moved: 'moved'
68
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;
69
+ // TODO: Update this mapping based on actual new semantic values when provided
70
+ return mapping[oldValue] || oldValue;
85
71
  }
86
72
 
87
73
  /**
@@ -103,11 +89,11 @@ var rule = createLintRule({
103
89
  /**
104
90
  * Generate the replacement JSX element text
105
91
  */
106
- function generateTagReplacement(node, lozengeLocalName) {
92
+ function generateTagReplacement(node) {
107
93
  var sourceCode = context.getSourceCode();
108
94
  var attributes = node.openingElement.attributes;
109
95
 
110
- // Build new attributes array, excluding isBold and mapping appearance to color
96
+ // Build new attributes array, excluding isBold and mapping appearance values to new semantics
111
97
  var newAttributes = [];
112
98
  attributes.forEach(function (attr) {
113
99
  if (attr.type === 'JSXAttribute' && attr.name.type === 'JSXIdentifier') {
@@ -117,15 +103,15 @@ var rule = createLintRule({
117
103
  return;
118
104
  }
119
105
  if (attrName === 'appearance') {
120
- // Map appearance to color with value transformation
106
+ // Map appearance value to new semantic value but keep the prop name as appearance
121
107
  var stringValue = extractStringValue(attr.value);
122
108
  if (stringValue && typeof stringValue === 'string') {
123
- var mappedColor = mapAppearanceToTagColor(stringValue);
124
- newAttributes.push("color=\"".concat(mappedColor, "\""));
109
+ var mappedAppearance = mapToNewAppearanceValue(stringValue);
110
+ newAttributes.push("appearance=\"".concat(mappedAppearance, "\""));
125
111
  } else {
126
- // If we can't extract the string value, keep as-is but rename to color
112
+ // If we can't extract the string value, keep as-is with appearance prop
127
113
  var value = attr.value ? sourceCode.getText(attr.value) : '';
128
- newAttributes.push("color".concat(value ? "=".concat(value) : ''));
114
+ newAttributes.push("appearance".concat(value ? "=".concat(value) : ''));
129
115
  }
130
116
  return;
131
117
  }
@@ -161,18 +147,6 @@ var rule = createLintRule({
161
147
  }
162
148
  });
163
149
  }
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
150
  }
177
151
  },
178
152
  JSXElement: function JSXElement(node) {
@@ -192,35 +166,30 @@ var rule = createLintRule({
192
166
  var appearanceProp = attributesMap.appearance;
193
167
  var isBoldProp = attributesMap.isBold;
194
168
 
195
- // Handle appearance prop migration
169
+ // Handle appearance prop value migration
196
170
  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
171
+ var shouldMigrateToTag = !isBoldProp || isLiteralFalse(isBoldProp.value);
172
+ if (!shouldMigrateToTag) {
173
+ // Only update appearance values for Lozenge components that stay as Lozenge
174
+ var stringValue = extractStringValue(appearanceProp.value);
175
+ if (stringValue && typeof stringValue === 'string') {
176
+ var mappedValue = mapToNewAppearanceValue(stringValue);
177
+ if (mappedValue !== stringValue) {
178
+ context.report({
179
+ node: appearanceProp,
180
+ messageId: 'updateAppearance',
181
+ fix: function fix(fixer) {
213
182
  if (appearanceProp.value.type === 'Literal') {
214
- fixes.push(fixer.replaceText(appearanceProp.value, "\"".concat(mappedColor, "\"")));
183
+ return fixer.replaceText(appearanceProp.value, "\"".concat(mappedValue, "\""));
215
184
  } else if (appearanceProp.value.type === 'JSXExpressionContainer' && appearanceProp.value.expression && appearanceProp.value.expression.type === 'Literal') {
216
- fixes.push(fixer.replaceText(appearanceProp.value.expression, "\"".concat(mappedColor, "\"")));
185
+ return fixer.replaceText(appearanceProp.value.expression, "\"".concat(mappedValue, "\""));
217
186
  }
187
+ return null;
218
188
  }
219
- }
189
+ });
220
190
  }
221
- return fixes;
222
191
  }
223
- });
192
+ }
224
193
  }
225
194
 
226
195
  // Handle isBold prop and Tag migration
@@ -231,7 +200,7 @@ var rule = createLintRule({
231
200
  node: node,
232
201
  messageId: 'migrateTag',
233
202
  fix: function fix(fixer) {
234
- var replacement = generateTagReplacement(node, elementName);
203
+ var replacement = generateTagReplacement(node);
235
204
  return fixer.replaceText(node, replacement);
236
205
  }
237
206
  });
@@ -249,7 +218,7 @@ var rule = createLintRule({
249
218
  node: node,
250
219
  messageId: 'migrateTag',
251
220
  fix: function fix(fixer) {
252
- var replacement = generateTagReplacement(node, elementName);
221
+ var replacement = generateTagReplacement(node);
253
222
  return fixer.replaceText(node, replacement);
254
223
  }
255
224
  });
@@ -1,2 +1,3 @@
1
- declare const rule: import("eslint").Rule.RuleModule;
1
+ import type { Rule } from 'eslint';
2
+ declare const rule: Rule.RuleModule;
2
3
  export default rule;
@@ -1,2 +1,3 @@
1
- declare const rule: import("eslint").Rule.RuleModule;
1
+ import type { Rule } from 'eslint';
2
+ declare const rule: Rule.RuleModule;
2
3
  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.24.0",
4
+ "version": "13.24.1",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
7
7
  "publishConfig": {