@atlaskit/eslint-plugin-design-system 10.12.1 → 10.12.3
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 +18 -0
- package/dist/cjs/rules/no-legacy-icons/checks.js +3 -4
- package/dist/cjs/rules/no-legacy-icons/helpers.js +22 -17
- package/dist/cjs/rules/use-heading/config/index.js +1 -0
- package/dist/cjs/rules/use-heading/index.js +3 -2
- package/dist/cjs/rules/use-latest-xcss-syntax-typography/config/index.js +12 -0
- package/dist/cjs/rules/use-latest-xcss-syntax-typography/index.js +5 -2
- package/dist/cjs/rules/use-primitives-text/config/index.js +1 -0
- package/dist/cjs/rules/use-primitives-text/index.js +3 -2
- package/dist/cjs/rules/use-tokens-typography/config/index.js +3 -0
- package/dist/es2019/rules/no-legacy-icons/checks.js +1 -2
- package/dist/es2019/rules/no-legacy-icons/helpers.js +13 -10
- package/dist/es2019/rules/use-heading/config/index.js +1 -0
- package/dist/es2019/rules/use-heading/index.js +3 -2
- package/dist/es2019/rules/use-latest-xcss-syntax-typography/config/index.js +6 -0
- package/dist/es2019/rules/use-latest-xcss-syntax-typography/index.js +5 -2
- package/dist/es2019/rules/use-primitives-text/config/index.js +1 -0
- package/dist/es2019/rules/use-primitives-text/index.js +3 -2
- package/dist/es2019/rules/use-tokens-typography/config/index.js +3 -0
- package/dist/esm/rules/no-legacy-icons/checks.js +1 -2
- package/dist/esm/rules/no-legacy-icons/helpers.js +21 -16
- package/dist/esm/rules/use-heading/config/index.js +1 -0
- package/dist/esm/rules/use-heading/index.js +3 -2
- package/dist/esm/rules/use-latest-xcss-syntax-typography/config/index.js +6 -0
- package/dist/esm/rules/use-latest-xcss-syntax-typography/index.js +5 -2
- package/dist/esm/rules/use-primitives-text/config/index.js +1 -0
- package/dist/esm/rules/use-primitives-text/index.js +3 -2
- package/dist/esm/rules/use-tokens-typography/config/index.js +3 -0
- package/dist/types/rules/no-legacy-icons/helpers.d.ts +5 -14
- package/dist/types/rules/use-heading/config/index.d.ts +1 -0
- package/dist/types/rules/use-latest-xcss-syntax-typography/config/index.d.ts +4 -0
- package/dist/types/rules/use-primitives-text/config/index.d.ts +1 -0
- package/dist/types-ts4.5/rules/no-legacy-icons/helpers.d.ts +10 -14
- package/dist/types-ts4.5/rules/use-heading/config/index.d.ts +1 -0
- package/dist/types-ts4.5/rules/use-latest-xcss-syntax-typography/config/index.d.ts +4 -0
- package/dist/types-ts4.5/rules/use-primitives-text/config/index.d.ts +1 -0
- package/package.json +2 -1
- package/dist/cjs/rules/no-legacy-icons/migration-map-temp.js +0 -4090
- package/dist/es2019/rules/no-legacy-icons/migration-map-temp.js +0 -4082
- package/dist/esm/rules/no-legacy-icons/migration-map-temp.js +0 -4084
- package/dist/types/rules/no-legacy-icons/migration-map-temp.d.ts +0 -22
- package/dist/types-ts4.5/rules/no-legacy-icons/migration-map-temp.d.ts +0 -27
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-design-system
|
|
2
2
|
|
|
3
|
+
## 10.12.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#126553](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/126553)
|
|
8
|
+
[`a8d7e60d3b69d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a8d7e60d3b69d) -
|
|
9
|
+
Update `no-legacy-icons` rule to use icon migration map from `@atlaskit/icon`.
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 10.12.2
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#124172](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/124172)
|
|
17
|
+
[`19b2005de7c1b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/19b2005de7c1b) -
|
|
18
|
+
Wrap use-heading, use-primitives-text and use-latest-xcss-syntax-typography with an error boudary
|
|
19
|
+
to stop it breaking issue-automat CI.
|
|
20
|
+
|
|
3
21
|
## 10.12.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -8,7 +8,6 @@ exports.createChecks = void 0;
|
|
|
8
8
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
9
|
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
10
10
|
var _helpers = require("./helpers");
|
|
11
|
-
var _migrationMapTemp = require("./migration-map-temp");
|
|
12
11
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, 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 normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
13
12
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
14
13
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
@@ -303,9 +302,9 @@ var createChecks = exports.createChecks = function createChecks(context) {
|
|
|
303
302
|
// Extract values of props
|
|
304
303
|
switch (attr.name.name) {
|
|
305
304
|
case 'size':
|
|
306
|
-
if ((0, _eslintCodemodUtils.isNodeOfType)(attr.value, 'Literal') && (0,
|
|
305
|
+
if ((0, _eslintCodemodUtils.isNodeOfType)(attr.value, 'Literal') && (0, _helpers.isSize)(attr.value.value)) {
|
|
307
306
|
size = attr.value.value;
|
|
308
|
-
} else if ((0, _eslintCodemodUtils.isNodeOfType)(attr.value, 'JSXExpressionContainer') && (0, _eslintCodemodUtils.isNodeOfType)(attr.value.expression, 'Literal') && (0,
|
|
307
|
+
} else if ((0, _eslintCodemodUtils.isNodeOfType)(attr.value, 'JSXExpressionContainer') && (0, _eslintCodemodUtils.isNodeOfType)(attr.value.expression, 'Literal') && (0, _helpers.isSize)(attr.value.expression.value)) {
|
|
309
308
|
size = attr.value.expression.value;
|
|
310
309
|
} else {
|
|
311
310
|
size = null;
|
|
@@ -357,7 +356,7 @@ var createChecks = exports.createChecks = function createChecks(context) {
|
|
|
357
356
|
} else if ((!newIcon || !isNewIconMigratable) && size) {
|
|
358
357
|
(0, _helpers.createCantFindSuitableReplacementError)(node, legacyIconImports[name].packageName, name, errorsManual, migrationMapObject ? true : false);
|
|
359
358
|
}
|
|
360
|
-
guidance[(0, _helpers.locToString)(node)] = (0, _helpers.createGuidance)(legacyIconImports[name].packageName, insideNewButton, size && (0,
|
|
359
|
+
guidance[(0, _helpers.locToString)(node)] = (0, _helpers.createGuidance)(legacyIconImports[name].packageName, insideNewButton, size && (0, _helpers.isSize)(size) ? size : undefined);
|
|
361
360
|
}
|
|
362
361
|
};
|
|
363
362
|
|
|
@@ -5,13 +5,18 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.locToString = exports.getMigrationMapObject = exports.getLiteralStringValue = exports.createHelpers = exports.createGuidance = exports.createCantMigrateSpreadPropsError = exports.createCantMigrateSizeUnknown = exports.createCantMigrateReExportError = exports.createCantMigrateIdentifierError = exports.createCantMigrateFunctionUnknownError = exports.createCantMigrateColorError = exports.createCantFindSuitableReplacementError = exports.createAutoMigrationError = exports.canMigrateColor = exports.canAutoMigrateNewIconBasedOnSize = void 0;
|
|
8
|
+
exports.locToString = exports.isSize = exports.getMigrationMapObject = exports.getLiteralStringValue = exports.createHelpers = exports.createGuidance = exports.createCantMigrateSpreadPropsError = exports.createCantMigrateSizeUnknown = exports.createCantMigrateReExportError = exports.createCantMigrateIdentifierError = exports.createCantMigrateFunctionUnknownError = exports.createCantMigrateColorError = exports.createCantFindSuitableReplacementError = exports.createAutoMigrationError = exports.canMigrateColor = exports.canAutoMigrateNewIconBasedOnSize = void 0;
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
10
|
var _eslintCodemodUtils = require("eslint-codemod-utils");
|
|
11
|
+
var _UNSAFE_migrationMap = _interopRequireWildcard(require("@atlaskit/icon/UNSAFE_migration-map"));
|
|
11
12
|
var _getImportName = require("../utils/get-import-name");
|
|
12
|
-
var _migrationMapTemp = _interopRequireWildcard(require("./migration-map-temp"));
|
|
13
13
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
14
14
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
+
var sizes = ['small', 'medium', 'large', 'xlarge'];
|
|
16
|
+
var isSize = exports.isSize = function isSize(size) {
|
|
17
|
+
return sizes.includes(size);
|
|
18
|
+
};
|
|
19
|
+
|
|
15
20
|
/**
|
|
16
21
|
* Returns the migration map object for a legacy icon or null if not found
|
|
17
22
|
* @param iconPackage The name of the legacy icon package
|
|
@@ -19,8 +24,8 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
19
24
|
*/
|
|
20
25
|
var getMigrationMapObject = exports.getMigrationMapObject = function getMigrationMapObject(iconPackage) {
|
|
21
26
|
var key = getIconKey(iconPackage);
|
|
22
|
-
if (key in
|
|
23
|
-
return
|
|
27
|
+
if (key in _UNSAFE_migrationMap.default) {
|
|
28
|
+
return _UNSAFE_migrationMap.default[key];
|
|
24
29
|
}
|
|
25
30
|
return null;
|
|
26
31
|
};
|
|
@@ -58,24 +63,24 @@ var createGuidance = exports.createGuidance = function createGuidance(iconPackag
|
|
|
58
63
|
var guidance = '';
|
|
59
64
|
if (size) {
|
|
60
65
|
if (migrationMapObject.sizeGuidance[size] && canAutoMigrateNewIconBasedOnSize(migrationMapObject.sizeGuidance[size])) {
|
|
61
|
-
guidance += "Fix: Use ".concat(newIcon.name, " from
|
|
66
|
+
guidance += "Fix: Use ".concat(newIcon.name, " from ").concat(newIcon.package, "/").concat(newIcon.type, "/").concat(newIcon.name, " instead.");
|
|
62
67
|
} else {
|
|
63
68
|
guidance += "No equivalent icon for this size, ".concat(size, ", in new set.");
|
|
64
69
|
}
|
|
65
|
-
guidance += "".concat(migrationMapObject.sizeGuidance[size] in
|
|
70
|
+
guidance += "".concat(migrationMapObject.sizeGuidance[size] in _UNSAFE_migrationMap.migrationOutcomeDescriptionMap ? " Please: ".concat(_UNSAFE_migrationMap.migrationOutcomeDescriptionMap[migrationMapObject.sizeGuidance[size]]) : ' No migration size advice given.', "\n");
|
|
66
71
|
} else {
|
|
67
|
-
guidance = "Use ".concat(newIcon.name, " from
|
|
68
|
-
|
|
69
|
-
var
|
|
70
|
-
|
|
71
|
-
value =
|
|
72
|
-
guidance += "\t- ".concat(
|
|
73
|
-
if (!(value in
|
|
72
|
+
guidance = "Use ".concat(newIcon.name, " from ").concat(newIcon.package, "/").concat(newIcon.type, "/").concat(newIcon.name, " instead.\nMigration suggestions, depending on the legacy icon size:\n");
|
|
73
|
+
Object.entries(migrationMapObject.sizeGuidance).forEach(function (_ref) {
|
|
74
|
+
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
75
|
+
size = _ref2[0],
|
|
76
|
+
value = _ref2[1];
|
|
77
|
+
guidance += "\t- ".concat(size, ": ");
|
|
78
|
+
if (!(value in _UNSAFE_migrationMap.migrationOutcomeDescriptionMap)) {
|
|
74
79
|
guidance += 'No migration advice given.\n';
|
|
75
80
|
} else {
|
|
76
|
-
guidance += "".concat(
|
|
81
|
+
guidance += "".concat(_UNSAFE_migrationMap.migrationOutcomeDescriptionMap[value], ".\n");
|
|
77
82
|
}
|
|
78
|
-
}
|
|
83
|
+
});
|
|
79
84
|
}
|
|
80
85
|
if (insideNewButton) {
|
|
81
86
|
guidance += buttonGuidanceStr;
|
|
@@ -254,9 +259,9 @@ var createHelpers = exports.createHelpers = function createHelpers(context) {
|
|
|
254
259
|
* Extracts the primaryColor value from a JSXAttribute
|
|
255
260
|
*/
|
|
256
261
|
getPrimaryColor: function getPrimaryColor(attr) {
|
|
257
|
-
var
|
|
262
|
+
var _ref3, _getLiteralStringValu;
|
|
258
263
|
var value = attr.value;
|
|
259
|
-
return (
|
|
264
|
+
return (_ref3 = (_getLiteralStringValu = getLiteralStringValue(value)) !== null && _getLiteralStringValu !== void 0 ? _getLiteralStringValu : getTokenCallValue(value)) !== null && _ref3 !== void 0 ? _ref3 : null;
|
|
260
265
|
},
|
|
261
266
|
getTokenCallValue: getTokenCallValue,
|
|
262
267
|
getConfigFlag: getConfigFlag
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _createRule = require("../utils/create-rule");
|
|
8
|
+
var _errorBoundary = require("../utils/error-boundary");
|
|
8
9
|
var _config = require("./config");
|
|
9
10
|
var _transformers = require("./transformers");
|
|
10
11
|
var docsUrl = 'https://atlassian.design/components/heading';
|
|
@@ -25,7 +26,7 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
25
26
|
},
|
|
26
27
|
create: function create(context) {
|
|
27
28
|
var config = (0, _config.getConfig)(context.options[0]);
|
|
28
|
-
return {
|
|
29
|
+
return (0, _errorBoundary.errorBoundary)({
|
|
29
30
|
// transforms <h1>...</h1> usages
|
|
30
31
|
'JSXElement[openingElement.name.name=/^h[0-6]$/]': function JSXElementOpeningElementNameNameH06$(node) {
|
|
31
32
|
return _transformers.NativeElements.lint(node, {
|
|
@@ -33,7 +34,7 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
33
34
|
config: config
|
|
34
35
|
});
|
|
35
36
|
}
|
|
36
|
-
};
|
|
37
|
+
}, config);
|
|
37
38
|
}
|
|
38
39
|
});
|
|
39
40
|
var _default = exports.default = rule;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getConfig = void 0;
|
|
7
|
+
var defaults = {
|
|
8
|
+
failSilently: false
|
|
9
|
+
};
|
|
10
|
+
var getConfig = exports.getConfig = function getConfig(overrides) {
|
|
11
|
+
return Object.assign({}, defaults, overrides);
|
|
12
|
+
};
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.error = exports.default = void 0;
|
|
7
7
|
var _createRule = require("../utils/create-rule");
|
|
8
|
+
var _errorBoundary = require("../utils/error-boundary");
|
|
9
|
+
var _config = require("./config");
|
|
8
10
|
var _linters = require("./linters");
|
|
9
11
|
var error = exports.error = "Don't set fontSize, lineHeight, fontWeight properties on xcss. They are unsafe as they allow invalid combinations of typography tokens. There is ongoing work to make this a TypeScript error. Once that happens, you will have to delete/refactor anyway.";
|
|
10
12
|
var rule = (0, _createRule.createLintRule)({
|
|
@@ -23,7 +25,8 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
23
25
|
}
|
|
24
26
|
},
|
|
25
27
|
create: function create(context) {
|
|
26
|
-
|
|
28
|
+
var config = (0, _config.getConfig)(context.options[0]);
|
|
29
|
+
return (0, _errorBoundary.errorBoundary)({
|
|
27
30
|
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Identifier[name=/(fontSize|lineHeight|fontWeight)/]': function CallExpressionCalleeNameXcssObjectExpressionPropertyIdentifierNameFontSizeLineHeightFontWeight(node) {
|
|
28
31
|
return _linters.BannedProperty.lint(node, {
|
|
29
32
|
context: context
|
|
@@ -34,7 +37,7 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
34
37
|
context: context
|
|
35
38
|
});
|
|
36
39
|
}
|
|
37
|
-
};
|
|
40
|
+
}, config);
|
|
38
41
|
}
|
|
39
42
|
});
|
|
40
43
|
var _default = exports.default = rule;
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getConfig = void 0;
|
|
7
7
|
var defaults = {
|
|
8
|
+
failSilently: false,
|
|
8
9
|
patterns: ['paragraph-elements', 'span-elements', 'strong-elements', 'emphasis-elements'],
|
|
9
10
|
inheritColor: false,
|
|
10
11
|
enableUnsafeAutofix: false
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _createRule = require("../utils/create-rule");
|
|
8
|
+
var _errorBoundary = require("../utils/error-boundary");
|
|
8
9
|
var _config = require("./config");
|
|
9
10
|
var _transformers = require("./transformers");
|
|
10
11
|
var textDocsUrl = 'https://atlassian.design/components/primitives/text';
|
|
@@ -26,7 +27,7 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
26
27
|
},
|
|
27
28
|
create: function create(context) {
|
|
28
29
|
var config = (0, _config.getConfig)(context.options[0]);
|
|
29
|
-
return {
|
|
30
|
+
return (0, _errorBoundary.errorBoundary)({
|
|
30
31
|
'JSXElement[openingElement.name.name=span]': function JSXElementOpeningElementNameNameSpan(node) {
|
|
31
32
|
return _transformers.SpanElements.lint(node, {
|
|
32
33
|
context: context,
|
|
@@ -51,7 +52,7 @@ var rule = (0, _createRule.createLintRule)({
|
|
|
51
52
|
config: config
|
|
52
53
|
});
|
|
53
54
|
}
|
|
54
|
-
};
|
|
55
|
+
}, config);
|
|
55
56
|
}
|
|
56
57
|
});
|
|
57
58
|
var _default = exports.default = rule;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
-
import { canAutoMigrateNewIconBasedOnSize, canMigrateColor, createAutoMigrationError, createCantFindSuitableReplacementError, createCantMigrateColorError, createCantMigrateFunctionUnknownError, createCantMigrateIdentifierError, createCantMigrateReExportError, createCantMigrateSizeUnknown, createCantMigrateSpreadPropsError, createGuidance, createHelpers, getMigrationMapObject, locToString } from './helpers';
|
|
3
|
-
import { isSize } from './migration-map-temp';
|
|
2
|
+
import { canAutoMigrateNewIconBasedOnSize, canMigrateColor, createAutoMigrationError, createCantFindSuitableReplacementError, createCantMigrateColorError, createCantMigrateFunctionUnknownError, createCantMigrateIdentifierError, createCantMigrateReExportError, createCantMigrateSizeUnknown, createCantMigrateSpreadPropsError, createGuidance, createHelpers, getMigrationMapObject, isSize, locToString } from './helpers';
|
|
4
3
|
export const createChecks = context => {
|
|
5
4
|
//create global variables to be shared by the checks
|
|
6
5
|
const {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
2
|
+
import baseMigrationMap, { migrationOutcomeDescriptionMap } from '@atlaskit/icon/UNSAFE_migration-map';
|
|
2
3
|
import { getImportName } from '../utils/get-import-name';
|
|
3
|
-
|
|
4
|
+
const sizes = ['small', 'medium', 'large', 'xlarge'];
|
|
5
|
+
export const isSize = size => sizes.includes(size);
|
|
6
|
+
|
|
4
7
|
/**
|
|
5
8
|
* Returns the migration map object for a legacy icon or null if not found
|
|
6
9
|
* @param iconPackage The name of the legacy icon package
|
|
@@ -8,8 +11,8 @@ import migrationMap, { outcomeDescriptionMap } from './migration-map-temp';
|
|
|
8
11
|
*/
|
|
9
12
|
export const getMigrationMapObject = iconPackage => {
|
|
10
13
|
const key = getIconKey(iconPackage);
|
|
11
|
-
if (key in
|
|
12
|
-
return
|
|
14
|
+
if (key in baseMigrationMap) {
|
|
15
|
+
return baseMigrationMap[key];
|
|
13
16
|
}
|
|
14
17
|
return null;
|
|
15
18
|
};
|
|
@@ -45,21 +48,21 @@ export const createGuidance = (iconPackage, insideNewButton = false, size) => {
|
|
|
45
48
|
let guidance = '';
|
|
46
49
|
if (size) {
|
|
47
50
|
if (migrationMapObject.sizeGuidance[size] && canAutoMigrateNewIconBasedOnSize(migrationMapObject.sizeGuidance[size])) {
|
|
48
|
-
guidance += `Fix: Use ${newIcon.name} from
|
|
51
|
+
guidance += `Fix: Use ${newIcon.name} from ${newIcon.package}/${newIcon.type}/${newIcon.name} instead.`;
|
|
49
52
|
} else {
|
|
50
53
|
guidance += `No equivalent icon for this size, ${size}, in new set.`;
|
|
51
54
|
}
|
|
52
|
-
guidance += `${migrationMapObject.sizeGuidance[size] in
|
|
55
|
+
guidance += `${migrationMapObject.sizeGuidance[size] in migrationOutcomeDescriptionMap ? ` Please: ${migrationOutcomeDescriptionMap[migrationMapObject.sizeGuidance[size]]}` : ' No migration size advice given.'}\n`;
|
|
53
56
|
} else {
|
|
54
|
-
guidance = `Use ${newIcon.name} from
|
|
55
|
-
|
|
57
|
+
guidance = `Use ${newIcon.name} from ${newIcon.package}/${newIcon.type}/${newIcon.name} instead.\nMigration suggestions, depending on the legacy icon size:\n`;
|
|
58
|
+
Object.entries(migrationMapObject.sizeGuidance).forEach(([size, value]) => {
|
|
56
59
|
guidance += `\t- ${size}: `;
|
|
57
|
-
if (!(value in
|
|
60
|
+
if (!(value in migrationOutcomeDescriptionMap)) {
|
|
58
61
|
guidance += 'No migration advice given.\n';
|
|
59
62
|
} else {
|
|
60
|
-
guidance += `${
|
|
63
|
+
guidance += `${migrationOutcomeDescriptionMap[value]}.\n`;
|
|
61
64
|
}
|
|
62
|
-
}
|
|
65
|
+
});
|
|
63
66
|
}
|
|
64
67
|
if (insideNewButton) {
|
|
65
68
|
guidance += buttonGuidanceStr;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createLintRule } from '../utils/create-rule';
|
|
2
|
+
import { errorBoundary } from '../utils/error-boundary';
|
|
2
3
|
import { getConfig } from './config';
|
|
3
4
|
import { NativeElements } from './transformers';
|
|
4
5
|
const docsUrl = 'https://atlassian.design/components/heading';
|
|
@@ -19,7 +20,7 @@ const rule = createLintRule({
|
|
|
19
20
|
},
|
|
20
21
|
create(context) {
|
|
21
22
|
const config = getConfig(context.options[0]);
|
|
22
|
-
return {
|
|
23
|
+
return errorBoundary({
|
|
23
24
|
// transforms <h1>...</h1> usages
|
|
24
25
|
'JSXElement[openingElement.name.name=/^h[0-6]$/]': node => {
|
|
25
26
|
return NativeElements.lint(node, {
|
|
@@ -27,7 +28,7 @@ const rule = createLintRule({
|
|
|
27
28
|
config
|
|
28
29
|
});
|
|
29
30
|
}
|
|
30
|
-
};
|
|
31
|
+
}, config);
|
|
31
32
|
}
|
|
32
33
|
});
|
|
33
34
|
export default rule;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { createLintRule } from '../utils/create-rule';
|
|
2
|
+
import { errorBoundary } from '../utils/error-boundary';
|
|
3
|
+
import { getConfig } from './config';
|
|
2
4
|
import { BannedProperty } from './linters';
|
|
3
5
|
export const error = `Don't set fontSize, lineHeight, fontWeight properties on xcss. They are unsafe as they allow invalid combinations of typography tokens. There is ongoing work to make this a TypeScript error. Once that happens, you will have to delete/refactor anyway.`;
|
|
4
6
|
const rule = createLintRule({
|
|
@@ -17,14 +19,15 @@ const rule = createLintRule({
|
|
|
17
19
|
}
|
|
18
20
|
},
|
|
19
21
|
create(context) {
|
|
20
|
-
|
|
22
|
+
const config = getConfig(context.options[0]);
|
|
23
|
+
return errorBoundary({
|
|
21
24
|
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Identifier[name=/(fontSize|lineHeight|fontWeight)/]': node => BannedProperty.lint(node, {
|
|
22
25
|
context
|
|
23
26
|
}),
|
|
24
27
|
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Literal[value=/(fontSize|lineHeight|fontWeight)/]': node => BannedProperty.lint(node, {
|
|
25
28
|
context
|
|
26
29
|
})
|
|
27
|
-
};
|
|
30
|
+
}, config);
|
|
28
31
|
}
|
|
29
32
|
});
|
|
30
33
|
export default rule;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createLintRule } from '../utils/create-rule';
|
|
2
|
+
import { errorBoundary } from '../utils/error-boundary';
|
|
2
3
|
import { getConfig } from './config';
|
|
3
4
|
import { EmphasisElements, ParagraphElements, SpanElements, StrongElements } from './transformers';
|
|
4
5
|
const textDocsUrl = 'https://atlassian.design/components/primitives/text';
|
|
@@ -20,7 +21,7 @@ const rule = createLintRule({
|
|
|
20
21
|
},
|
|
21
22
|
create(context) {
|
|
22
23
|
const config = getConfig(context.options[0]);
|
|
23
|
-
return {
|
|
24
|
+
return errorBoundary({
|
|
24
25
|
'JSXElement[openingElement.name.name=span]': node => {
|
|
25
26
|
return SpanElements.lint(node, {
|
|
26
27
|
context,
|
|
@@ -45,7 +46,7 @@ const rule = createLintRule({
|
|
|
45
46
|
config
|
|
46
47
|
});
|
|
47
48
|
}
|
|
48
|
-
};
|
|
49
|
+
}, config);
|
|
49
50
|
}
|
|
50
51
|
});
|
|
51
52
|
export default rule;
|
|
@@ -3,8 +3,7 @@ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol
|
|
|
3
3
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
4
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
5
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
6
|
-
import { canAutoMigrateNewIconBasedOnSize, canMigrateColor, createAutoMigrationError, createCantFindSuitableReplacementError, createCantMigrateColorError, createCantMigrateFunctionUnknownError, createCantMigrateIdentifierError, createCantMigrateReExportError, createCantMigrateSizeUnknown, createCantMigrateSpreadPropsError, createGuidance, createHelpers, getMigrationMapObject, locToString } from './helpers';
|
|
7
|
-
import { isSize } from './migration-map-temp';
|
|
6
|
+
import { canAutoMigrateNewIconBasedOnSize, canMigrateColor, createAutoMigrationError, createCantFindSuitableReplacementError, createCantMigrateColorError, createCantMigrateFunctionUnknownError, createCantMigrateIdentifierError, createCantMigrateReExportError, createCantMigrateSizeUnknown, createCantMigrateSpreadPropsError, createGuidance, createHelpers, getMigrationMapObject, isSize, locToString } from './helpers';
|
|
8
7
|
export var createChecks = function createChecks(context) {
|
|
9
8
|
//create global variables to be shared by the checks
|
|
10
9
|
var _createHelpers = createHelpers(context),
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import { isNodeOfType } from 'eslint-codemod-utils';
|
|
3
|
+
import baseMigrationMap, { migrationOutcomeDescriptionMap } from '@atlaskit/icon/UNSAFE_migration-map';
|
|
3
4
|
import { getImportName } from '../utils/get-import-name';
|
|
4
|
-
|
|
5
|
+
var sizes = ['small', 'medium', 'large', 'xlarge'];
|
|
6
|
+
export var isSize = function isSize(size) {
|
|
7
|
+
return sizes.includes(size);
|
|
8
|
+
};
|
|
9
|
+
|
|
5
10
|
/**
|
|
6
11
|
* Returns the migration map object for a legacy icon or null if not found
|
|
7
12
|
* @param iconPackage The name of the legacy icon package
|
|
@@ -9,8 +14,8 @@ import migrationMap, { outcomeDescriptionMap } from './migration-map-temp';
|
|
|
9
14
|
*/
|
|
10
15
|
export var getMigrationMapObject = function getMigrationMapObject(iconPackage) {
|
|
11
16
|
var key = getIconKey(iconPackage);
|
|
12
|
-
if (key in
|
|
13
|
-
return
|
|
17
|
+
if (key in baseMigrationMap) {
|
|
18
|
+
return baseMigrationMap[key];
|
|
14
19
|
}
|
|
15
20
|
return null;
|
|
16
21
|
};
|
|
@@ -48,24 +53,24 @@ export var createGuidance = function createGuidance(iconPackage) {
|
|
|
48
53
|
var guidance = '';
|
|
49
54
|
if (size) {
|
|
50
55
|
if (migrationMapObject.sizeGuidance[size] && canAutoMigrateNewIconBasedOnSize(migrationMapObject.sizeGuidance[size])) {
|
|
51
|
-
guidance += "Fix: Use ".concat(newIcon.name, " from
|
|
56
|
+
guidance += "Fix: Use ".concat(newIcon.name, " from ").concat(newIcon.package, "/").concat(newIcon.type, "/").concat(newIcon.name, " instead.");
|
|
52
57
|
} else {
|
|
53
58
|
guidance += "No equivalent icon for this size, ".concat(size, ", in new set.");
|
|
54
59
|
}
|
|
55
|
-
guidance += "".concat(migrationMapObject.sizeGuidance[size] in
|
|
60
|
+
guidance += "".concat(migrationMapObject.sizeGuidance[size] in migrationOutcomeDescriptionMap ? " Please: ".concat(migrationOutcomeDescriptionMap[migrationMapObject.sizeGuidance[size]]) : ' No migration size advice given.', "\n");
|
|
56
61
|
} else {
|
|
57
|
-
guidance = "Use ".concat(newIcon.name, " from
|
|
58
|
-
|
|
59
|
-
var
|
|
60
|
-
|
|
61
|
-
value =
|
|
62
|
-
guidance += "\t- ".concat(
|
|
63
|
-
if (!(value in
|
|
62
|
+
guidance = "Use ".concat(newIcon.name, " from ").concat(newIcon.package, "/").concat(newIcon.type, "/").concat(newIcon.name, " instead.\nMigration suggestions, depending on the legacy icon size:\n");
|
|
63
|
+
Object.entries(migrationMapObject.sizeGuidance).forEach(function (_ref) {
|
|
64
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
65
|
+
size = _ref2[0],
|
|
66
|
+
value = _ref2[1];
|
|
67
|
+
guidance += "\t- ".concat(size, ": ");
|
|
68
|
+
if (!(value in migrationOutcomeDescriptionMap)) {
|
|
64
69
|
guidance += 'No migration advice given.\n';
|
|
65
70
|
} else {
|
|
66
|
-
guidance += "".concat(
|
|
71
|
+
guidance += "".concat(migrationOutcomeDescriptionMap[value], ".\n");
|
|
67
72
|
}
|
|
68
|
-
}
|
|
73
|
+
});
|
|
69
74
|
}
|
|
70
75
|
if (insideNewButton) {
|
|
71
76
|
guidance += buttonGuidanceStr;
|
|
@@ -244,9 +249,9 @@ export var createHelpers = function createHelpers(context) {
|
|
|
244
249
|
* Extracts the primaryColor value from a JSXAttribute
|
|
245
250
|
*/
|
|
246
251
|
getPrimaryColor: function getPrimaryColor(attr) {
|
|
247
|
-
var
|
|
252
|
+
var _ref3, _getLiteralStringValu;
|
|
248
253
|
var value = attr.value;
|
|
249
|
-
return (
|
|
254
|
+
return (_ref3 = (_getLiteralStringValu = getLiteralStringValue(value)) !== null && _getLiteralStringValu !== void 0 ? _getLiteralStringValu : getTokenCallValue(value)) !== null && _ref3 !== void 0 ? _ref3 : null;
|
|
250
255
|
},
|
|
251
256
|
getTokenCallValue: getTokenCallValue,
|
|
252
257
|
getConfigFlag: getConfigFlag
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createLintRule } from '../utils/create-rule';
|
|
2
|
+
import { errorBoundary } from '../utils/error-boundary';
|
|
2
3
|
import { getConfig } from './config';
|
|
3
4
|
import { NativeElements } from './transformers';
|
|
4
5
|
var docsUrl = 'https://atlassian.design/components/heading';
|
|
@@ -19,7 +20,7 @@ var rule = createLintRule({
|
|
|
19
20
|
},
|
|
20
21
|
create: function create(context) {
|
|
21
22
|
var config = getConfig(context.options[0]);
|
|
22
|
-
return {
|
|
23
|
+
return errorBoundary({
|
|
23
24
|
// transforms <h1>...</h1> usages
|
|
24
25
|
'JSXElement[openingElement.name.name=/^h[0-6]$/]': function JSXElementOpeningElementNameNameH06$(node) {
|
|
25
26
|
return NativeElements.lint(node, {
|
|
@@ -27,7 +28,7 @@ var rule = createLintRule({
|
|
|
27
28
|
config: config
|
|
28
29
|
});
|
|
29
30
|
}
|
|
30
|
-
};
|
|
31
|
+
}, config);
|
|
31
32
|
}
|
|
32
33
|
});
|
|
33
34
|
export default rule;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { createLintRule } from '../utils/create-rule';
|
|
2
|
+
import { errorBoundary } from '../utils/error-boundary';
|
|
3
|
+
import { getConfig } from './config';
|
|
2
4
|
import { BannedProperty } from './linters';
|
|
3
5
|
export var error = "Don't set fontSize, lineHeight, fontWeight properties on xcss. They are unsafe as they allow invalid combinations of typography tokens. There is ongoing work to make this a TypeScript error. Once that happens, you will have to delete/refactor anyway.";
|
|
4
6
|
var rule = createLintRule({
|
|
@@ -17,7 +19,8 @@ var rule = createLintRule({
|
|
|
17
19
|
}
|
|
18
20
|
},
|
|
19
21
|
create: function create(context) {
|
|
20
|
-
|
|
22
|
+
var config = getConfig(context.options[0]);
|
|
23
|
+
return errorBoundary({
|
|
21
24
|
'CallExpression[callee.name="xcss"] ObjectExpression > Property > Identifier[name=/(fontSize|lineHeight|fontWeight)/]': function CallExpressionCalleeNameXcssObjectExpressionPropertyIdentifierNameFontSizeLineHeightFontWeight(node) {
|
|
22
25
|
return BannedProperty.lint(node, {
|
|
23
26
|
context: context
|
|
@@ -28,7 +31,7 @@ var rule = createLintRule({
|
|
|
28
31
|
context: context
|
|
29
32
|
});
|
|
30
33
|
}
|
|
31
|
-
};
|
|
34
|
+
}, config);
|
|
32
35
|
}
|
|
33
36
|
});
|
|
34
37
|
export default rule;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createLintRule } from '../utils/create-rule';
|
|
2
|
+
import { errorBoundary } from '../utils/error-boundary';
|
|
2
3
|
import { getConfig } from './config';
|
|
3
4
|
import { EmphasisElements, ParagraphElements, SpanElements, StrongElements } from './transformers';
|
|
4
5
|
var textDocsUrl = 'https://atlassian.design/components/primitives/text';
|
|
@@ -20,7 +21,7 @@ var rule = createLintRule({
|
|
|
20
21
|
},
|
|
21
22
|
create: function create(context) {
|
|
22
23
|
var config = getConfig(context.options[0]);
|
|
23
|
-
return {
|
|
24
|
+
return errorBoundary({
|
|
24
25
|
'JSXElement[openingElement.name.name=span]': function JSXElementOpeningElementNameNameSpan(node) {
|
|
25
26
|
return SpanElements.lint(node, {
|
|
26
27
|
context: context,
|
|
@@ -45,7 +46,7 @@ var rule = createLintRule({
|
|
|
45
46
|
config: config
|
|
46
47
|
});
|
|
47
48
|
}
|
|
48
|
-
};
|
|
49
|
+
}, config);
|
|
49
50
|
}
|
|
50
51
|
});
|
|
51
52
|
export default rule;
|