@atlaskit/eslint-plugin-design-system 13.20.1 → 13.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +1 -0
  3. package/dist/cjs/common/token-maps.partial.js +2 -2
  4. package/dist/cjs/index.codegen.js +1 -1
  5. package/dist/cjs/presets/all-flat.codegen.js +6 -3
  6. package/dist/cjs/presets/all.codegen.js +6 -3
  7. package/dist/cjs/presets/recommended-flat.codegen.js +5 -3
  8. package/dist/cjs/presets/recommended.codegen.js +5 -3
  9. package/dist/cjs/rules/ensure-design-token-usage/shape.js +5 -9
  10. package/dist/cjs/rules/index.codegen.js +3 -1
  11. package/dist/cjs/rules/use-tokens-shape/index.js +54 -0
  12. package/dist/cjs/rules/use-tokens-shape/transformers/index.js +128 -0
  13. package/dist/cjs/rules/use-tokens-shape/transformers/style-map.js +49 -0
  14. package/dist/cjs/rules/use-tokens-shape/transformers/supported.js +15 -0
  15. package/dist/cjs/rules/utils/is-node.js +2 -2
  16. package/dist/es2019/common/token-maps.partial.js +2 -2
  17. package/dist/es2019/index.codegen.js +1 -1
  18. package/dist/es2019/presets/all-flat.codegen.js +5 -3
  19. package/dist/es2019/presets/all.codegen.js +5 -3
  20. package/dist/es2019/presets/recommended-flat.codegen.js +4 -3
  21. package/dist/es2019/presets/recommended.codegen.js +4 -3
  22. package/dist/es2019/rules/ensure-design-token-usage/shape.js +5 -7
  23. package/dist/es2019/rules/index.codegen.js +4 -1
  24. package/dist/es2019/rules/use-tokens-shape/index.js +38 -0
  25. package/dist/es2019/rules/use-tokens-shape/transformers/index.js +120 -0
  26. package/dist/es2019/rules/use-tokens-shape/transformers/style-map.js +43 -0
  27. package/dist/es2019/rules/use-tokens-shape/transformers/supported.js +9 -0
  28. package/dist/es2019/rules/utils/is-node.js +2 -2
  29. package/dist/esm/common/token-maps.partial.js +2 -2
  30. package/dist/esm/index.codegen.js +1 -1
  31. package/dist/esm/presets/all-flat.codegen.js +5 -3
  32. package/dist/esm/presets/all.codegen.js +5 -3
  33. package/dist/esm/presets/recommended-flat.codegen.js +4 -3
  34. package/dist/esm/presets/recommended.codegen.js +4 -3
  35. package/dist/esm/rules/ensure-design-token-usage/shape.js +5 -9
  36. package/dist/esm/rules/index.codegen.js +4 -1
  37. package/dist/esm/rules/use-tokens-shape/index.js +48 -0
  38. package/dist/esm/rules/use-tokens-shape/transformers/index.js +119 -0
  39. package/dist/esm/rules/use-tokens-shape/transformers/style-map.js +43 -0
  40. package/dist/esm/rules/use-tokens-shape/transformers/supported.js +9 -0
  41. package/dist/esm/rules/utils/is-node.js +2 -2
  42. package/dist/types/common/token-maps.partial.d.ts +51 -51
  43. package/dist/types/index.codegen.d.ts +3 -571
  44. package/dist/types/presets/all-flat.codegen.d.ts +8 -71
  45. package/dist/types/presets/all.codegen.d.ts +8 -71
  46. package/dist/types/presets/recommended-flat.codegen.d.ts +8 -52
  47. package/dist/types/presets/recommended.codegen.d.ts +8 -52
  48. package/dist/types/rules/index.codegen.d.ts +7 -68
  49. package/dist/types/rules/use-tokens-shape/index.d.ts +3 -0
  50. package/dist/types/rules/use-tokens-shape/transformers/index.d.ts +26 -0
  51. package/dist/types/rules/use-tokens-shape/transformers/style-map.d.ts +10 -0
  52. package/dist/types/rules/use-tokens-shape/transformers/supported.d.ts +6 -0
  53. package/dist/types/rules/use-tokens-typography/utils.d.ts +24 -60
  54. package/dist/types-ts4.5/common/token-maps.partial.d.ts +51 -51
  55. package/dist/types-ts4.5/index.codegen.d.ts +3 -595
  56. package/dist/types-ts4.5/presets/all-flat.codegen.d.ts +8 -74
  57. package/dist/types-ts4.5/presets/all.codegen.d.ts +8 -74
  58. package/dist/types-ts4.5/presets/recommended-flat.codegen.d.ts +8 -55
  59. package/dist/types-ts4.5/presets/recommended.codegen.d.ts +8 -55
  60. package/dist/types-ts4.5/rules/index.codegen.d.ts +7 -68
  61. package/dist/types-ts4.5/rules/use-tokens-shape/index.d.ts +3 -0
  62. package/dist/types-ts4.5/rules/use-tokens-shape/transformers/index.d.ts +26 -0
  63. package/dist/types-ts4.5/rules/use-tokens-shape/transformers/style-map.d.ts +10 -0
  64. package/dist/types-ts4.5/rules/use-tokens-shape/transformers/supported.d.ts +6 -0
  65. package/dist/types-ts4.5/rules/use-tokens-typography/utils.d.ts +24 -60
  66. package/package.json +4 -8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/eslint-plugin-design-system
