@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.
- package/CHANGELOG.md +24 -0
- package/README.md +1 -0
- package/dist/cjs/presets/all-flat.codegen.js +2 -1
- package/dist/cjs/presets/all.codegen.js +2 -1
- package/dist/cjs/rules/index.codegen.js +3 -1
- package/dist/cjs/rules/lozenge-badge-tag-labelling-system-migration/index.js +27 -124
- package/dist/cjs/rules/use-tokens-motion/index.js +555 -0
- package/dist/es2019/presets/all-flat.codegen.js +2 -1
- package/dist/es2019/presets/all.codegen.js +2 -1
- package/dist/es2019/rules/index.codegen.js +3 -1
- package/dist/es2019/rules/lozenge-badge-tag-labelling-system-migration/index.js +23 -120
- package/dist/es2019/rules/use-tokens-motion/index.js +489 -0
- package/dist/esm/presets/all-flat.codegen.js +2 -1
- package/dist/esm/presets/all.codegen.js +2 -1
- package/dist/esm/rules/index.codegen.js +3 -1
- package/dist/esm/rules/lozenge-badge-tag-labelling-system-migration/index.js +27 -124
- package/dist/esm/rules/use-tokens-motion/index.js +548 -0
- package/dist/types/presets/all-flat.codegen.d.ts +1 -1
- package/dist/types/presets/all.codegen.d.ts +1 -1
- package/dist/types/rules/index.codegen.d.ts +1 -1
- package/dist/types/rules/use-tokens-motion/index.d.ts +3 -0
- package/package.json +1 -1
|
@@ -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::
|
|
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::
|
|
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::
|
|
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: '
|
|
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
|
-
*
|
|
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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
new: '
|
|
119
|
-
|
|
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
|
|
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
|
-
//
|
|
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
|
|
307
|
-
if (
|
|
308
|
-
var
|
|
309
|
-
newAttributes.push("color=\"".concat(
|
|
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
|
|
360
|
-
if (options.isSimpleTag
|
|
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
|
|
643
|
-
if (
|
|
644
|
-
|
|
645
|
-
|
|
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: '
|
|
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
|
};
|