@atlaskit/eslint-plugin-design-system 13.14.2 → 13.16.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 +24 -0
- package/README.md +2 -0
- package/dist/cjs/presets/all-flat.codegen.js +3 -1
- package/dist/cjs/presets/all.codegen.js +3 -1
- package/dist/cjs/presets/recommended-flat.codegen.js +2 -1
- package/dist/cjs/presets/recommended.codegen.js +2 -1
- package/dist/cjs/rules/ensure-proper-xcss-usage/index.js +157 -0
- package/dist/cjs/rules/index.codegen.js +5 -1
- package/dist/cjs/rules/no-legacy-icons/checks.js +22 -5
- package/dist/cjs/rules/no-legacy-icons/helpers.js +122 -46
- package/dist/cjs/rules/no-utility-icons/checks.js +233 -0
- package/dist/cjs/rules/no-utility-icons/index.js +40 -0
- package/dist/cjs/rules/utils/get-deprecated-config.js +1 -1
- package/dist/es2019/presets/all-flat.codegen.js +3 -1
- package/dist/es2019/presets/all.codegen.js +3 -1
- package/dist/es2019/presets/recommended-flat.codegen.js +2 -1
- package/dist/es2019/presets/recommended.codegen.js +2 -1
- package/dist/es2019/rules/ensure-proper-xcss-usage/index.js +149 -0
- package/dist/es2019/rules/index.codegen.js +5 -1
- package/dist/es2019/rules/no-legacy-icons/checks.js +22 -6
- package/dist/es2019/rules/no-legacy-icons/helpers.js +125 -44
- package/dist/es2019/rules/no-utility-icons/checks.js +164 -0
- package/dist/es2019/rules/no-utility-icons/index.js +35 -0
- package/dist/es2019/rules/utils/get-deprecated-config.js +3 -2
- package/dist/esm/presets/all-flat.codegen.js +3 -1
- package/dist/esm/presets/all.codegen.js +3 -1
- package/dist/esm/presets/recommended-flat.codegen.js +2 -1
- package/dist/esm/presets/recommended.codegen.js +2 -1
- package/dist/esm/rules/ensure-proper-xcss-usage/index.js +151 -0
- package/dist/esm/rules/index.codegen.js +5 -1
- package/dist/esm/rules/no-legacy-icons/checks.js +22 -5
- package/dist/esm/rules/no-legacy-icons/helpers.js +121 -45
- package/dist/esm/rules/no-utility-icons/checks.js +226 -0
- package/dist/esm/rules/no-utility-icons/index.js +34 -0
- package/dist/esm/rules/utils/get-deprecated-config.js +2 -2
- package/dist/types/index.codegen.d.ts +14 -0
- package/dist/types/presets/all-flat.codegen.d.ts +2 -0
- package/dist/types/presets/all.codegen.d.ts +2 -0
- package/dist/types/presets/recommended-flat.codegen.d.ts +1 -0
- package/dist/types/presets/recommended.codegen.d.ts +1 -0
- package/dist/types/rules/ensure-proper-xcss-usage/index.d.ts +3 -0
- package/dist/types/rules/index.codegen.d.ts +2 -0
- package/dist/types/rules/no-legacy-icons/helpers.d.ts +12 -4
- package/dist/types/rules/no-utility-icons/checks.d.ts +10 -0
- package/dist/types/rules/no-utility-icons/index.d.ts +3 -0
- package/dist/types/rules/use-tokens-typography/transformers/banned-properties.d.ts +1 -1
- package/dist/types/rules/use-tokens-typography/transformers/font-family.d.ts +1 -1
- package/dist/types/rules/use-tokens-typography/transformers/font-weight.d.ts +1 -1
- package/dist/types/rules/use-tokens-typography/transformers/restricted-capitalisation.d.ts +1 -1
- package/dist/types/rules/use-tokens-typography/transformers/untokenized-properties.d.ts +1 -1
- package/dist/types-ts4.5/index.codegen.d.ts +14 -0
- package/dist/types-ts4.5/presets/all-flat.codegen.d.ts +2 -0
- package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -0
- package/dist/types-ts4.5/presets/recommended-flat.codegen.d.ts +1 -0
- package/dist/types-ts4.5/presets/recommended.codegen.d.ts +1 -0
- package/dist/types-ts4.5/rules/ensure-proper-xcss-usage/index.d.ts +3 -0
- package/dist/types-ts4.5/rules/index.codegen.d.ts +2 -0
- package/dist/types-ts4.5/rules/no-legacy-icons/helpers.d.ts +12 -4
- package/dist/types-ts4.5/rules/no-utility-icons/checks.d.ts +10 -0
- package/dist/types-ts4.5/rules/no-utility-icons/index.d.ts +3 -0
- package/dist/types-ts4.5/rules/use-tokens-typography/transformers/banned-properties.d.ts +1 -1
- package/dist/types-ts4.5/rules/use-tokens-typography/transformers/font-family.d.ts +1 -1
- package/dist/types-ts4.5/rules/use-tokens-typography/transformers/font-weight.d.ts +1 -1
- package/dist/types-ts4.5/rules/use-tokens-typography/transformers/restricted-capitalisation.d.ts +1 -1
- package/dist/types-ts4.5/rules/use-tokens-typography/transformers/untokenized-properties.d.ts +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-design-system
|
|
2
2
|
|
|
3
|
+
## 13.16.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#157767](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/157767)
|
|
8
|
+
[`f3d552d85708a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f3d552d85708a) -
|
|
9
|
+
Introduces new ESLint rule to identify, discourage, and, where possible, fix use of utility icons.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 13.15.0
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- [#149822](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/149822)
|
|
20
|
+
[`f9ab0e846ae21`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f9ab0e846ae21) -
|
|
21
|
+
Updated to support `size` prop for new icons from `@atlaskit/icon`.
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- Updated dependencies
|
|
26
|
+
|
|
3
27
|
## 13.14.2
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -53,6 +53,7 @@ module.exports = {
|
|
|
53
53
|
| <a href="./packages/design-system/eslint-plugin/src/rules/ensure-design-token-usage/README.md">ensure-design-token-usage</a> | Enforces usage of design tokens rather than hard-coded values. | Yes | Yes | Yes |
|
|
54
54
|
| <a href="./packages/design-system/eslint-plugin/src/rules/ensure-design-token-usage-preview/README.md">ensure-design-token-usage/preview</a> | Enforces usage of pre-release design tokens rather than hard-coded values. | | Yes | Yes |
|
|
55
55
|
| <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. | | | |
|
|
56
|
+
| <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. | | | |
|
|
56
57
|
| <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 | |
|
|
57
58
|
| <a href="./packages/design-system/eslint-plugin/src/rules/no-banned-imports/README.md">no-banned-imports</a> | Disallow importing banned modules. | Yes | | |
|
|
58
59
|
| <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 | | |
|
|
@@ -89,6 +90,7 @@ module.exports = {
|
|
|
89
90
|
| <a href="./packages/design-system/eslint-plugin/src/rules/no-unsafe-design-token-usage/README.md">no-unsafe-design-token-usage</a> | Enforces design token usage is statically and locally analyzable. | Yes | Yes | |
|
|
90
91
|
| <a href="./packages/design-system/eslint-plugin/src/rules/no-unsafe-style-overrides/README.md">no-unsafe-style-overrides</a> | Discourage usage of unsafe style overrides used against the Atlassian Design System. | Yes | | |
|
|
91
92
|
| <a href="./packages/design-system/eslint-plugin/src/rules/no-unsupported-drag-and-drop-libraries/README.md">no-unsupported-drag-and-drop-libraries</a> | Disallow importing unsupported drag and drop modules. | Yes | | |
|
|
93
|
+
| <a href="./packages/design-system/eslint-plugin/src/rules/no-utility-icons/README.md">no-utility-icons</a> | Disallow use of deprecated utility icons, in favor of core icons with `size="small"`. | Yes | Yes | Yes |
|
|
92
94
|
| <a href="./packages/design-system/eslint-plugin/src/rules/prefer-primitives/README.md">prefer-primitives</a> | Increase awareness of primitive components via code hints. Strictly used for education purposes and discoverability. To enforce usage please refer to the `use-primitives` rule. | | | |
|
|
93
95
|
| <a href="./packages/design-system/eslint-plugin/src/rules/use-button-group-label/README.md">use-button-group-label</a> | Ensures button groups are described to assistive technology by a direct label or by another element. | Yes | | Yes |
|
|
94
96
|
| <a href="./packages/design-system/eslint-plugin/src/rules/use-cx-function-in-xcss/README.md">use-cx-function-in-xcss</a> | Enforces cx function use to combine styles in xcss. | Yes | Yes | 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::5ceb45b21744434ca96a850461a3c574>>
|
|
10
10
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
11
11
|
*/
|
|
12
12
|
var _default = exports.default = {
|
|
@@ -17,6 +17,7 @@ var _default = exports.default = {
|
|
|
17
17
|
'@atlaskit/design-system/ensure-design-token-usage': 'error',
|
|
18
18
|
'@atlaskit/design-system/ensure-design-token-usage/preview': 'warn',
|
|
19
19
|
'@atlaskit/design-system/ensure-icon-color': 'error',
|
|
20
|
+
'@atlaskit/design-system/ensure-proper-xcss-usage': 'error',
|
|
20
21
|
'@atlaskit/design-system/icon-label': 'warn',
|
|
21
22
|
'@atlaskit/design-system/no-banned-imports': 'error',
|
|
22
23
|
'@atlaskit/design-system/no-boolean-autofocus-on-modal-dialog': 'warn',
|
|
@@ -52,6 +53,7 @@ var _default = exports.default = {
|
|
|
52
53
|
'@atlaskit/design-system/no-unsafe-design-token-usage': 'error',
|
|
53
54
|
'@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
|
|
54
55
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
56
|
+
'@atlaskit/design-system/no-utility-icons': 'warn',
|
|
55
57
|
'@atlaskit/design-system/prefer-primitives': 'warn',
|
|
56
58
|
'@atlaskit/design-system/use-button-group-label': 'warn',
|
|
57
59
|
'@atlaskit/design-system/use-cx-function-in-xcss': '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::b96d8bb5115de6e0a230feef152a1365>>
|
|
10
10
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
11
11
|
*/
|
|
12
12
|
var _default = exports.default = {
|
|
@@ -16,6 +16,7 @@ var _default = exports.default = {
|
|
|
16
16
|
'@atlaskit/design-system/ensure-design-token-usage': 'error',
|
|
17
17
|
'@atlaskit/design-system/ensure-design-token-usage/preview': 'warn',
|
|
18
18
|
'@atlaskit/design-system/ensure-icon-color': 'error',
|
|
19
|
+
'@atlaskit/design-system/ensure-proper-xcss-usage': 'error',
|
|
19
20
|
'@atlaskit/design-system/icon-label': 'warn',
|
|
20
21
|
'@atlaskit/design-system/no-banned-imports': 'error',
|
|
21
22
|
'@atlaskit/design-system/no-boolean-autofocus-on-modal-dialog': 'warn',
|
|
@@ -51,6 +52,7 @@ var _default = exports.default = {
|
|
|
51
52
|
'@atlaskit/design-system/no-unsafe-design-token-usage': 'error',
|
|
52
53
|
'@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
|
|
53
54
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
55
|
+
'@atlaskit/design-system/no-utility-icons': 'warn',
|
|
54
56
|
'@atlaskit/design-system/prefer-primitives': 'warn',
|
|
55
57
|
'@atlaskit/design-system/use-button-group-label': 'warn',
|
|
56
58
|
'@atlaskit/design-system/use-cx-function-in-xcss': '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::10f372e16c048db9bfb1bc36cf48421c>>
|
|
10
10
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
11
11
|
*/
|
|
12
12
|
var _default = exports.default = {
|
|
@@ -41,6 +41,7 @@ var _default = exports.default = {
|
|
|
41
41
|
'@atlaskit/design-system/no-unsafe-design-token-usage': 'error',
|
|
42
42
|
'@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
|
|
43
43
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
44
|
+
'@atlaskit/design-system/no-utility-icons': 'warn',
|
|
44
45
|
'@atlaskit/design-system/use-button-group-label': 'warn',
|
|
45
46
|
'@atlaskit/design-system/use-cx-function-in-xcss': 'error',
|
|
46
47
|
'@atlaskit/design-system/use-datetime-picker-calendar-button': 'warn',
|
|
@@ -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::608f46f9cc8653226152a8edc34849d6>>
|
|
10
10
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
11
11
|
*/
|
|
12
12
|
var _default = exports.default = {
|
|
@@ -40,6 +40,7 @@ var _default = exports.default = {
|
|
|
40
40
|
'@atlaskit/design-system/no-unsafe-design-token-usage': 'error',
|
|
41
41
|
'@atlaskit/design-system/no-unsafe-style-overrides': 'warn',
|
|
42
42
|
'@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 'error',
|
|
43
|
+
'@atlaskit/design-system/no-utility-icons': 'warn',
|
|
43
44
|
'@atlaskit/design-system/use-button-group-label': 'warn',
|
|
44
45
|
'@atlaskit/design-system/use-cx-function-in-xcss': 'error',
|
|
45
46
|
'@atlaskit/design-system/use-datetime-picker-calendar-button': 'warn',
|
|
@@ -0,0 +1,157 @@
|
|
|
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 _errorBoundary = require("../utils/error-boundary");
|
|
10
|
+
var rule = (0, _createRule.createLintRule)({
|
|
11
|
+
meta: {
|
|
12
|
+
name: 'ensure-proper-xcss-usage',
|
|
13
|
+
docs: {
|
|
14
|
+
description: 'Enforces proper xcss usage: migrate from xcss() to cssMap() and use cssMap objects with specific keys.',
|
|
15
|
+
recommended: false,
|
|
16
|
+
severity: 'error'
|
|
17
|
+
},
|
|
18
|
+
messages: {
|
|
19
|
+
missingCssMapKey: 'xcss prop should use a specific key from cssMap (e.g., {{identifier}}.root) instead of the entire cssMap object.',
|
|
20
|
+
noXcssWithCompiled: 'Cannot use `xcss()` function with `@atlaskit/primitives/compiled`. Use `cssMap()` from `@atlaskit/css or `@compiled/react` instead.'
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
create: function create(context) {
|
|
24
|
+
var tracker = {
|
|
25
|
+
// Components tracking
|
|
26
|
+
compiledComponents: new Set(),
|
|
27
|
+
// Function tracking
|
|
28
|
+
cssMapFunction: new Set(),
|
|
29
|
+
xcssFunction: new Set(),
|
|
30
|
+
// Variables tracking
|
|
31
|
+
cssMapVariables: new Map(),
|
|
32
|
+
xcssVariables: new Set()
|
|
33
|
+
};
|
|
34
|
+
return (0, _errorBoundary.errorBoundary)({
|
|
35
|
+
// Track all imports in a single handler
|
|
36
|
+
ImportDeclaration: function ImportDeclaration(node) {
|
|
37
|
+
var source = node.source.value;
|
|
38
|
+
node.specifiers.forEach(function (specifier) {
|
|
39
|
+
if (specifier.type !== 'ImportSpecifier') {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Handle different import sources
|
|
44
|
+
switch (source) {
|
|
45
|
+
case '@atlaskit/primitives/compiled':
|
|
46
|
+
tracker.compiledComponents.add(specifier.imported.name);
|
|
47
|
+
break;
|
|
48
|
+
case '@atlaskit/primitives':
|
|
49
|
+
if (specifier.imported.name === 'xcss') {
|
|
50
|
+
tracker.xcssFunction.add(specifier.local.name);
|
|
51
|
+
}
|
|
52
|
+
break;
|
|
53
|
+
case '@atlaskit/css':
|
|
54
|
+
case '@compiled/react':
|
|
55
|
+
if (specifier.imported.name === 'cssMap') {
|
|
56
|
+
tracker.cssMapFunction.add(specifier.local.name);
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
},
|
|
62
|
+
// Track variable declarations
|
|
63
|
+
VariableDeclarator: function VariableDeclarator(node) {
|
|
64
|
+
if (!node.init || node.init.type !== 'CallExpression' || node.init.callee.type !== 'Identifier' || node.id.type !== 'Identifier') {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
var calleeName = node.init.callee.name;
|
|
68
|
+
var variableName = node.id.name;
|
|
69
|
+
|
|
70
|
+
// Track cssMap variables and extract their keys
|
|
71
|
+
if (tracker.cssMapFunction.has(calleeName)) {
|
|
72
|
+
var keys = new Set();
|
|
73
|
+
|
|
74
|
+
// Extract keys from the cssMap object argument
|
|
75
|
+
if (node.init.arguments.length > 0 && node.init.arguments[0].type === 'ObjectExpression') {
|
|
76
|
+
node.init.arguments[0].properties.forEach(function (prop) {
|
|
77
|
+
if (prop.type === 'Property' && prop.key.type === 'Identifier') {
|
|
78
|
+
keys.add(prop.key.name);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
tracker.cssMapVariables.set(variableName, keys);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Track xcss variables
|
|
86
|
+
if (tracker.xcssFunction.has(calleeName)) {
|
|
87
|
+
tracker.xcssVariables.add(variableName);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
// Check JSX elements for xcss prop usage
|
|
91
|
+
JSXElement: function JSXElement(node) {
|
|
92
|
+
var _xcssAttribute$value;
|
|
93
|
+
if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'JSXElement')) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
var elementName = node.openingElement.name;
|
|
97
|
+
if (elementName.type !== 'JSXIdentifier') {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
var componentName = elementName.name;
|
|
101
|
+
if (!tracker.compiledComponents.has(componentName)) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Find xcss attribute
|
|
106
|
+
var xcssAttribute = node.openingElement.attributes.find(function (attr) {
|
|
107
|
+
return attr.type === 'JSXAttribute' && attr.name.name === 'xcss';
|
|
108
|
+
});
|
|
109
|
+
if ((xcssAttribute === null || xcssAttribute === void 0 || (_xcssAttribute$value = xcssAttribute.value) === null || _xcssAttribute$value === void 0 ? void 0 : _xcssAttribute$value.type) !== 'JSXExpressionContainer') {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
var expression = xcssAttribute.value.expression;
|
|
113
|
+
|
|
114
|
+
// Check for direct xcss function calls
|
|
115
|
+
if (expression.type === 'CallExpression' && expression.callee.type === 'Identifier' && tracker.xcssFunction.has(expression.callee.name)) {
|
|
116
|
+
context.report({
|
|
117
|
+
node: expression,
|
|
118
|
+
messageId: 'noXcssWithCompiled'
|
|
119
|
+
});
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Check for variables
|
|
124
|
+
if (expression.type === 'Identifier') {
|
|
125
|
+
var identifierName = expression.name;
|
|
126
|
+
if (tracker.xcssVariables.has(identifierName)) {
|
|
127
|
+
context.report({
|
|
128
|
+
node: expression,
|
|
129
|
+
messageId: 'noXcssWithCompiled'
|
|
130
|
+
});
|
|
131
|
+
} else if (tracker.cssMapVariables.has(identifierName)) {
|
|
132
|
+
context.report({
|
|
133
|
+
node: expression,
|
|
134
|
+
messageId: 'missingCssMapKey',
|
|
135
|
+
data: {
|
|
136
|
+
identifier: identifierName
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Check member expressions (e.g., styles.root)
|
|
144
|
+
if (expression.type === 'MemberExpression' && expression.object.type === 'Identifier') {
|
|
145
|
+
var objectName = expression.object.name;
|
|
146
|
+
if (tracker.xcssVariables.has(objectName)) {
|
|
147
|
+
context.report({
|
|
148
|
+
node: expression,
|
|
149
|
+
messageId: 'noXcssWithCompiled'
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
var _default = exports.default = rule;
|
|
@@ -9,6 +9,7 @@ var _consistentCssPropUsage = _interopRequireDefault(require("./consistent-css-p
|
|
|
9
9
|
var _ensureDesignTokenUsage = _interopRequireDefault(require("./ensure-design-token-usage"));
|
|
10
10
|
var _ensureDesignTokenUsagePreview = _interopRequireDefault(require("./ensure-design-token-usage-preview"));
|
|
11
11
|
var _ensureIconColor = _interopRequireDefault(require("./ensure-icon-color"));
|
|
12
|
+
var _ensureProperXcssUsage = _interopRequireDefault(require("./ensure-proper-xcss-usage"));
|
|
12
13
|
var _iconLabel = _interopRequireDefault(require("./icon-label"));
|
|
13
14
|
var _noBannedImports = _interopRequireDefault(require("./no-banned-imports"));
|
|
14
15
|
var _noBooleanAutofocusOnModalDialog = _interopRequireDefault(require("./no-boolean-autofocus-on-modal-dialog"));
|
|
@@ -45,6 +46,7 @@ var _noStyledTaggedTemplateExpression = _interopRequireDefault(require("./no-sty
|
|
|
45
46
|
var _noUnsafeDesignTokenUsage = _interopRequireDefault(require("./no-unsafe-design-token-usage"));
|
|
46
47
|
var _noUnsafeStyleOverrides = _interopRequireDefault(require("./no-unsafe-style-overrides"));
|
|
47
48
|
var _noUnsupportedDragAndDropLibraries = _interopRequireDefault(require("./no-unsupported-drag-and-drop-libraries"));
|
|
49
|
+
var _noUtilityIcons = _interopRequireDefault(require("./no-utility-icons"));
|
|
48
50
|
var _preferPrimitives = _interopRequireDefault(require("./prefer-primitives"));
|
|
49
51
|
var _useButtonGroupLabel = _interopRequireDefault(require("./use-button-group-label"));
|
|
50
52
|
var _useCxFunctionInXcss = _interopRequireDefault(require("./use-cx-function-in-xcss"));
|
|
@@ -68,7 +70,7 @@ var _useTokensTypography = _interopRequireDefault(require("./use-tokens-typograp
|
|
|
68
70
|
var _useVisuallyHidden = _interopRequireDefault(require("./use-visually-hidden"));
|
|
69
71
|
/**
|
|
70
72
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
71
|
-
* @codegen <<SignedSource::
|
|
73
|
+
* @codegen <<SignedSource::3de5d5b44aa01faabdb840bc7fb43d04>>
|
|
72
74
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
|
|
73
75
|
*/
|
|
74
76
|
|
|
@@ -77,6 +79,7 @@ var rules = exports.rules = {
|
|
|
77
79
|
'ensure-design-token-usage': _ensureDesignTokenUsage.default,
|
|
78
80
|
'ensure-design-token-usage/preview': _ensureDesignTokenUsagePreview.default,
|
|
79
81
|
'ensure-icon-color': _ensureIconColor.default,
|
|
82
|
+
'ensure-proper-xcss-usage': _ensureProperXcssUsage.default,
|
|
80
83
|
'icon-label': _iconLabel.default,
|
|
81
84
|
'no-banned-imports': _noBannedImports.default,
|
|
82
85
|
'no-boolean-autofocus-on-modal-dialog': _noBooleanAutofocusOnModalDialog.default,
|
|
@@ -113,6 +116,7 @@ var rules = exports.rules = {
|
|
|
113
116
|
'no-unsafe-design-token-usage': _noUnsafeDesignTokenUsage.default,
|
|
114
117
|
'no-unsafe-style-overrides': _noUnsafeStyleOverrides.default,
|
|
115
118
|
'no-unsupported-drag-and-drop-libraries': _noUnsupportedDragAndDropLibraries.default,
|
|
119
|
+
'no-utility-icons': _noUtilityIcons.default,
|
|
116
120
|
'prefer-primitives': _preferPrimitives.default,
|
|
117
121
|
'use-button-group-label': _useButtonGroupLabel.default,
|
|
118
122
|
'use-cx-function-in-xcss': _useCxFunctionInXcss.default,
|
|
@@ -20,6 +20,8 @@ var createChecks = exports.createChecks = function createChecks(context) {
|
|
|
20
20
|
var legacyButtonImports = new Set();
|
|
21
21
|
var errorsManual = {};
|
|
22
22
|
var errorsAuto = {};
|
|
23
|
+
var iconSizesInfo = {}; //Import source key, locations as value
|
|
24
|
+
|
|
23
25
|
var guidance = {};
|
|
24
26
|
|
|
25
27
|
// Extract parameters
|
|
@@ -391,6 +393,7 @@ var createChecks = exports.createChecks = function createChecks(context) {
|
|
|
391
393
|
|
|
392
394
|
// Legacy icons rendered as JSX elements
|
|
393
395
|
if (Object.keys(legacyIconImports).includes(name)) {
|
|
396
|
+
var _sizeProp$value2;
|
|
394
397
|
// Determine if inside a new button - if so:
|
|
395
398
|
// - Assume spread props are safe - still error if props explicitly set to unmigratable values
|
|
396
399
|
var insideNewButton = (0, _helpers.isInsideNewButton)(node, newButtonImports);
|
|
@@ -489,7 +492,7 @@ var createChecks = exports.createChecks = function createChecks(context) {
|
|
|
489
492
|
var isNewIconMigratable = (0, _helpers.canAutoMigrateNewIconBasedOnSize)(upcomingIcon ? upcomingIcon.sizeGuidance[size !== null && size !== void 0 ? size : 'medium'] : migrationMapObject === null || migrationMapObject === void 0 ? void 0 : migrationMapObject.sizeGuidance[size !== null && size !== void 0 ? size : 'medium']);
|
|
490
493
|
|
|
491
494
|
// Add spacing if:
|
|
492
|
-
// 1. size is medium for core/utility icons or
|
|
495
|
+
// 1. size is medium for core/utility icons or not set (default is medium for core and small for utility icons)
|
|
493
496
|
// 2. not inside a new or legacy button (except for icon-only legacy buttons)
|
|
494
497
|
var sizeProp = node.openingElement.attributes.find(function (attribute) {
|
|
495
498
|
return attribute.type === 'JSXAttribute' && (attribute.name.name === 'size' || attribute.name.name === 'LEGACY_size');
|
|
@@ -500,13 +503,24 @@ var createChecks = exports.createChecks = function createChecks(context) {
|
|
|
500
503
|
if (sizeProp && sizeProp.type === 'JSXAttribute' && ((_sizeProp$value = sizeProp.value) === null || _sizeProp$value === void 0 ? void 0 : _sizeProp$value.type) === 'Literal') {
|
|
501
504
|
if (sizeProp.value.value === 'medium') {
|
|
502
505
|
spacing = 'spacious';
|
|
503
|
-
} else if (sizeProp.value.value === 'small' && (newIcon === null || newIcon === void 0 ? void 0 : newIcon.type) === 'utility') {
|
|
504
|
-
spacing = 'compact';
|
|
505
506
|
}
|
|
506
507
|
} else if (!sizeProp) {
|
|
507
508
|
spacing = 'spacious';
|
|
508
509
|
}
|
|
509
510
|
}
|
|
511
|
+
if (!iconSizesInfo[legacyIconImports[name].packageName]) {
|
|
512
|
+
iconSizesInfo[legacyIconImports[name].packageName] = {
|
|
513
|
+
small: [],
|
|
514
|
+
usageCount: 0
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
// Do not automatically migration if size is small as we cannot determine if a core icon or a scaled down utility icon should be used
|
|
519
|
+
if (sizeProp && sizeProp.type === 'JSXAttribute' && ((_sizeProp$value2 = sizeProp.value) === null || _sizeProp$value2 === void 0 ? void 0 : _sizeProp$value2.type) === 'Literal' && sizeProp.value.value === 'small') {
|
|
520
|
+
iconSizesInfo[legacyIconImports[name].packageName].small.push((0, _helpers.locToString)(node));
|
|
521
|
+
}
|
|
522
|
+
iconSizesInfo[legacyIconImports[name].packageName].usageCount++;
|
|
523
|
+
var shouldForceSmallIcon = newIcon === null || newIcon === void 0 ? void 0 : newIcon.shouldForceSmallIcon;
|
|
510
524
|
if (shouldUseSafeMigrationMode && !hasManualMigration && (newIcon !== null && newIcon !== void 0 && newIcon.isMigrationUnsafe || size !== 'medium' || hasSecondaryColorProp)) {
|
|
511
525
|
(0, _helpers.createCantFindSuitableReplacementError)(node, legacyIconImports[name].packageName, name, errorsManual, upcomingIcon ? true : migrationMapObject ? true : false);
|
|
512
526
|
} else if (!hasManualMigration && (newIcon || upcomingIcon) && isNewIconMigratable) {
|
|
@@ -516,7 +530,8 @@ var createChecks = exports.createChecks = function createChecks(context) {
|
|
|
516
530
|
iconName: name,
|
|
517
531
|
errors: errorsAuto,
|
|
518
532
|
spacing: spacing,
|
|
519
|
-
insideNewButton: insideNewButton
|
|
533
|
+
insideNewButton: insideNewButton,
|
|
534
|
+
shouldForceSmallIcon: shouldForceSmallIcon
|
|
520
535
|
});
|
|
521
536
|
} else if ((!newIcon && !upcomingIcon || !isNewIconMigratable) && size) {
|
|
522
537
|
(0, _helpers.createCantFindSuitableReplacementError)(node, legacyIconImports[name].packageName, name, errorsManual, upcomingIcon ? true : migrationMapObject ? true : false);
|
|
@@ -526,7 +541,8 @@ var createChecks = exports.createChecks = function createChecks(context) {
|
|
|
526
541
|
iconPackage: legacyIconImports[name].packageName,
|
|
527
542
|
insideNewButton: insideNewButton,
|
|
528
543
|
size: size && (0, _helpers.isSize)(size) ? size : undefined,
|
|
529
|
-
shouldUseMigrationPath: shouldUseMigrationPath
|
|
544
|
+
shouldUseMigrationPath: shouldUseMigrationPath,
|
|
545
|
+
shouldForceSmallIcon: shouldForceSmallIcon
|
|
530
546
|
});
|
|
531
547
|
}
|
|
532
548
|
};
|
|
@@ -577,6 +593,7 @@ var createChecks = exports.createChecks = function createChecks(context) {
|
|
|
577
593
|
(0, _helpers.throwAutoErrors)({
|
|
578
594
|
errorsManual: errorsManual,
|
|
579
595
|
errorsAuto: errorsAuto,
|
|
596
|
+
iconSizesInfo: iconSizesInfo,
|
|
580
597
|
legacyIconImports: legacyIconImports,
|
|
581
598
|
guidance: guidance,
|
|
582
599
|
migrationIconImports: migrationIconImports,
|