@atlaskit/eslint-plugin-design-system 13.23.3 → 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.
- package/CHANGELOG.md +17 -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/presets/recommended-flat.codegen.js +2 -1
- package/dist/cjs/presets/recommended.codegen.js +2 -1
- package/dist/cjs/rules/index.codegen.js +3 -1
- package/dist/cjs/rules/lozenge-appearance-and-isbold-migration/index.js +267 -0
- package/dist/cjs/rules/no-deprecated-imports/handlers/icon.js +13 -14
- package/dist/cjs/rules/no-legacy-icons/helpers.js +2 -2
- package/dist/cjs/rules/utils/get-deprecated-config.js +1 -1
- package/dist/es2019/presets/all-flat.codegen.js +2 -1
- package/dist/es2019/presets/all.codegen.js +2 -1
- package/dist/es2019/presets/recommended-flat.codegen.js +2 -1
- package/dist/es2019/presets/recommended.codegen.js +2 -1
- package/dist/es2019/rules/index.codegen.js +3 -1
- package/dist/es2019/rules/lozenge-appearance-and-isbold-migration/index.js +261 -0
- package/dist/es2019/rules/no-deprecated-imports/handlers/icon.js +8 -9
- package/dist/es2019/rules/no-legacy-icons/helpers.js +2 -2
- package/dist/es2019/rules/utils/get-deprecated-config.js +1 -2
- package/dist/esm/presets/all-flat.codegen.js +2 -1
- package/dist/esm/presets/all.codegen.js +2 -1
- package/dist/esm/presets/recommended-flat.codegen.js +2 -1
- package/dist/esm/presets/recommended.codegen.js +2 -1
- package/dist/esm/rules/index.codegen.js +3 -1
- package/dist/esm/rules/lozenge-appearance-and-isbold-migration/index.js +261 -0
- package/dist/esm/rules/no-deprecated-imports/handlers/icon.js +12 -13
- package/dist/esm/rules/no-legacy-icons/helpers.js +2 -2
- package/dist/esm/rules/utils/get-deprecated-config.js +2 -2
- package/dist/types/presets/all-flat.codegen.d.ts +1 -1
- package/dist/types/presets/all.codegen.d.ts +1 -1
- package/dist/types/presets/recommended-flat.codegen.d.ts +1 -1
- package/dist/types/presets/recommended.codegen.d.ts +1 -1
- package/dist/types/rules/index.codegen.d.ts +1 -1
- package/dist/types/rules/lozenge-appearance-and-isbold-migration/index.d.ts +2 -0
- package/dist/types/rules/no-legacy-icons/helpers.d.ts +0 -2
- package/dist/types-ts4.5/presets/all-flat.codegen.d.ts +1 -1
- package/dist/types-ts4.5/presets/all.codegen.d.ts +1 -1
- package/dist/types-ts4.5/presets/recommended-flat.codegen.d.ts +1 -1
- package/dist/types-ts4.5/presets/recommended.codegen.d.ts +1 -1
- package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -1
- package/dist/types-ts4.5/rules/lozenge-appearance-and-isbold-migration/index.d.ts +2 -0
- package/dist/types-ts4.5/rules/no-legacy-icons/helpers.d.ts +0 -2
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
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
|
+
|
|
11
|
+
## 13.23.4
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`f0d92beae2f40`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f0d92beae2f40) -
|
|
16
|
+
Removes utility icons entrypoints from the '@atlaskit/icon' package. Migrates related packages to
|
|
17
|
+
update their imports.
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 13.23.3
|
|
4
21
|
|
|
5
22
|
### 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::
|
|
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::
|
|
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::
|
|
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::
|
|
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::
|
|
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;
|
|
@@ -7,8 +7,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.getDeprecationIconHandler = void 0;
|
|
8
8
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
9
|
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
10
|
-
var
|
|
11
|
-
var
|
|
10
|
+
var _metadata2 = _interopRequireDefault(require("@atlaskit/icon-lab/metadata"));
|
|
11
|
+
var _metadata3 = require("@atlaskit/icon/metadata");
|
|
12
12
|
var _constants = require("../constants");
|
|
13
13
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
14
14
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
@@ -75,43 +75,42 @@ var getDeprecationIconHandler = exports.getDeprecationIconHandler = function get
|
|
|
75
75
|
importSource = _Object$entries$_i[0],
|
|
76
76
|
error = _Object$entries$_i[1];
|
|
77
77
|
if (importSource.includes('/migration/')) {
|
|
78
|
-
var
|
|
78
|
+
var _coreIconMetadata$dep, _error$data;
|
|
79
79
|
var _importSource$split$s = importSource.split('/').slice(1),
|
|
80
80
|
_importSource$split$s2 = (0, _slicedToArray2.default)(_importSource$split$s, 4),
|
|
81
81
|
_location = _importSource$split$s2[0],
|
|
82
|
-
|
|
82
|
+
_ = _importSource$split$s2[1],
|
|
83
83
|
_migration = _importSource$split$s2[2],
|
|
84
84
|
name = _importSource$split$s2[3];
|
|
85
|
-
var metadata = type === 'core' ? _metadata4.coreIconMetadata : _metadata4.utilityIconMetadata;
|
|
86
85
|
var _name$split = name.split('--'),
|
|
87
86
|
_name$split2 = (0, _slicedToArray2.default)(_name$split, 2),
|
|
88
87
|
deprecatedIconName = _name$split2[0],
|
|
89
88
|
legacyIconName = _name$split2[1];
|
|
90
|
-
var replacement =
|
|
89
|
+
var replacement = (_coreIconMetadata$dep = _metadata3.coreIconMetadata[deprecatedIconName]) === null || _coreIconMetadata$dep === void 0 ? void 0 : _coreIconMetadata$dep.replacement;
|
|
91
90
|
if (replacement && ((_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.unfixable) === 'false') {
|
|
92
91
|
var newIconName = getIconComponentName(replacement.name);
|
|
93
92
|
if (!shouldTurnOffAutoFixer) {
|
|
94
|
-
addAutoFix(error, importSource, "".concat(replacement.location, "/
|
|
93
|
+
addAutoFix(error, importSource, "".concat(replacement.location, "/core/migration/").concat(replacement.name, "--").concat(legacyIconName), newIconName);
|
|
95
94
|
}
|
|
96
95
|
}
|
|
97
96
|
} else {
|
|
98
|
-
var
|
|
97
|
+
var _metadata;
|
|
99
98
|
var _importSource$split$s3 = importSource.split('/').slice(1),
|
|
100
99
|
_importSource$split$s4 = (0, _slicedToArray2.default)(_importSource$split$s3, 3),
|
|
101
100
|
location = _importSource$split$s4[0],
|
|
102
|
-
|
|
101
|
+
_2 = _importSource$split$s4[1],
|
|
103
102
|
_name = _importSource$split$s4[2];
|
|
104
|
-
var
|
|
103
|
+
var metadata = void 0;
|
|
105
104
|
if (location === 'icon') {
|
|
106
|
-
|
|
105
|
+
metadata = _metadata3.coreIconMetadata;
|
|
107
106
|
} else if (location === 'icon-lab') {
|
|
108
|
-
|
|
107
|
+
metadata = _metadata2.default;
|
|
109
108
|
}
|
|
110
|
-
var _replacement = (
|
|
109
|
+
var _replacement = (_metadata = metadata) === null || _metadata === void 0 || (_metadata = _metadata[_name]) === null || _metadata === void 0 ? void 0 : _metadata.replacement;
|
|
111
110
|
if (_replacement) {
|
|
112
111
|
var _newIconName = getIconComponentName(_replacement.name);
|
|
113
112
|
if (!shouldTurnOffAutoFixer) {
|
|
114
|
-
addAutoFix(error, importSource, "".concat(_replacement.location, "/
|
|
113
|
+
addAutoFix(error, importSource, "".concat(_replacement.location, "/core/").concat(_replacement.name), _newIconName);
|
|
115
114
|
}
|
|
116
115
|
}
|
|
117
116
|
}
|
|
@@ -80,10 +80,10 @@ var getNewIconNameAndImportPath = function getNewIconNameAndImportPath(iconPacka
|
|
|
80
80
|
return {};
|
|
81
81
|
}
|
|
82
82
|
var newIcon = migrationMapObject.newIcon;
|
|
83
|
-
var migrationPath = newIcon.name === legacyIconName ? "".concat(newIcon.package, "/
|
|
83
|
+
var migrationPath = newIcon.name === legacyIconName ? "".concat(newIcon.package, "/core/migration/").concat(newIcon.name) : "".concat(newIcon.package, "/core/migration/").concat(newIcon.name, "--").concat(legacyIconName.replaceAll('/', '-'));
|
|
84
84
|
return {
|
|
85
85
|
iconName: newIcon.name,
|
|
86
|
-
importPath: shouldUseMigrationPath ? migrationPath : "".concat(newIcon.package, "/
|
|
86
|
+
importPath: shouldUseMigrationPath ? migrationPath : "".concat(newIcon.package, "/core/").concat(newIcon.name)
|
|
87
87
|
};
|
|
88
88
|
};
|
|
89
89
|
|
|
@@ -17,7 +17,7 @@ var getConfig = exports.getConfig = function getConfig(specifier) {
|
|
|
17
17
|
var source = _fs.default.readFileSync(configPath, 'utf8');
|
|
18
18
|
var parsedConfig = JSON.parse(source);
|
|
19
19
|
var combinedConfig = _objectSpread(_objectSpread({}, parsedConfig), {}, {
|
|
20
|
-
imports: _objectSpread(_objectSpread(_objectSpread(_objectSpread(
|
|
20
|
+
imports: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, parsedConfig.imports), _deprecatedMap2.deprecatedCore), _deprecatedMap.deprecatedCore), _deprecatedMap.deprecatedUtility)
|
|
21
21
|
});
|
|
22
22
|
return combinedConfig[specifier];
|
|
23
23
|
};
|
|
@@ -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::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::
|
|
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::
|
|
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::
|
|
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::
|
|
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,
|