@atlaskit/eslint-plugin-design-system 13.20.1 → 13.21.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +1 -0
  3. package/dist/cjs/presets/all-flat.codegen.js +2 -1
  4. package/dist/cjs/presets/all.codegen.js +2 -1
  5. package/dist/cjs/rules/ensure-design-token-usage/shape.js +5 -9
  6. package/dist/cjs/rules/index.codegen.js +3 -1
  7. package/dist/cjs/rules/use-tokens-shape/index.js +54 -0
  8. package/dist/cjs/rules/use-tokens-shape/transformers/index.js +128 -0
  9. package/dist/cjs/rules/use-tokens-shape/transformers/style-map.js +49 -0
  10. package/dist/cjs/rules/use-tokens-shape/transformers/supported.js +15 -0
  11. package/dist/es2019/presets/all-flat.codegen.js +2 -1
  12. package/dist/es2019/presets/all.codegen.js +2 -1
  13. package/dist/es2019/rules/ensure-design-token-usage/shape.js +5 -7
  14. package/dist/es2019/rules/index.codegen.js +3 -1
  15. package/dist/es2019/rules/use-tokens-shape/index.js +38 -0
  16. package/dist/es2019/rules/use-tokens-shape/transformers/index.js +120 -0
  17. package/dist/es2019/rules/use-tokens-shape/transformers/style-map.js +43 -0
  18. package/dist/es2019/rules/use-tokens-shape/transformers/supported.js +9 -0
  19. package/dist/esm/presets/all-flat.codegen.js +2 -1
  20. package/dist/esm/presets/all.codegen.js +2 -1
  21. package/dist/esm/rules/ensure-design-token-usage/shape.js +5 -9
  22. package/dist/esm/rules/index.codegen.js +3 -1
  23. package/dist/esm/rules/use-tokens-shape/index.js +48 -0
  24. package/dist/esm/rules/use-tokens-shape/transformers/index.js +119 -0
  25. package/dist/esm/rules/use-tokens-shape/transformers/style-map.js +43 -0
  26. package/dist/esm/rules/use-tokens-shape/transformers/supported.js +9 -0
  27. package/dist/types/index.codegen.d.ts +5 -0
  28. package/dist/types/presets/all-flat.codegen.d.ts +1 -0
  29. package/dist/types/presets/all.codegen.d.ts +1 -0
  30. package/dist/types/rules/index.codegen.d.ts +1 -0
  31. package/dist/types/rules/use-tokens-shape/index.d.ts +3 -0
  32. package/dist/types/rules/use-tokens-shape/transformers/index.d.ts +26 -0
  33. package/dist/types/rules/use-tokens-shape/transformers/style-map.d.ts +10 -0
  34. package/dist/types/rules/use-tokens-shape/transformers/supported.d.ts +6 -0
  35. package/dist/types-ts4.5/index.codegen.d.ts +5 -0
  36. package/dist/types-ts4.5/presets/all-flat.codegen.d.ts +1 -0
  37. package/dist/types-ts4.5/presets/all.codegen.d.ts +1 -0
  38. package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
  39. package/dist/types-ts4.5/rules/use-tokens-shape/index.d.ts +3 -0
  40. package/dist/types-ts4.5/rules/use-tokens-shape/transformers/index.d.ts +26 -0
  41. package/dist/types-ts4.5/rules/use-tokens-shape/transformers/style-map.d.ts +10 -0
  42. package/dist/types-ts4.5/rules/use-tokens-shape/transformers/supported.d.ts +6 -0
  43. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @atlaskit/eslint-plugin-design-system
2
2
 
3
+ ## 13.21.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`8a95abe487d79`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8a95abe487d79) - -
8
+ Added `use-tokens-shape` rule to enforce borderRadius and borderWidth values.
9
+ - Updated `ensure-design-token-usage` rule to apply correct shape tokens. Note this rule should
10
+ not be used for shape - instead use the `use-tokens-shape` rule instead.
11
+
3
12
  ## 13.20.1
4
13
 
5
14
  ### Patch Changes