2
2
 
3
+ ## 13.21.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`f49681ffca5bc`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f49681ffca5bc) -
8
+ Fixed an issue with the `ensure-design-token-usage` rule, where it was identifying non-issues with
9
+ the `@atlaskit/tile` `backgroundColor` prop.
10
+
11
+ ## 13.21.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [`8a95abe487d79`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8a95abe487d79) - -
16
+ Added `use-tokens-shape` rule to enforce borderRadius and borderWidth values.
17
+ - Updated `ensure-design-token-usage` rule to apply correct shape tokens. Note this rule should
18
+ not be used for shape - instead use the `use-tokens-shape` rule instead.
19
+
3
20
  ## 13.20.1
4
21
 
5
22
  ### 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 | |
@@ -10,10 +10,10 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
10
10
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
11
  /**
12
12
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
13
- * @codegen <<SignedSource::a9fbd091c8b53fd9515afc7cdd793c6b>>
13
+ * @codegen <<SignedSource::f302f98104caa39f6137b6e8690eb7a8>>
14
14
  * @codegenId spacing
15
15
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen-token-maps
16
- * @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::55622b91aca9b3afac4bce440f222b71>>
16
+ * @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::07b9c29f8d9f95e43d59a7b7ad4ce7a2>>
17
17
  */