package/README.md CHANGED
@@ -112,6 +112,7 @@ module.exports = {
112
112
  | <a href="./packages/design-system/eslint-plugin/src/rules/use-primitives-text/README.md">use-primitives-text</a> | Encourage the usage of text components. | | Yes | Yes |
113
113
  | <a href="./packages/design-system/eslint-plugin/src/rules/use-should-render-to-parent/README.md">use-should-render-to-parent</a> | Encourages makers to use the `shouldRenderToParent` where possible in Atlassian Design System `Popup` and `DropdownMenu` components. | Yes | | Yes |
114
114
  | <a href="./packages/design-system/eslint-plugin/src/rules/use-tag-group-label/README.md">use-tag-group-label</a> | Ensures tag groups are described to assistive technology by a direct label or by another element. | Yes | | Yes |
115
+ | <a href="./packages/design-system/eslint-plugin/src/rules/use-tokens-shape/README.md">use-tokens-shape</a> | Enforces usage of shape design tokens rather than hard-coded values. | | Yes | Yes |
115
116
  | <a href="./packages/design-system/eslint-plugin/src/rules/use-tokens-space/README.md">use-tokens-space</a> | Enforces usage of space design tokens rather than hard-coded values. | | Yes | Yes |
116
117
  | <a href="./packages/design-system/eslint-plugin/src/rules/use-tokens-typography/README.md">use-tokens-typography</a> | Enforces usage of design tokens for typography properties rather than hard-coded values. | | Yes | Yes |
117
118
  | <a href="./packages/design-system/eslint-plugin/src/rules/use-visually-hidden/README.md">use-visually-hidden</a> | Enforce usage of the visually hidden component. | 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::e075ab709ebd382d6f5e39fd78de9d6d>>
9
+ * @codegen <<SignedSource::c8428e53319286fb2b37a107968f2be8>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
11
11
  */
12
12
  var _default = exports.default = {
@@ -75,6 +75,7 @@ var _default = exports.default = {
75
75
  '@atlaskit/design-system/use-primitives-text': 'warn',
76
76
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
77
77
  '@atlaskit/design-system/use-tag-group-label': 'warn',
78
+ '@atlaskit/design-system/use-tokens-shape': 'error',
78
79
  '@atlaskit/design-system/use-tokens-space': 'error',
79
80
  '@atlaskit/design-system/use-tokens-typography': 'warn',
80
81
  '@atlaskit/design-system/use-visually-hidden': '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::d78f5649534c2e153e3ce48063649a8a>>
9
+ * @codegen <<SignedSource::a739ba6d63b1aa39d462906ee1876ce6>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
11
11
  */
12
12
  var _default = exports.default = {
@@ -74,6 +74,7 @@ var _default = exports.default = {
74
74
  '@atlaskit/design-system/use-primitives-text': 'warn',
75
75
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
76
76
  '@atlaskit/design-system/use-tag-group-label': 'warn',
77
+ '@atlaskit/design-system/use-tokens-shape': 'error',
77
78
  '@atlaskit/design-system/use-tokens-space': 'error',
78
79
  '@atlaskit/design-system/use-tokens-typography': 'warn',
79
80
  '@atlaskit/design-system/use-visually-hidden': 'error'
@@ -11,19 +11,15 @@ exports.isShapeProperty = isShapeProperty;
11
11
  exports.radiusValueToToken = void 0;
12
12
  var _eslintCodemodUtils = require("eslint-codemod-utils");
13
13
  var _tokensRaw = require("@atlaskit/tokens/tokens-raw");
14
- var shapeProperties = ['borderTopLeftRadius', 'borderTopRightRadius', 'borderBottomRightRadius', 'borderBottomLeftRadius', 'borderRadius'];
14
+ var shapeProperties = ['borderTopLeftRadius', 'borderTopRightRadius', 'borderBottomRightRadius', 'borderBottomLeftRadius', 'borderRadius', 'borderStartStartRadius', 'borderStartEndRadius', 'borderEndStartRadius', 'borderEndEndRadius'];
15
15
  var borderSizeProperties = ['borderWidth', 'outlineWidth', 'borderRightWidth', 'borderLeftWidth', 'borderTopWidth', 'borderBottomWidth', 'borderInlineWidth', 'borderBlockWidth'];
16
16
  var radiusValueToToken = exports.radiusValueToToken = Object.fromEntries(_tokensRaw.shape.filter(function (t) {
17
- return t.name.startsWith('border.radius');
18
- })
19
- // we prefer using the default (border.radius) over its aliases
20
- .filter(function (t) {
21
- return !t.name.startsWith('border.radius.100');
17
+ return t.name.startsWith('radius');
22
18
  }).map(function (t) {
23
19
  return [t.value, t.cleanName];
24
- }).concat([['3px', 'border.radius']]) // add in an extra entry to resolve 3px to border.radius (normally 4px)
25
- .concat([['50%', 'border.radius.circle']]) // add in an extra entry to resolve 50% to border.radius.circle (normally 2002rem)
26
- );
20
+ })
21
+ // add in extra entries to resolve 3px, 50%, and 100% to tokens
22
+ .concat([['3px', 'radius.small'], ['50%', 'radius.full'], ['100%', 'radius.full']]));
27
23
  var borderWidthValueToToken = exports.borderWidthValueToToken = Object.fromEntries(_tokensRaw.shape.filter(function (t) {
28
24
  return t.name.startsWith('border.width');
29
25
  }).map(function (t) {
@@ -68,12 +68,13 @@ var _usePrimitives = _interopRequireDefault(require("./use-primitives"));
68
68
  var _usePrimitivesText = _interopRequireDefault(require("./use-primitives-text"));
69
69
  var _useShouldRenderToParent = _interopRequireDefault(require("./use-should-render-to-parent"));
70
70
  var _useTagGroupLabel = _interopRequireDefault(require("./use-tag-group-label"));
71
+ var _useTokensShape = _interopRequireDefault(require("./use-tokens-shape"));
71
72
  var _useTokensSpace = _interopRequireDefault(require("./use-tokens-space"));
72
73
  var _useTokensTypography = _interopRequireDefault(require("./use-tokens-typography"));
73
74
  var _useVisuallyHidden = _interopRequireDefault(require("./use-visually-hidden"));
74
75
  /**
75
76
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
76
- * @codegen <<SignedSource::53ad66d79f989ce9beb46ee0186685b2>>
77
+ * @codegen <<SignedSource::5fbd59fcd3fd6cb0602821de4a0a32aa>>
77
78
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
78
79
  */
79
80
 
@@ -141,6 +142,7 @@ var rules = exports.rules = {
141
142
  'use-primitives-text': _usePrimitivesText.default,
142
143
  'use-should-render-to-parent': _useShouldRenderToParent.default,
143
144
  'use-tag-group-label': _useTagGroupLabel.default,
145
+ 'use-tokens-shape': _useTokensShape.default,
144
146
  'use-tokens-space': _useTokensSpace.default,
145
147
  'use-tokens-typography': _useTokensTypography.default,
146
148
  'use-visually-hidden': _useVisuallyHidden.default
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _createRule = require("../utils/create-rule");
8
+ var _transformers = require("./transformers");
9
+ var rule = (0, _createRule.createLintRule)({
10
+ meta: {
11
+ name: 'use-tokens-shape',
12
+ type: 'problem',
13
+ fixable: 'code',
14
+ hasSuggestions: true,
15
+ docs: {
16
+ description: 'Enforces usage of shape design tokens rather than hard-coded values.',
17
+ recommended: false,
18
+ severity: 'error'
19
+ },
20
+ messages: {
21
+ noRawShapeValues: 'The use of shape tokens is preferred over the direct application of border radius and border width properties.'
22
+ }
23
+ },
24
+ create: function create(context) {
25
+ return {
26
+ 'CallExpression[callee.name="css"] ObjectExpression Property': function CallExpressionCalleeNameCss_ObjectExpression_Property(node) {
27
+ return _transformers.StyleProperty.lint(node, {
28
+ context: context
29
+ });
30
+ },
31
+ 'CallExpression[callee.name="keyframes"] ObjectExpression Property': function CallExpressionCalleeNameKeyframes_ObjectExpression_Property(node) {
32
+ return _transformers.StyleProperty.lint(node, {
33
+ context: context
34
+ });
35
+ },
36
+ 'CallExpression[callee.name="cssMap"] ObjectExpression Property': function CallExpressionCalleeNameCssMap_ObjectExpression_Property(node) {
37
+ return _transformers.StyleProperty.lint(node, {
38
+ context: context
39
+ });
40
+ },
41
+ 'CallExpression[callee.object.name=styled] ObjectExpression Property': function CallExpressionCalleeObjectNameStyled_ObjectExpression_Property(node) {
42
+ return _transformers.StyleProperty.lint(node, {
43
+ context: context
44
+ });
45
+ },
46
+ 'CallExpression[callee.object.name=styled2] ObjectExpression Property': function CallExpressionCalleeObjectNameStyled2_ObjectExpression_Property(node) {
47
+ return _transformers.StyleProperty.lint(node, {
48
+ context: context
49
+ });
50
+ }
51
+ };
52
+ }
53
+ });
54
+ var _default = exports.default = rule;
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.StyleProperty = void 0;
9
+ var _eslintCodemodUtils = require("eslint-codemod-utils");
10
+ var ast = _interopRequireWildcard(require("../../../ast-nodes"));
11
+ var _utils = require("../../use-tokens-space/utils");
12
+ var _styleMap = require("./style-map");
13
+ var _supported = _interopRequireDefault(require("./supported"));
14
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
15
+ /* eslint-disable @repo/internal/react/require-jsdoc */
16
+
17
+ var messageId = 'noRawShapeValues';
18
+ var StyleProperty = exports.StyleProperty = {
19
+ lint: function lint(node, _ref) {
20
+ var context = _ref.context;
21
+ // Check whether all criteria needed to make a transformation are met
22
+ var _StyleProperty$_check = StyleProperty._check(node),
23
+ success = _StyleProperty$_check.success,
24
+ ref = _StyleProperty$_check.ref;
25
+ if (!success) {
26
+ return;
27
+ }
28
+ context.report({
29
+ node: ref.node.value,
30
+ messageId: messageId,
31
+ fix: ref.token ? StyleProperty._fix(ref, context) : undefined
32
+ });
33
+ },
34
+ _check: function _check(node) {
35
+ if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'Property')) {
36
+ return {
37
+ success: false,
38
+ ref: undefined
39
+ };
40
+ }
41
+
42
+ /**
43
+ * Currently, we support values like:
44
+ * ```
45
+ * {
46
+ * borderRadius: '8px', // value.type is Literal
47
+ * borderWidth: 2, // value.type is UnaryExpression
48
+ * }
49
+ * ```
50
+ */
51
+ if (!((0, _eslintCodemodUtils.isNodeOfType)(node.value, 'Literal') || (0, _eslintCodemodUtils.isNodeOfType)(node.value, 'UnaryExpression'))) {
52
+ return {
53
+ success: false,
54
+ ref: undefined
55
+ };
56
+ }
57
+ var _ast$ObjectEntry$getP = ast.ObjectEntry.getProperty(node),
58
+ property = _ast$ObjectEntry$getP.value;
59
+
60
+ // Bail if the property is not `borderRadius`, `borderWidth`, etc
61
+ if (!property || !_styleMap.styleMap[property]) {
62
+ return {
63
+ success: false,
64
+ ref: undefined
65
+ };
66
+ }
67
+ var value = ast.ObjectEntry.getValue(node);
68
+
69
+ // This is mainly useful as a type guard, so the checks after don't have to have duplicate checks for other types.
70
+ if (!(0, _utils.isStringOrNumber)(value)) {
71
+ return {
72
+ success: false,
73
+ ref: undefined
74
+ };
75
+ }
76
+
77
+ // ignore CSS vars. See: https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/pull-requests/74844/overview?commentId=6741571
78
+ if (value.toString().startsWith('var(')) {
79
+ return {
80
+ success: false,
81
+ ref: undefined
82
+ };
83
+ }
84
+
85
+ // There are valid values to ignore, such as `margin: auto`
86
+ if (_supported.default.values.ignore.includes(value)) {
87
+ return {
88
+ success: false,
89
+ ref: undefined
90
+ };
91
+ }
92
+
93
+ // Don't report on stuff like `borderRadius: '3px 8px'`.
94
+ // We may iterate to handle values like this in future.
95
+ if (value.toString().includes(' ')) {
96
+ return {
97
+ success: false,
98
+ ref: undefined
99
+ };
100
+ }
101
+ var ref = {
102
+ node: node,
103
+ token: _styleMap.styleMap[property][value],
104
+ fallback: value
105
+ };
106
+ return {
107
+ success: true,
108
+ ref: ref
109
+ };
110
+ },
111
+ /**
112
+ * All required validation steps have been taken care of before this
113
+ * transformer is called, so it just goes ahead providing all necessary fixes
114
+ */
115
+ _fix: function _fix(ref, context) {
116
+ return function (fixer) {
117
+ var importFix = ast.Root.upsertNamedImportDeclaration({
118
+ module: '@atlaskit/tokens',
119
+ specifiers: ['token']
120
+ }, context, fixer);
121
+ var tokenCall = "token('".concat(ref.token, "')");
122
+ var tokenFix = fixer.replaceText(ref.node.value, tokenCall);
123
+ return [importFix, tokenFix].filter(function (fix) {
124
+ return Boolean(fix);
125
+ }); // Some of the transformers can return arrays with undefined, so filter them out
126
+ };
127
+ }
128
+ };
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.styleMap = void 0;
7
+ var radiusTokenMap = {
8
+ '2px': 'radius.xsmall',
9
+ '3px': 'radius.small',
10
+ '4px': 'radius.small',
11
+ '6px': 'radius.medium',
12
+ '8px': 'radius.large',
13
+ '12px': 'radius.xlarge',
14
+ '50%': 'radius.full',
15
+ '100%': 'radius.full',
16
+ 2: 'radius.xsmall',
17
+ 3: 'radius.small',
18
+ 4: 'radius.small',
19
+ 6: 'radius.medium',
20
+ 8: 'radius.large',
21
+ 12: 'radius.xlarge',
22
+ '0.125rem': 'radius.xsmall',
23
+ '0.25rem': 'radius.small',
24
+ '0.375rem': 'radius.medium',
25
+ '0.5rem': 'radius.large',
26
+ '0.75rem': 'radius.xlarge'
27
+ };
28
+ var borderWidthTokenMap = {
29
+ '1px': 'border.width'
30
+ };
31
+ var styleMap = exports.styleMap = {
32
+ borderRadius: radiusTokenMap,
33
+ borderTopLeftRadius: radiusTokenMap,
34
+ borderTopRightRadius: radiusTokenMap,
35
+ borderBottomRightRadius: radiusTokenMap,
36
+ borderBottomLeftRadius: radiusTokenMap,
37
+ borderStartStartRadius: radiusTokenMap,
38
+ borderStartEndRadius: radiusTokenMap,
39
+ borderEndStartRadius: radiusTokenMap,
40
+ borderEndEndRadius: radiusTokenMap,
41
+ borderWidth: borderWidthTokenMap,
42
+ borderBottomWidth: borderWidthTokenMap,
43
+ borderLeftWidth: borderWidthTokenMap,
44
+ borderRightWidth: borderWidthTokenMap,
45
+ borderTopWidth: borderWidthTokenMap,
46
+ borderBlockWidth: borderWidthTokenMap,
47
+ borderInlineWidth: borderWidthTokenMap,
48
+ outlineWidth: borderWidthTokenMap
49
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var supported = {
8
+ values: {
9
+ ignore: ['initial', 'inherit', 'unset', 'revert', 'revert-layer', 'none',
10
+ // outline-offset can be set to none
11
+ // Currently the DST opinion is that 0 is valid.
12
+ 0, '0', '0px', '0em', '0rem']
13
+ }
14
+ };
15
+ var _default = exports.default = supported;
@@ -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::e075ab709ebd382d6f5e39fd78de9d6d>>
3
+ * @codegen <<SignedSource::c8428e53319286fb2b37a107968f2be8>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -70,6 +70,7 @@ export default {
70
70
  '@atlaskit/design-system/use-primitives-text': 'warn',
71
71
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
72
72
  '@atlaskit/design-system/use-tag-group-label': 'warn',
73
+ '@atlaskit/design-system/use-tokens-shape': 'error',
73
74
  '@atlaskit/design-system/use-tokens-space': 'error',
74
75
  '@atlaskit/design-system/use-tokens-typography': 'warn',
75
76
  '@atlaskit/design-system/use-visually-hidden': '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::d78f5649534c2e153e3ce48063649a8a>>
3
+ * @codegen <<SignedSource::a739ba6d63b1aa39d462906ee1876ce6>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -69,6 +69,7 @@ export default {
69
69
  '@atlaskit/design-system/use-primitives-text': 'warn',
70
70
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
71
71
  '@atlaskit/design-system/use-tag-group-label': 'warn',
72
+ '@atlaskit/design-system/use-tokens-shape': 'error',
72
73
  '@atlaskit/design-system/use-tokens-space': 'error',
73
74
  '@atlaskit/design-system/use-tokens-typography': 'warn',
74
75
  '@atlaskit/design-system/use-visually-hidden': 'error'
@@ -1,14 +1,12 @@
1
1
  import { isNodeOfType } from 'eslint-codemod-utils';
2
2
  import { shape as shapeTokens } from '@atlaskit/tokens/tokens-raw';
3
- const shapeProperties = ['borderTopLeftRadius', 'borderTopRightRadius', 'borderBottomRightRadius', 'borderBottomLeftRadius', 'borderRadius'];
3
+ const shapeProperties = ['borderTopLeftRadius', 'borderTopRightRadius', 'borderBottomRightRadius', 'borderBottomLeftRadius', 'borderRadius', 'borderStartStartRadius', 'borderStartEndRadius', 'borderEndStartRadius', 'borderEndEndRadius'];
4
4
  const borderSizeProperties = ['borderWidth', 'outlineWidth', 'borderRightWidth', 'borderLeftWidth', 'borderTopWidth', 'borderBottomWidth', 'borderInlineWidth', 'borderBlockWidth'];
5
- export const radiusValueToToken = Object.fromEntries(shapeTokens.filter(t => t.name.startsWith('border.radius'))
6
- // we prefer using the default (border.radius) over its aliases
7
- .filter(t => !t.name.startsWith('border.radius.100')).map(t => {
5
+ export const radiusValueToToken = Object.fromEntries(shapeTokens.filter(t => t.name.startsWith('radius')).map(t => {
8
6
  return [t.value, t.cleanName];
9
- }).concat([['3px', 'border.radius']]) // add in an extra entry to resolve 3px to border.radius (normally 4px)
10
- .concat([['50%', 'border.radius.circle']]) // add in an extra entry to resolve 50% to border.radius.circle (normally 2002rem)
11
- );
7
+ })
8
+ // add in extra entries to resolve 3px, 50%, and 100% to tokens
9
+ .concat([['3px', 'radius.small'], ['50%', 'radius.full'], ['100%', 'radius.full']]));
12
10
  export const borderWidthValueToToken = Object.fromEntries(shapeTokens.filter(t => t.name.startsWith('border.width')).map(t => [t.value, t.cleanName]).concat([['2px', 'border.width']]));
13
11
  export function isRadiusProperty(propertyName) {
14
12
  return shapeProperties.includes(propertyName);
@@ -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::53ad66d79f989ce9beb46ee0186685b2>>
3
+ * @codegen <<SignedSource::5fbd59fcd3fd6cb0602821de4a0a32aa>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  import consistentCssPropUsage from './consistent-css-prop-usage';
@@ -66,6 +66,7 @@ import usePrimitives from './use-primitives';
66
66
  import usePrimitivesText from './use-primitives-text';
67
67
  import useShouldRenderToParent from './use-should-render-to-parent';
68
68
  import useTagGroupLabel from './use-tag-group-label';
69
+ import useTokensShape from './use-tokens-shape';
69
70
  import useTokensSpace from './use-tokens-space';
70
71
  import useTokensTypography from './use-tokens-typography';
71
72
  import useVisuallyHidden from './use-visually-hidden';
@@ -133,6 +134,7 @@ export const rules = {
133
134
  'use-primitives-text': usePrimitivesText,
134
135
  'use-should-render-to-parent': useShouldRenderToParent,
135
136
  'use-tag-group-label': useTagGroupLabel,
137
+ 'use-tokens-shape': useTokensShape,
136
138
  'use-tokens-space': useTokensSpace,
137
139
  'use-tokens-typography': useTokensTypography,
138
140
  'use-visually-hidden': useVisuallyHidden
@@ -0,0 +1,38 @@
1
+ import { createLintRule } from '../utils/create-rule';
2
+ import { StyleProperty } from './transformers';
3
+ const rule = createLintRule({
4
+ meta: {
5
+ name: 'use-tokens-shape',
6
+ type: 'problem',
7
+ fixable: 'code',
8
+ hasSuggestions: true,
9
+ docs: {
10
+ description: 'Enforces usage of shape design tokens rather than hard-coded values.',
11
+ recommended: false,
12
+ severity: 'error'
13
+ },
14
+ messages: {
15
+ noRawShapeValues: 'The use of shape tokens is preferred over the direct application of border radius and border width properties.'
16
+ }
17
+ },
18
+ create(context) {
19
+ return {
20
+ 'CallExpression[callee.name="css"] ObjectExpression Property': node => StyleProperty.lint(node, {
21
+ context
22
+ }),
23
+ 'CallExpression[callee.name="keyframes"] ObjectExpression Property': node => StyleProperty.lint(node, {
24
+ context
25
+ }),
26
+ 'CallExpression[callee.name="cssMap"] ObjectExpression Property': node => StyleProperty.lint(node, {
27
+ context
28
+ }),
29
+ 'CallExpression[callee.object.name=styled] ObjectExpression Property': node => StyleProperty.lint(node, {
30
+ context
31
+ }),
32
+ 'CallExpression[callee.object.name=styled2] ObjectExpression Property': node => StyleProperty.lint(node, {
33
+ context
34
+ })
35
+ };
36
+ }
37
+ });
38
+ export default rule;
@@ -0,0 +1,120 @@
1
+ /* eslint-disable @repo/internal/react/require-jsdoc */
2
+
3
+ import { isNodeOfType } from 'eslint-codemod-utils';
4
+ import * as ast from '../../../ast-nodes';
5
+ import { isStringOrNumber } from '../../use-tokens-space/utils';
6
+ import { styleMap } from './style-map';
7
+ import supported from './supported';
8
+ const messageId = 'noRawShapeValues';
9
+ export const StyleProperty = {
10
+ lint(node, {
11
+ context
12
+ }) {
13
+ // Check whether all criteria needed to make a transformation are met
14
+ const {
15
+ success,
16
+ ref
17
+ } = StyleProperty._check(node);
18
+ if (!success) {
19
+ return;
20
+ }
21
+ context.report({
22
+ node: ref.node.value,
23
+ messageId,
24
+ fix: ref.token ? StyleProperty._fix(ref, context) : undefined
25
+ });
26
+ },
27
+ _check(node) {
28
+ if (!isNodeOfType(node, 'Property')) {
29
+ return {
30
+ success: false,
31
+ ref: undefined
32
+ };
33
+ }
34
+
35
+ /**
36
+ * Currently, we support values like:
37
+ * ```
38
+ * {
39
+ * borderRadius: '8px', // value.type is Literal
40
+ * borderWidth: 2, // value.type is UnaryExpression
41
+ * }
42
+ * ```
43
+ */
44
+ if (!(isNodeOfType(node.value, 'Literal') || isNodeOfType(node.value, 'UnaryExpression'))) {
45
+ return {
46
+ success: false,
47
+ ref: undefined
48
+ };
49
+ }
50
+ const {
51
+ value: property
52
+ } = ast.ObjectEntry.getProperty(node);
53
+
54
+ // Bail if the property is not `borderRadius`, `borderWidth`, etc
55
+ if (!property || !styleMap[property]) {
56
+ return {
57
+ success: false,
58
+ ref: undefined
59
+ };
60
+ }
61
+ const value = ast.ObjectEntry.getValue(node);
62
+
63
+ // This is mainly useful as a type guard, so the checks after don't have to have duplicate checks for other types.
64
+ if (!isStringOrNumber(value)) {
65
+ return {
66
+ success: false,
67
+ ref: undefined
68
+ };
69
+ }
70
+
71
+ // ignore CSS vars. See: https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/pull-requests/74844/overview?commentId=6741571
72
+ if (value.toString().startsWith('var(')) {
73
+ return {
74
+ success: false,
75
+ ref: undefined
76
+ };
77
+ }
78
+
79
+ // There are valid values to ignore, such as `margin: auto`
80
+ if (supported.values.ignore.includes(value)) {
81
+ return {
82
+ success: false,
83
+ ref: undefined
84
+ };
85
+ }
86
+
87
+ // Don't report on stuff like `borderRadius: '3px 8px'`.
88
+ // We may iterate to handle values like this in future.
89
+ if (value.toString().includes(' ')) {
90
+ return {
91
+ success: false,
92
+ ref: undefined
93
+ };
94
+ }
95
+ const ref = {
96
+ node,
97
+ token: styleMap[property][value],
98
+ fallback: value
99
+ };
100
+ return {
101
+ success: true,
102
+ ref
103
+ };
104
+ },
105
+ /**
106
+ * All required validation steps have been taken care of before this
107
+ * transformer is called, so it just goes ahead providing all necessary fixes
108
+ */
109
+ _fix(ref, context) {
110
+ return fixer => {
111
+ const importFix = ast.Root.upsertNamedImportDeclaration({
112
+ module: '@atlaskit/tokens',
113
+ specifiers: ['token']
114
+ }, context, fixer);
115
+ const tokenCall = `token('${ref.token}')`;
116
+ const tokenFix = fixer.replaceText(ref.node.value, tokenCall);
117
+ return [importFix, tokenFix].filter(fix => Boolean(fix)); // Some of the transformers can return arrays with undefined, so filter them out
118
+ };
119
+ }
120
+ };
@@ -0,0 +1,43 @@
1
+ const radiusTokenMap = {
2
+ '2px': 'radius.xsmall',
3
+ '3px': 'radius.small',
4
+ '4px': 'radius.small',
5
+ '6px': 'radius.medium',
6
+ '8px': 'radius.large',
7
+ '12px': 'radius.xlarge',
8
+ '50%': 'radius.full',
9
+ '100%': 'radius.full',
10
+ 2: 'radius.xsmall',
11
+ 3: 'radius.small',
12
+ 4: 'radius.small',
13
+ 6: 'radius.medium',
14
+ 8: 'radius.large',
15
+ 12: 'radius.xlarge',
16
+ '0.125rem': 'radius.xsmall',
17
+ '0.25rem': 'radius.small',
18
+ '0.375rem': 'radius.medium',
19
+ '0.5rem': 'radius.large',
20
+ '0.75rem': 'radius.xlarge'
21
+ };
22
+ const borderWidthTokenMap = {
23
+ '1px': 'border.width'
24
+ };
25
+ export const styleMap = {
26
+ borderRadius: radiusTokenMap,
27
+ borderTopLeftRadius: radiusTokenMap,
28
+ borderTopRightRadius: radiusTokenMap,
29
+ borderBottomRightRadius: radiusTokenMap,
30
+ borderBottomLeftRadius: radiusTokenMap,
31
+ borderStartStartRadius: radiusTokenMap,
32
+ borderStartEndRadius: radiusTokenMap,
33
+ borderEndStartRadius: radiusTokenMap,
34
+ borderEndEndRadius: radiusTokenMap,
35
+ borderWidth: borderWidthTokenMap,
36
+ borderBottomWidth: borderWidthTokenMap,
37
+ borderLeftWidth: borderWidthTokenMap,
38
+ borderRightWidth: borderWidthTokenMap,
39
+ borderTopWidth: borderWidthTokenMap,
40
+ borderBlockWidth: borderWidthTokenMap,
41
+ borderInlineWidth: borderWidthTokenMap,
42
+ outlineWidth: borderWidthTokenMap
43
+ };
@@ -0,0 +1,9 @@
1
+ const supported = {
2
+ values: {
3
+ ignore: ['initial', 'inherit', 'unset', 'revert', 'revert-layer', 'none',
4
+ // outline-offset can be set to none
5
+ // Currently the DST opinion is that 0 is valid.
6
+ 0, '0', '0px', '0em', '0rem']
7
+ }
8
+ };
9
+ export default supported;
@@ -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::e075ab709ebd382d6f5e39fd78de9d6d>>
3
+ * @codegen <<SignedSource::c8428e53319286fb2b37a107968f2be8>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -70,6 +70,7 @@ export default {
70
70
  '@atlaskit/design-system/use-primitives-text': 'warn',
71
71
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
72
72
  '@atlaskit/design-system/use-tag-group-label': 'warn',
73
+ '@atlaskit/design-system/use-tokens-shape': 'error',
73
74
  '@atlaskit/design-system/use-tokens-space': 'error',
74
75
  '@atlaskit/design-system/use-tokens-typography': 'warn',
75
76
  '@atlaskit/design-system/use-visually-hidden': '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::d78f5649534c2e153e3ce48063649a8a>>
3
+ * @codegen <<SignedSource::a739ba6d63b1aa39d462906ee1876ce6>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -69,6 +69,7 @@ export default {
69
69
  '@atlaskit/design-system/use-primitives-text': 'warn',
70
70
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
71
71
  '@atlaskit/design-system/use-tag-group-label': 'warn',
72
+ '@atlaskit/design-system/use-tokens-shape': 'error',
72
73
  '@atlaskit/design-system/use-tokens-space': 'error',
73
74
  '@atlaskit/design-system/use-tokens-typography': 'warn',
74
75
  '@atlaskit/design-system/use-visually-hidden': 'error'
@@ -1,18 +1,14 @@
1
1
  import { isNodeOfType } from 'eslint-codemod-utils';
2
2
  import { shape as shapeTokens } from '@atlaskit/tokens/tokens-raw';
3
- var shapeProperties = ['borderTopLeftRadius', 'borderTopRightRadius', 'borderBottomRightRadius', 'borderBottomLeftRadius', 'borderRadius'];
3
+ var shapeProperties = ['borderTopLeftRadius', 'borderTopRightRadius', 'borderBottomRightRadius', 'borderBottomLeftRadius', 'borderRadius', 'borderStartStartRadius', 'borderStartEndRadius', 'borderEndStartRadius', 'borderEndEndRadius'];
4
4
  var borderSizeProperties = ['borderWidth', 'outlineWidth', 'borderRightWidth', 'borderLeftWidth', 'borderTopWidth', 'borderBottomWidth', 'borderInlineWidth', 'borderBlockWidth'];
5
5
  export var radiusValueToToken = Object.fromEntries(shapeTokens.filter(function (t) {
6
- return t.name.startsWith('border.radius');
7
- })
8
- // we prefer using the default (border.radius) over its aliases
9
- .filter(function (t) {
10
- return !t.name.startsWith('border.radius.100');
6
+ return t.name.startsWith('radius');
11
7
  }).map(function (t) {
12
8
  return [t.value, t.cleanName];
13
- }).concat([['3px', 'border.radius']]) // add in an extra entry to resolve 3px to border.radius (normally 4px)
14
- .concat([['50%', 'border.radius.circle']]) // add in an extra entry to resolve 50% to border.radius.circle (normally 2002rem)
15
- );
9
+ })
10
+ // add in extra entries to resolve 3px, 50%, and 100% to tokens
11
+ .concat([['3px', 'radius.small'], ['50%', 'radius.full'], ['100%', 'radius.full']]));
16
12
  export var borderWidthValueToToken = Object.fromEntries(shapeTokens.filter(function (t) {
17
13
  return t.name.startsWith('border.width');
18
14
  }).map(function (t) {
@@ -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::53ad66d79f989ce9beb46ee0186685b2>>
3
+ * @codegen <<SignedSource::5fbd59fcd3fd6cb0602821de4a0a32aa>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  import consistentCssPropUsage from './consistent-css-prop-usage';
@@ -66,6 +66,7 @@ import usePrimitives from './use-primitives';
66
66
  import usePrimitivesText from './use-primitives-text';
67
67
  import useShouldRenderToParent from './use-should-render-to-parent';
68
68
  import useTagGroupLabel from './use-tag-group-label';
69
+ import useTokensShape from './use-tokens-shape';
69
70
  import useTokensSpace from './use-tokens-space';
70
71
  import useTokensTypography from './use-tokens-typography';
71
72
  import useVisuallyHidden from './use-visually-hidden';
@@ -133,6 +134,7 @@ export var rules = {
133
134
  'use-primitives-text': usePrimitivesText,
134
135
  'use-should-render-to-parent': useShouldRenderToParent,
135
136
  'use-tag-group-label': useTagGroupLabel,
137
+ 'use-tokens-shape': useTokensShape,
136
138
  'use-tokens-space': useTokensSpace,
137
139
  'use-tokens-typography': useTokensTypography,
138
140
  'use-visually-hidden': useVisuallyHidden
@@ -0,0 +1,48 @@
1
+ import { createLintRule } from '../utils/create-rule';
2
+ import { StyleProperty } from './transformers';
3
+ var rule = createLintRule({
4
+ meta: {
5
+ name: 'use-tokens-shape',
6
+ type: 'problem',
7
+ fixable: 'code',
8
+ hasSuggestions: true,
9
+ docs: {
10
+ description: 'Enforces usage of shape design tokens rather than hard-coded values.',
11
+ recommended: false,
12
+ severity: 'error'
13
+ },
14
+ messages: {
15
+ noRawShapeValues: 'The use of shape tokens is preferred over the direct application of border radius and border width properties.'
16
+ }
17
+ },
18
+ create: function create(context) {
19
+ return {
20
+ 'CallExpression[callee.name="css"] ObjectExpression Property': function CallExpressionCalleeNameCss_ObjectExpression_Property(node) {
21
+ return StyleProperty.lint(node, {
22
+ context: context
23
+ });
24
+ },
25
+ 'CallExpression[callee.name="keyframes"] ObjectExpression Property': function CallExpressionCalleeNameKeyframes_ObjectExpression_Property(node) {
26
+ return StyleProperty.lint(node, {
27
+ context: context
28
+ });
29
+ },
30
+ 'CallExpression[callee.name="cssMap"] ObjectExpression Property': function CallExpressionCalleeNameCssMap_ObjectExpression_Property(node) {
31
+ return StyleProperty.lint(node, {
32
+ context: context
33
+ });
34
+ },
35
+ 'CallExpression[callee.object.name=styled] ObjectExpression Property': function CallExpressionCalleeObjectNameStyled_ObjectExpression_Property(node) {
36
+ return StyleProperty.lint(node, {
37
+ context: context
38
+ });
39
+ },
40
+ 'CallExpression[callee.object.name=styled2] ObjectExpression Property': function CallExpressionCalleeObjectNameStyled2_ObjectExpression_Property(node) {
41
+ return StyleProperty.lint(node, {
42
+ context: context
43
+ });
44
+ }
45
+ };
46
+ }
47
+ });
48
+ export default rule;
@@ -0,0 +1,119 @@
1
+ /* eslint-disable @repo/internal/react/require-jsdoc */
2
+
3
+ import { isNodeOfType } from 'eslint-codemod-utils';
4
+ import * as ast from '../../../ast-nodes';
5
+ import { isStringOrNumber } from '../../use-tokens-space/utils';
6
+ import { styleMap } from './style-map';
7
+ import supported from './supported';
8
+ var messageId = 'noRawShapeValues';
9
+ export var StyleProperty = {
10
+ lint: function lint(node, _ref) {
11
+ var context = _ref.context;
12
+ // Check whether all criteria needed to make a transformation are met
13
+ var _StyleProperty$_check = StyleProperty._check(node),
14
+ success = _StyleProperty$_check.success,
15
+ ref = _StyleProperty$_check.ref;
16
+ if (!success) {
17
+ return;
18
+ }
19
+ context.report({
20
+ node: ref.node.value,
21
+ messageId: messageId,
22
+ fix: ref.token ? StyleProperty._fix(ref, context) : undefined
23
+ });
24
+ },
25
+ _check: function _check(node) {
26
+ if (!isNodeOfType(node, 'Property')) {
27
+ return {
28
+ success: false,
29
+ ref: undefined
30
+ };
31
+ }
32
+
33
+ /**
34
+ * Currently, we support values like:
35
+ * ```
36
+ * {
37
+ * borderRadius: '8px', // value.type is Literal
38
+ * borderWidth: 2, // value.type is UnaryExpression
39
+ * }
40
+ * ```
41
+ */
42
+ if (!(isNodeOfType(node.value, 'Literal') || isNodeOfType(node.value, 'UnaryExpression'))) {
43
+ return {
44
+ success: false,
45
+ ref: undefined
46
+ };
47
+ }
48
+ var _ast$ObjectEntry$getP = ast.ObjectEntry.getProperty(node),
49
+ property = _ast$ObjectEntry$getP.value;
50
+
51
+ // Bail if the property is not `borderRadius`, `borderWidth`, etc
52
+ if (!property || !styleMap[property]) {
53
+ return {
54
+ success: false,
55
+ ref: undefined
56
+ };
57
+ }
58
+ var value = ast.ObjectEntry.getValue(node);
59
+
60
+ // This is mainly useful as a type guard, so the checks after don't have to have duplicate checks for other types.
61
+ if (!isStringOrNumber(value)) {
62
+ return {
63
+ success: false,
64
+ ref: undefined
65
+ };
66
+ }
67
+
68
+ // ignore CSS vars. See: https://stash.atlassian.com/projects/ATLASSIAN/repos/atlassian-frontend-monorepo/pull-requests/74844/overview?commentId=6741571
69
+ if (value.toString().startsWith('var(')) {
70
+ return {
71
+ success: false,
72
+ ref: undefined
73
+ };
74
+ }
75
+
76
+ // There are valid values to ignore, such as `margin: auto`
77
+ if (supported.values.ignore.includes(value)) {
78
+ return {
79
+ success: false,
80
+ ref: undefined
81
+ };
82
+ }
83
+
84
+ // Don't report on stuff like `borderRadius: '3px 8px'`.
85
+ // We may iterate to handle values like this in future.
86
+ if (value.toString().includes(' ')) {
87
+ return {
88
+ success: false,
89
+ ref: undefined
90
+ };
91
+ }
92
+ var ref = {
93
+ node: node,
94
+ token: styleMap[property][value],
95
+ fallback: value
96
+ };
97
+ return {
98
+ success: true,
99
+ ref: ref
100
+ };
101
+ },
102
+ /**
103
+ * All required validation steps have been taken care of before this
104
+ * transformer is called, so it just goes ahead providing all necessary fixes
105
+ */
106
+ _fix: function _fix(ref, context) {
107
+ return function (fixer) {
108
+ var importFix = ast.Root.upsertNamedImportDeclaration({
109
+ module: '@atlaskit/tokens',
110
+ specifiers: ['token']
111
+ }, context, fixer);
112
+ var tokenCall = "token('".concat(ref.token, "')");
113
+ var tokenFix = fixer.replaceText(ref.node.value, tokenCall);
114
+ return [importFix, tokenFix].filter(function (fix) {
115
+ return Boolean(fix);
116
+ }); // Some of the transformers can return arrays with undefined, so filter them out
117
+ };
118
+ }
119
+ };
@@ -0,0 +1,43 @@
1
+ var radiusTokenMap = {
2
+ '2px': 'radius.xsmall',
3
+ '3px': 'radius.small',
4
+ '4px': 'radius.small',
5
+ '6px': 'radius.medium',
6
+ '8px': 'radius.large',
7
+ '12px': 'radius.xlarge',
8
+ '50%': 'radius.full',
9
+ '100%': 'radius.full',
10
+ 2: 'radius.xsmall',
11
+ 3: 'radius.small',
12
+ 4: 'radius.small',
13
+ 6: 'radius.medium',
14
+ 8: 'radius.large',
15
+ 12: 'radius.xlarge',
16
+ '0.125rem': 'radius.xsmall',
17
+ '0.25rem': 'radius.small',
18
+ '0.375rem': 'radius.medium',
19
+ '0.5rem': 'radius.large',
20
+ '0.75rem': 'radius.xlarge'
21
+ };
22
+ var borderWidthTokenMap = {
23
+ '1px': 'border.width'
24
+ };
25
+ export var styleMap = {
26
+ borderRadius: radiusTokenMap,
27
+ borderTopLeftRadius: radiusTokenMap,
28
+ borderTopRightRadius: radiusTokenMap,
29
+ borderBottomRightRadius: radiusTokenMap,
30
+ borderBottomLeftRadius: radiusTokenMap,
31
+ borderStartStartRadius: radiusTokenMap,
32
+ borderStartEndRadius: radiusTokenMap,
33
+ borderEndStartRadius: radiusTokenMap,
34
+ borderEndEndRadius: radiusTokenMap,
35
+ borderWidth: borderWidthTokenMap,
36
+ borderBottomWidth: borderWidthTokenMap,
37
+ borderLeftWidth: borderWidthTokenMap,
38
+ borderRightWidth: borderWidthTokenMap,
39
+ borderTopWidth: borderWidthTokenMap,
40
+ borderBlockWidth: borderWidthTokenMap,
41
+ borderInlineWidth: borderWidthTokenMap,
42
+ outlineWidth: borderWidthTokenMap
43
+ };
@@ -0,0 +1,9 @@
1
+ var supported = {
2
+ values: {
3
+ ignore: ['initial', 'inherit', 'unset', 'revert', 'revert-layer', 'none',
4
+ // outline-offset can be set to none
5
+ // Currently the DST opinion is that 0 is valid.
6
+ 0, '0', '0px', '0em', '0rem']
7
+ }
8
+ };
9
+ export default supported;
@@ -78,6 +78,7 @@ export declare const plugin: {
78
78
  'use-primitives-text': import("eslint").Rule.RuleModule;
79
79
  'use-should-render-to-parent': import("eslint").Rule.RuleModule;
80
80
  'use-tag-group-label': import("eslint").Rule.RuleModule;
81
+ 'use-tokens-shape': import("eslint").Rule.RuleModule;
81
82
  'use-tokens-space': import("eslint").Rule.RuleModule;
82
83
  'use-tokens-typography': import("eslint").Rule.RuleModule;
83
84
  'use-visually-hidden': import("eslint").Rule.RuleModule;
@@ -148,6 +149,7 @@ export declare const plugin: {
148
149
  '@atlaskit/design-system/use-primitives-text': "warn";
149
150
  '@atlaskit/design-system/use-should-render-to-parent': "warn";
150
151
  '@atlaskit/design-system/use-tag-group-label': "warn";
152
+ '@atlaskit/design-system/use-tokens-shape': "error";
151
153
  '@atlaskit/design-system/use-tokens-space': "error";
152
154
  '@atlaskit/design-system/use-tokens-typography': "warn";
153
155
  '@atlaskit/design-system/use-visually-hidden': "error";
@@ -220,6 +222,7 @@ export declare const plugin: {
220
222
  '@atlaskit/design-system/use-primitives-text': "warn";
221
223
  '@atlaskit/design-system/use-should-render-to-parent': "warn";
222
224
  '@atlaskit/design-system/use-tag-group-label': "warn";
225
+ '@atlaskit/design-system/use-tokens-shape': "error";
223
226
  '@atlaskit/design-system/use-tokens-space': "error";
224
227
  '@atlaskit/design-system/use-tokens-typography': "warn";
225
228
  '@atlaskit/design-system/use-visually-hidden': "error";
@@ -397,6 +400,7 @@ declare const configs: {
397
400
  '@atlaskit/design-system/use-primitives-text': "warn";
398
401
  '@atlaskit/design-system/use-should-render-to-parent': "warn";
399
402
  '@atlaskit/design-system/use-tag-group-label': "warn";
403
+ '@atlaskit/design-system/use-tokens-shape': "error";
400
404
  '@atlaskit/design-system/use-tokens-space': "error";
401
405
  '@atlaskit/design-system/use-tokens-typography': "warn";
402
406
  '@atlaskit/design-system/use-visually-hidden': "error";
@@ -469,6 +473,7 @@ declare const configs: {
469
473
  '@atlaskit/design-system/use-primitives-text': "warn";
470
474
  '@atlaskit/design-system/use-should-render-to-parent': "warn";
471
475
  '@atlaskit/design-system/use-tag-group-label': "warn";
476
+ '@atlaskit/design-system/use-tokens-shape': "error";
472
477
  '@atlaskit/design-system/use-tokens-space': "error";
473
478
  '@atlaskit/design-system/use-tokens-typography': "warn";
474
479
  '@atlaskit/design-system/use-visually-hidden': "error";
@@ -63,6 +63,7 @@ declare const _default: {
63
63
  '@atlaskit/design-system/use-primitives-text': "warn";
64
64
  '@atlaskit/design-system/use-should-render-to-parent': "warn";
65
65
  '@atlaskit/design-system/use-tag-group-label': "warn";
66
+ '@atlaskit/design-system/use-tokens-shape': "error";
66
67
  '@atlaskit/design-system/use-tokens-space': "error";
67
68
  '@atlaskit/design-system/use-tokens-typography': "warn";
68
69
  '@atlaskit/design-system/use-visually-hidden': "error";
@@ -63,6 +63,7 @@ declare const _default: {
63
63
  '@atlaskit/design-system/use-primitives-text': "warn";
64
64
  '@atlaskit/design-system/use-should-render-to-parent': "warn";
65
65
  '@atlaskit/design-system/use-tag-group-label': "warn";
66
+ '@atlaskit/design-system/use-tokens-shape': "error";
66
67
  '@atlaskit/design-system/use-tokens-space': "error";
67
68
  '@atlaskit/design-system/use-tokens-typography': "warn";
68
69
  '@atlaskit/design-system/use-visually-hidden': "error";
@@ -62,6 +62,7 @@ export declare const rules: {
62
62
  'use-primitives-text': import("eslint").Rule.RuleModule;
63
63
  'use-should-render-to-parent': import("eslint").Rule.RuleModule;
64
64
  'use-tag-group-label': import("eslint").Rule.RuleModule;
65
+ 'use-tokens-shape': import("eslint").Rule.RuleModule;
65
66
  'use-tokens-space': import("eslint").Rule.RuleModule;
66
67
  'use-tokens-typography': import("eslint").Rule.RuleModule;
67
68
  'use-visually-hidden': import("eslint").Rule.RuleModule;
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ declare const rule: Rule.RuleModule;
3
+ export default rule;
@@ -0,0 +1,26 @@
1
+ import type { Rule } from 'eslint';
2
+ import { type Property } from 'eslint-codemod-utils';
3
+ type Ref = {
4
+ node: Property;
5
+ token?: string;
6
+ fallback?: string | number;
7
+ };
8
+ type Check = {
9
+ success: false;
10
+ ref: undefined;
11
+ } | {
12
+ success: true;
13
+ ref: Ref;
14
+ };
15
+ export declare const StyleProperty: {
16
+ lint(node: Rule.Node, { context }: {
17
+ context: Rule.RuleContext;
18
+ }): void;
19
+ _check(node: Rule.Node): Check;
20
+ /**
21
+ * All required validation steps have been taken care of before this
22
+ * transformer is called, so it just goes ahead providing all necessary fixes
23
+ */
24
+ _fix(ref: Ref, context: Rule.RuleContext): (fixer: Rule.RuleFixer) => Rule.Fix[];
25
+ };
26
+ export {};
@@ -0,0 +1,10 @@
1
+ declare const radiusTokenMap: {
2
+ [key: string]: string;
3
+ };
4
+ declare const borderWidthTokenMap: {
5
+ [key: string]: string;
6
+ };
7
+ export declare const styleMap: {
8
+ [key: string]: typeof radiusTokenMap | typeof borderWidthTokenMap;
9
+ };
10
+ export {};
@@ -0,0 +1,6 @@
1
+ declare const supported: {
2
+ values: {
3
+ ignore: (string | number)[];
4
+ };
5
+ };
6
+ export default supported;
@@ -78,6 +78,7 @@ export declare const plugin: {
78
78
  'use-primitives-text': import("eslint").Rule.RuleModule;
79
79
  'use-should-render-to-parent': import("eslint").Rule.RuleModule;
80
80
  'use-tag-group-label': import("eslint").Rule.RuleModule;
81
+ 'use-tokens-shape': import("eslint").Rule.RuleModule;
81
82
  'use-tokens-space': import("eslint").Rule.RuleModule;
82
83
  'use-tokens-typography': import("eslint").Rule.RuleModule;
83
84
  'use-visually-hidden': import("eslint").Rule.RuleModule;
@@ -151,6 +152,7 @@ export declare const plugin: {
151
152
  '@atlaskit/design-system/use-primitives-text': "warn";
152
153
  '@atlaskit/design-system/use-should-render-to-parent': "warn";
153
154
  '@atlaskit/design-system/use-tag-group-label': "warn";
155
+ '@atlaskit/design-system/use-tokens-shape': "error";
154
156
  '@atlaskit/design-system/use-tokens-space': "error";
155
157
  '@atlaskit/design-system/use-tokens-typography': "warn";
156
158
  '@atlaskit/design-system/use-visually-hidden': "error";
@@ -226,6 +228,7 @@ export declare const plugin: {
226
228
  '@atlaskit/design-system/use-primitives-text': "warn";
227
229
  '@atlaskit/design-system/use-should-render-to-parent': "warn";
228
230
  '@atlaskit/design-system/use-tag-group-label': "warn";
231
+ '@atlaskit/design-system/use-tokens-shape': "error";
229
232
  '@atlaskit/design-system/use-tokens-space': "error";
230
233
  '@atlaskit/design-system/use-tokens-typography': "warn";
231
234
  '@atlaskit/design-system/use-visually-hidden': "error";
@@ -412,6 +415,7 @@ declare const configs: {
412
415
  '@atlaskit/design-system/use-primitives-text': "warn";
413
416
  '@atlaskit/design-system/use-should-render-to-parent': "warn";
414
417
  '@atlaskit/design-system/use-tag-group-label': "warn";
418
+ '@atlaskit/design-system/use-tokens-shape': "error";
415
419
  '@atlaskit/design-system/use-tokens-space': "error";
416
420
  '@atlaskit/design-system/use-tokens-typography': "warn";
417
421
  '@atlaskit/design-system/use-visually-hidden': "error";
@@ -487,6 +491,7 @@ declare const configs: {
487
491
  '@atlaskit/design-system/use-primitives-text': "warn";
488
492
  '@atlaskit/design-system/use-should-render-to-parent': "warn";
489
493
  '@atlaskit/design-system/use-tag-group-label': "warn";
494
+ '@atlaskit/design-system/use-tokens-shape': "error";
490
495
  '@atlaskit/design-system/use-tokens-space': "error";
491
496
  '@atlaskit/design-system/use-tokens-typography': "warn";
492
497
  '@atlaskit/design-system/use-visually-hidden': "error";
@@ -66,6 +66,7 @@ declare const _default: {
66
66
  '@atlaskit/design-system/use-primitives-text': "warn";
67
67
  '@atlaskit/design-system/use-should-render-to-parent': "warn";
68
68
  '@atlaskit/design-system/use-tag-group-label': "warn";
69
+ '@atlaskit/design-system/use-tokens-shape': "error";
69
70
  '@atlaskit/design-system/use-tokens-space': "error";
70
71
  '@atlaskit/design-system/use-tokens-typography': "warn";
71
72
  '@atlaskit/design-system/use-visually-hidden': "error";
@@ -66,6 +66,7 @@ declare const _default: {
66
66
  '@atlaskit/design-system/use-primitives-text': "warn";
67
67
  '@atlaskit/design-system/use-should-render-to-parent': "warn";
68
68
  '@atlaskit/design-system/use-tag-group-label': "warn";
69
+ '@atlaskit/design-system/use-tokens-shape': "error";
69
70
  '@atlaskit/design-system/use-tokens-space': "error";
70
71
  '@atlaskit/design-system/use-tokens-typography': "warn";
71
72
  '@atlaskit/design-system/use-visually-hidden': "error";
@@ -62,6 +62,7 @@ export declare const rules: {
62
62
  'use-primitives-text': import("eslint").Rule.RuleModule;
63
63
  'use-should-render-to-parent': import("eslint").Rule.RuleModule;
64
64
  'use-tag-group-label': import("eslint").Rule.RuleModule;
65
+ 'use-tokens-shape': import("eslint").Rule.RuleModule;
65
66
  'use-tokens-space': import("eslint").Rule.RuleModule;
66
67
  'use-tokens-typography': import("eslint").Rule.RuleModule;
67
68
  'use-visually-hidden': import("eslint").Rule.RuleModule;
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ declare const rule: Rule.RuleModule;
3
+ export default rule;
@@ -0,0 +1,26 @@
1
+ import type { Rule } from 'eslint';
2
+ import { type Property } from 'eslint-codemod-utils';
3
+ type Ref = {
4
+ node: Property;
5
+ token?: string;
6
+ fallback?: string | number;
7
+ };
8
+ type Check = {
9
+ success: false;
10
+ ref: undefined;
11
+ } | {
12
+ success: true;
13
+ ref: Ref;
14
+ };
15
+ export declare const StyleProperty: {
16
+ lint(node: Rule.Node, { context }: {
17
+ context: Rule.RuleContext;
18
+ }): void;
19
+ _check(node: Rule.Node): Check;
20
+ /**
21
+ * All required validation steps have been taken care of before this
22
+ * transformer is called, so it just goes ahead providing all necessary fixes
23
+ */
24
+ _fix(ref: Ref, context: Rule.RuleContext): (fixer: Rule.RuleFixer) => Rule.Fix[];
25
+ };
26
+ export {};
@@ -0,0 +1,10 @@
1
+ declare const radiusTokenMap: {
2
+ [key: string]: string;
3
+ };
4
+ declare const borderWidthTokenMap: {
5
+ [key: string]: string;
6
+ };
7
+ export declare const styleMap: {
8
+ [key: string]: typeof radiusTokenMap | typeof borderWidthTokenMap;
9
+ };
10
+ export {};
@@ -0,0 +1,6 @@
1
+ declare const supported: {
2
+ values: {
3
+ ignore: (string | number)[];
4
+ };
5
+ };
6
+ export default supported;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@atlaskit/eslint-plugin-design-system",
3
3
  "description": "The essential plugin for use with the Atlassian Design System.",
4
- "version": "13.20.1",
4
+ "version": "13.21.0",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
7
7
  "publishConfig": {
@@ -43,7 +43,7 @@
43
43
  },
44
44
  "dependencies": {
45
45
  "@atlaskit/eslint-utils": "^2.0.0",
46
- "@atlaskit/icon": "^28.1.0",
46
+ "@atlaskit/icon": "^28.2.0",
47
47
  "@atlaskit/icon-lab": "^5.7.0",
48
48
  "@atlaskit/tokens": "^6.3.0",
49
49
  "@babel/runtime": "^7.0.0",
@@ -59,7 +59,7 @@
59
59
  "devDependencies": {
60
60
  "@af/formatting": "workspace:^",
61
61
  "@atlaskit/ds-lib": "^5.0.0",
62
- "@atlaskit/theme": "^20.0.0",
62
+ "@atlaskit/theme": "^21.0.0",
63
63
  "@atlassian/codegen": "^0.1.0",
64
64
  "@atlassian/eslint-utils": "^0.5.0",
65
65
  "@atlassian/ts-loader": "^0.1.0",