18
18
  var positiveSpaceMap = exports.positiveSpaceMap = {
19
19
  '0px': 'space.0',
@@ -20,7 +20,7 @@ var _index = require("./rules/index.codegen");
20
20
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
21
21
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /**
22
22
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
23
- * @codegen <<SignedSource::1ca7a384145f3bf3577ede9b88907a52>>
23
+ * @codegen <<SignedSource::891a7e1d667de46cfe89cad670005f2c>>
24
24
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
25
25
  */
26
26
  // this uses require because not all node versions this package supports use the same import assertions/attributes
@@ -6,10 +6,11 @@ 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::6210f09c70f4d44befb986dfd548ed3e>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
11
11
  */
12
- var _default = exports.default = {
12
+
13
+ var rules = {
13
14
  // NOTE: The reference to this plugin is inserted dynamically while creating the plugin in `index.codegen.tsx`
14
15
  plugins: {},
15
16
  rules: {
@@ -75,8 +76,10 @@ var _default = exports.default = {
75
76
  '@atlaskit/design-system/use-primitives-text': 'warn',
76
77
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
77
78
  '@atlaskit/design-system/use-tag-group-label': 'warn',
79
+ '@atlaskit/design-system/use-tokens-shape': 'error',
78
80
  '@atlaskit/design-system/use-tokens-space': 'error',
79
81
  '@atlaskit/design-system/use-tokens-typography': 'warn',
80
82
  '@atlaskit/design-system/use-visually-hidden': 'error'
81
83
  }
82
- };
84
+ };
85
+ var _default = exports.default = rules;
@@ -6,10 +6,11 @@ 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::daf4a5893d65c7a1592f8bc6e51920c6>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
11
11
  */
12
- var _default = exports.default = {
12
+
13
+ var rules = {
13
14
  plugins: ['@atlaskit/design-system'],
14
15
  rules: {
15
16
  '@atlaskit/design-system/consistent-css-prop-usage': 'error',
@@ -74,8 +75,10 @@ var _default = exports.default = {
74
75
  '@atlaskit/design-system/use-primitives-text': 'warn',
75
76
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
76
77
  '@atlaskit/design-system/use-tag-group-label': 'warn',
78
+ '@atlaskit/design-system/use-tokens-shape': 'error',
77
79
  '@atlaskit/design-system/use-tokens-space': 'error',
78
80
  '@atlaskit/design-system/use-tokens-typography': 'warn',
79
81
  '@atlaskit/design-system/use-visually-hidden': 'error'
80
82
  }
81
- };
83
+ };
84
+ var _default = exports.default = rules;
@@ -6,10 +6,11 @@ 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::310988af3dc2559509bf99f2110134b8>>
9
+ * @codegen <<SignedSource::3328b9c675a0d09876dcfbc5d29bc63f>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
11
11
  */
12
- var _default = exports.default = {
12
+
13
+ var rules = {
13
14
  // NOTE: The reference to this plugin is inserted dynamically while creating the plugin in `index.codegen.tsx`
14
15
  plugins: {},
15
16
  rules: {
@@ -60,4 +61,5 @@ var _default = exports.default = {
60
61
  '@atlaskit/design-system/use-tag-group-label': 'warn',
61
62
  '@atlaskit/design-system/use-visually-hidden': 'error'
62
63
  }
63
- };
64
+ };
65
+ var _default = exports.default = rules;
@@ -6,10 +6,11 @@ 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::ce9d9b39fba8bb67d218e48398271109>>
9
+ * @codegen <<SignedSource::b28f895280627b7a35f059f90783644a>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
11
11
  */
12
- var _default = exports.default = {
12
+
13
+ var rules = {
13
14
  plugins: ['@atlaskit/design-system'],
14
15
  rules: {
15
16
  '@atlaskit/design-system/consistent-css-prop-usage': 'error',
@@ -59,4 +60,5 @@ var _default = exports.default = {
59
60
  '@atlaskit/design-system/use-tag-group-label': 'warn',
60
61
  '@atlaskit/design-system/use-visually-hidden': 'error'
61
62
  }
62
- };
63
+ };
64
+ var _default = exports.default = rules;
@@ -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::4693db80b637ac078521dd6e0591f75b>>
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;
@@ -56,11 +56,11 @@ var _isDecendantOfSvgElement = exports.isDecendantOfSvgElement = function isDece
56
56
  return false;
57
57
  };
58
58
  var _isDecendantOfPrimitive = exports.isDecendantOfPrimitive = function isDecendantOfPrimitive(node, context) {
59
- var primitivesToCheck = ['Box', 'Text'];
59
+ var primitivesToCheck = ['Box', 'Text', 'Tile'];
60
60
  if ((0, _eslintCodemodUtils.isNodeOfType)(node, 'JSXElement')) {
61
61
  // @ts-ignore
62
62
  if (primitivesToCheck.includes(node.openingElement.name.name)) {
63
- var importDeclaration = _astNodes.Root.findImportsByModule((0, _contextCompat.getSourceCode)(context).ast.body, ['@atlaskit/primitives', '@atlaskit/primitives/box', '@atlaskit/primitives/text', '@atlaskit/primitives/compiled']);
63
+ var importDeclaration = _astNodes.Root.findImportsByModule((0, _contextCompat.getSourceCode)(context).ast.body, ['@atlaskit/primitives', '@atlaskit/primitives/box', '@atlaskit/primitives/text', '@atlaskit/primitives/compiled', '@atlaskit/tile']);
64
64
  if (importDeclaration.length) {
65
65
  return true;
66
66
  }
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::a9fbd091c8b53fd9515afc7cdd793c6b>>
3
+ * @codegen <<SignedSource::f302f98104caa39f6137b6e8690eb7a8>>
4
4
  * @codegenId spacing
5
5
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen-token-maps
6
- * @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::55622b91aca9b3afac4bce440f222b71>>
6
+ * @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::07b9c29f8d9f95e43d59a7b7ad4ce7a2>>
7
7
  */
8
8
  export const positiveSpaceMap = {
9
9
  '0px': 'space.0',
@@ -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::1ca7a384145f3bf3577ede9b88907a52>>
3
+ * @codegen <<SignedSource::891a7e1d667de46cfe89cad670005f2c>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -1,10 +1,10 @@
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::6210f09c70f4d44befb986dfd548ed3e>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
7
- export default {
7
+ const rules = {
8
8
  // NOTE: The reference to this plugin is inserted dynamically while creating the plugin in `index.codegen.tsx`
9
9
  plugins: {},
10
10
  rules: {
@@ -70,8 +70,10 @@ 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'
76
77
  }
77
- };
78
+ };
79
+ export default rules;
@@ -1,10 +1,10 @@
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::daf4a5893d65c7a1592f8bc6e51920c6>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
7
- export default {
7
+ const rules = {
8
8
  plugins: ['@atlaskit/design-system'],
9
9
  rules: {
10
10
  '@atlaskit/design-system/consistent-css-prop-usage': 'error',
@@ -69,8 +69,10 @@ 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'
75
76
  }
76
- };
77
+ };
78
+ export default rules;
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::310988af3dc2559509bf99f2110134b8>>
3
+ * @codegen <<SignedSource::3328b9c675a0d09876dcfbc5d29bc63f>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
7
- export default {
7
+ const rules = {
8
8
  // NOTE: The reference to this plugin is inserted dynamically while creating the plugin in `index.codegen.tsx`
9
9
  plugins: {},
10
10
  rules: {
@@ -55,4 +55,5 @@ export default {
55
55
  '@atlaskit/design-system/use-tag-group-label': 'warn',
56
56
  '@atlaskit/design-system/use-visually-hidden': 'error'
57
57
  }
58
- };
58
+ };
59
+ export default rules;
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::ce9d9b39fba8bb67d218e48398271109>>
3
+ * @codegen <<SignedSource::b28f895280627b7a35f059f90783644a>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
7
- export default {
7
+ const rules = {
8
8
  plugins: ['@atlaskit/design-system'],
9
9
  rules: {
10
10
  '@atlaskit/design-system/consistent-css-prop-usage': 'error',
@@ -54,4 +54,5 @@ export default {
54
54
  '@atlaskit/design-system/use-tag-group-label': 'warn',
55
55
  '@atlaskit/design-system/use-visually-hidden': 'error'
56
56
  }
57
- };
57
+ };
58
+ export default rules;
@@ -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,8 +1,9 @@
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::4693db80b637ac078521dd6e0591f75b>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
+
6
7
  import consistentCssPropUsage from './consistent-css-prop-usage';
7
8
  import enforceInlineStylesInSelect from './enforce-inline-styles-in-select';
8
9
  import ensureDesignTokenUsage from './ensure-design-token-usage';
@@ -66,6 +67,7 @@ import usePrimitives from './use-primitives';
66
67
  import usePrimitivesText from './use-primitives-text';
67
68
  import useShouldRenderToParent from './use-should-render-to-parent';
68
69
  import useTagGroupLabel from './use-tag-group-label';
70
+ import useTokensShape from './use-tokens-shape';
69
71
  import useTokensSpace from './use-tokens-space';
70
72
  import useTokensTypography from './use-tokens-typography';
71
73
  import useVisuallyHidden from './use-visually-hidden';
@@ -133,6 +135,7 @@ export const rules = {
133
135
  'use-primitives-text': usePrimitivesText,
134
136
  'use-should-render-to-parent': useShouldRenderToParent,
135
137
  'use-tag-group-label': useTagGroupLabel,
138
+ 'use-tokens-shape': useTokensShape,
136
139
  'use-tokens-space': useTokensSpace,
137
140
  'use-tokens-typography': useTokensTypography,
138
141
  'use-visually-hidden': useVisuallyHidden