@atlaskit/eslint-plugin-design-system 13.40.4 → 13.41.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 (41) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +1 -1
  3. package/dist/cjs/presets/all-flat.codegen.js +2 -2
  4. package/dist/cjs/presets/all.codegen.js +2 -2
  5. package/dist/cjs/presets/recommended-flat.codegen.js +2 -2
  6. package/dist/cjs/presets/recommended.codegen.js +2 -2
  7. package/dist/cjs/rules/index.codegen.js +3 -3
  8. package/dist/cjs/rules/no-icon-spacing-prop/helpers.js +250 -0
  9. package/dist/cjs/rules/no-icon-spacing-prop/index.js +139 -0
  10. package/dist/es2019/presets/all-flat.codegen.js +2 -2
  11. package/dist/es2019/presets/all.codegen.js +2 -2
  12. package/dist/es2019/presets/recommended-flat.codegen.js +2 -2
  13. package/dist/es2019/presets/recommended.codegen.js +2 -2
  14. package/dist/es2019/rules/index.codegen.js +3 -3
  15. package/dist/es2019/rules/no-icon-spacing-prop/helpers.js +199 -0
  16. package/dist/es2019/rules/no-icon-spacing-prop/index.js +133 -0
  17. package/dist/esm/presets/all-flat.codegen.js +2 -2
  18. package/dist/esm/presets/all.codegen.js +2 -2
  19. package/dist/esm/presets/recommended-flat.codegen.js +2 -2
  20. package/dist/esm/presets/recommended.codegen.js +2 -2
  21. package/dist/esm/rules/index.codegen.js +3 -3
  22. package/dist/esm/rules/no-icon-spacing-prop/helpers.js +232 -0
  23. package/dist/esm/rules/no-icon-spacing-prop/index.js +133 -0
  24. package/dist/types/presets/all-flat.codegen.d.ts +1 -1
  25. package/dist/types/presets/all.codegen.d.ts +1 -1
  26. package/dist/types/presets/recommended-flat.codegen.d.ts +1 -1
  27. package/dist/types/presets/recommended.codegen.d.ts +1 -1
  28. package/dist/types/rules/index.codegen.d.ts +1 -1
  29. package/dist/types/rules/no-icon-spacing-prop/helpers.d.ts +62 -0
  30. package/dist/types-ts4.5/presets/all-flat.codegen.d.ts +1 -1
  31. package/dist/types-ts4.5/presets/all.codegen.d.ts +1 -1
  32. package/dist/types-ts4.5/presets/recommended-flat.codegen.d.ts +1 -1
  33. package/dist/types-ts4.5/presets/recommended.codegen.d.ts +1 -1
  34. package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -1
  35. package/dist/types-ts4.5/rules/no-icon-spacing-prop/helpers.d.ts +62 -0
  36. package/package.json +4 -4
  37. package/dist/cjs/rules/use-side-nav-items-package/index.js +0 -189
  38. package/dist/es2019/rules/use-side-nav-items-package/index.js +0 -152
  39. package/dist/esm/rules/use-side-nav-items-package/index.js +0 -182
  40. /package/dist/types/rules/{use-side-nav-items-package → no-icon-spacing-prop}/index.d.ts +0 -0
  41. /package/dist/types-ts4.5/rules/{use-side-nav-items-package → no-icon-spacing-prop}/index.d.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/eslint-plugin-design-system
2
2
 
3
+ ## 13.41.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`af619ffaf19e1`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/af619ffaf19e1) -
8
+ Add `no-icon-spacing-prop` ESLint rule to flag and suggest migration of deprecated `spacing` prop
9
+ on icon components.
10
+ - Updated dependencies
11
+
12
+ ## 13.41.0
13
+
14
+ ### Minor Changes
15
+
16
+ - [`dcbccb3da71a6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/dcbccb3da71a6) -
17
+ The `use-side-nav-items-package` rule has been removed.
18
+
3
19
  ## 13.40.4
4
20
 
5
21
  ### Patch Changes
package/README.md CHANGED
@@ -82,6 +82,7 @@ module.exports = {
82
82
  | <a href="./packages/design-system/eslint-plugin/src/rules/no-html-select/README.md">no-html-select</a> | Discourage direct usage of HTML select elements in favor of the Atlassian Design System select component. | Yes | | Yes |
83
83
  | <a href="./packages/design-system/eslint-plugin/src/rules/no-html-text-input/README.md">no-html-text-input</a> | Discourage direct usage of HTML text input elements in favor of the Atlassian Design System textfield component. | Yes | | Yes |
84
84
  | <a href="./packages/design-system/eslint-plugin/src/rules/no-html-textarea/README.md">no-html-textarea</a> | Discourage direct usage of HTML textarea elements in favor of the Atlassian Design System textarea component. | Yes | | Yes |
85
+ | <a href="./packages/design-system/eslint-plugin/src/rules/no-icon-spacing-prop/README.md">no-icon-spacing-prop</a> | Disallows usage of the deprecated spacing prop on new icons. Use Box with cssMap for spacing instead. | Yes | | Yes |
85
86
  | <a href="./packages/design-system/eslint-plugin/src/rules/no-invalid-css-map/README.md">no-invalid-css-map</a> | Checks the validity of a CSS map created through cssMap. This is intended to be used alongside TypeScript's type-checking. | Yes | | |
86
87
  | <a href="./packages/design-system/eslint-plugin/src/rules/no-keyframes-tagged-template-expression/README.md">no-keyframes-tagged-template-expression</a> | Disallows any `keyframe` tagged template expressions that originate from Emotion, Styled Components or Compiled | | Yes | |
87
88
  | <a href="./packages/design-system/eslint-plugin/src/rules/no-legacy-icons/README.md">no-legacy-icons</a> | Enforces no legacy icons are used. | | Yes | Yes |
@@ -117,7 +118,6 @@ module.exports = {
117
118
  | <a href="./packages/design-system/eslint-plugin/src/rules/use-primitives/README.md">use-primitives</a> | Encourage the usage of primitives components. | | Yes | Yes |
118
119
  | <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 | Yes |
119
120
  | <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 |
120
- | <a href="./packages/design-system/eslint-plugin/src/rules/use-side-nav-items-package/README.md">use-side-nav-items-package</a> | Use @atlaskit/side-nav-items instead of @atlaskit/navigation-system/side-nav-items. | Yes | Yes | Yes |
121
121
  | <a href="./packages/design-system/eslint-plugin/src/rules/use-simple-field/README.md">use-simple-field</a> | Encourage use of simple field for better developer experience and accessibility. | Yes | | Yes |
122
122
  | <a href="./packages/design-system/eslint-plugin/src/rules/use-simple-form/README.md">use-simple-form</a> | Encourage use of simple form for better developer experience and accessibility. | Yes | | Yes |
123
123
  | <a href="./packages/design-system/eslint-plugin/src/rules/use-spotlight-package/README.md">use-spotlight-package</a> | Discourage the use of @atlaskit/onboarding in favor of @atlaskit/spotlight. | | 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::82ab0b678e51fc2eba27b6725ea60840>>
9
+ * @codegen <<SignedSource::6a7b233fc5b211ee3868899e1525bbdb>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
11
11
  */
12
12
 
@@ -44,6 +44,7 @@ var rules = {
44
44
  '@atlaskit/design-system/no-html-select': 'warn',
45
45
  '@atlaskit/design-system/no-html-text-input': 'warn',
46
46
  '@atlaskit/design-system/no-html-textarea': 'warn',
47
+ '@atlaskit/design-system/no-icon-spacing-prop': 'warn',
47
48
  '@atlaskit/design-system/no-invalid-css-map': ['error', {
48
49
  allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
49
50
  }],
@@ -81,7 +82,6 @@ var rules = {
81
82
  '@atlaskit/design-system/use-primitives': 'warn',
82
83
  '@atlaskit/design-system/use-primitives-text': 'warn',
83
84
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
84
- '@atlaskit/design-system/use-side-nav-items-package': 'warn',
85
85
  '@atlaskit/design-system/use-simple-field': 'warn',
86
86
  '@atlaskit/design-system/use-simple-form': 'warn',
87
87
  '@atlaskit/design-system/use-spotlight-package': '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::7ee6b956e557a4528e187fef69ff1014>>
9
+ * @codegen <<SignedSource::69b963bac3d18247c1cba21a3bca7bb4>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
11
11
  */
12
12
 
@@ -43,6 +43,7 @@ var rules = {
43
43
  '@atlaskit/design-system/no-html-select': 'warn',
44
44
  '@atlaskit/design-system/no-html-text-input': 'warn',
45
45
  '@atlaskit/design-system/no-html-textarea': 'warn',
46
+ '@atlaskit/design-system/no-icon-spacing-prop': 'warn',
46
47
  '@atlaskit/design-system/no-invalid-css-map': ['error', {
47
48
  allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
48
49
  }],
@@ -80,7 +81,6 @@ var rules = {
80
81
  '@atlaskit/design-system/use-primitives': 'warn',
81
82
  '@atlaskit/design-system/use-primitives-text': 'warn',
82
83
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
83
- '@atlaskit/design-system/use-side-nav-items-package': 'warn',
84
84
  '@atlaskit/design-system/use-simple-field': 'warn',
85
85
  '@atlaskit/design-system/use-simple-form': 'warn',
86
86
  '@atlaskit/design-system/use-spotlight-package': '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::7c689115fea10ca7f4a4d36b687d0d4b>>
9
+ * @codegen <<SignedSource::6f0d931df90a4eea8dc4201b3a8e0866>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
11
11
  */
12
12
 
@@ -35,6 +35,7 @@ var rules = {
35
35
  '@atlaskit/design-system/no-html-select': 'warn',
36
36
  '@atlaskit/design-system/no-html-text-input': 'warn',
37
37
  '@atlaskit/design-system/no-html-textarea': 'warn',
38
+ '@atlaskit/design-system/no-icon-spacing-prop': 'warn',
38
39
  '@atlaskit/design-system/no-invalid-css-map': ['error', {
39
40
  allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
40
41
  }],
@@ -63,7 +64,6 @@ var rules = {
63
64
  '@atlaskit/design-system/use-popup-label': 'warn',
64
65
  '@atlaskit/design-system/use-primitives-text': 'warn',
65
66
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
66
- '@atlaskit/design-system/use-side-nav-items-package': 'warn',
67
67
  '@atlaskit/design-system/use-simple-field': 'warn',
68
68
  '@atlaskit/design-system/use-simple-form': 'warn',
69
69
  '@atlaskit/design-system/use-tag-group-label': '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::70131b79da4231aaa59e2822b38790c1>>
9
+ * @codegen <<SignedSource::aa118aeb6a9c0d954f6e3a5ea7bd10af>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
11
11
  */
12
12
 
@@ -34,6 +34,7 @@ var rules = {
34
34
  '@atlaskit/design-system/no-html-select': 'warn',
35
35
  '@atlaskit/design-system/no-html-text-input': 'warn',
36
36
  '@atlaskit/design-system/no-html-textarea': 'warn',
37
+ '@atlaskit/design-system/no-icon-spacing-prop': 'warn',
37
38
  '@atlaskit/design-system/no-invalid-css-map': ['error', {
38
39
  allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
39
40
  }],
@@ -62,7 +63,6 @@ var rules = {
62
63
  '@atlaskit/design-system/use-popup-label': 'warn',
63
64
  '@atlaskit/design-system/use-primitives-text': 'warn',
64
65
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
65
- '@atlaskit/design-system/use-side-nav-items-package': 'warn',
66
66
  '@atlaskit/design-system/use-simple-field': 'warn',
67
67
  '@atlaskit/design-system/use-simple-form': 'warn',
68
68
  '@atlaskit/design-system/use-tag-group-label': 'warn',
@@ -38,6 +38,7 @@ var _noHtmlRange = _interopRequireDefault(require("./no-html-range"));
38
38
  var _noHtmlSelect = _interopRequireDefault(require("./no-html-select"));
39
39
  var _noHtmlTextInput = _interopRequireDefault(require("./no-html-text-input"));
40
40
  var _noHtmlTextarea = _interopRequireDefault(require("./no-html-textarea"));
41
+ var _noIconSpacingProp = _interopRequireDefault(require("./no-icon-spacing-prop"));
41
42
  var _noInvalidCssMap = _interopRequireDefault(require("./no-invalid-css-map"));
42
43
  var _noKeyframesTaggedTemplateExpression = _interopRequireDefault(require("./no-keyframes-tagged-template-expression"));
43
44
  var _noLegacyIcons = _interopRequireDefault(require("./no-legacy-icons"));
@@ -73,7 +74,6 @@ var _usePopupLabel = _interopRequireDefault(require("./use-popup-label"));
73
74
  var _usePrimitives = _interopRequireDefault(require("./use-primitives"));
74
75
  var _usePrimitivesText = _interopRequireDefault(require("./use-primitives-text"));
75
76
  var _useShouldRenderToParent = _interopRequireDefault(require("./use-should-render-to-parent"));
76
- var _useSideNavItemsPackage = _interopRequireDefault(require("./use-side-nav-items-package"));
77
77
  var _useSimpleField = _interopRequireDefault(require("./use-simple-field"));
78
78
  var _useSimpleForm = _interopRequireDefault(require("./use-simple-form"));
79
79
  var _useSpotlightPackage = _interopRequireDefault(require("./use-spotlight-package"));
@@ -84,7 +84,7 @@ var _useTokensTypography = _interopRequireDefault(require("./use-tokens-typograp
84
84
  var _useVisuallyHidden = _interopRequireDefault(require("./use-visually-hidden"));
85
85
  /**
86
86
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
87
- * @codegen <<SignedSource::9644eafd202e31d1b6f6c9b86ad519a2>>
87
+ * @codegen <<SignedSource::5d0d1213db83267889fa81e0aab419f7>>
88
88
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
89
89
  */
90
90
 
@@ -122,6 +122,7 @@ var rules = exports.rules = {
122
122
  'no-html-select': _noHtmlSelect.default,
123
123
  'no-html-text-input': _noHtmlTextInput.default,
124
124
  'no-html-textarea': _noHtmlTextarea.default,
125
+ 'no-icon-spacing-prop': _noIconSpacingProp.default,
125
126
  'no-invalid-css-map': _noInvalidCssMap.default,
126
127
  'no-keyframes-tagged-template-expression': _noKeyframesTaggedTemplateExpression.default,
127
128
  'no-legacy-icons': _noLegacyIcons.default,
@@ -157,7 +158,6 @@ var rules = exports.rules = {
157
158
  'use-primitives': _usePrimitives.default,
158
159
  'use-primitives-text': _usePrimitivesText.default,
159
160
  'use-should-render-to-parent': _useShouldRenderToParent.default,
160
- 'use-side-nav-items-package': _useSideNavItemsPackage.default,
161
161
  'use-simple-field': _useSimpleField.default,
162
162
  'use-simple-form': _useSimpleForm.default,
163
163
  'use-spotlight-package': _useSpotlightPackage.default,
@@ -0,0 +1,250 @@
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.TOKEN_IMPORT_MODULE = exports.SPACING_TO_PADDING = exports.CSS_IMPORT_MODULE = exports.CSSMAP_VARIABLE_NAME = exports.BOX_IMPORT_MODULE_NON_COMPILED = exports.BOX_IMPORT_MODULE = void 0;
9
+ exports.getCssMapKey = getCssMapKey;
10
+ exports.getIconSize = getIconSize;
11
+ exports.getSpacingAttribute = getSpacingAttribute;
12
+ exports.getStaticAttributeValue = getStaticAttributeValue;
13
+ exports.hasSpreadProps = hasSpreadProps;
14
+ exports.upsertBoxImport = upsertBoxImport;
15
+ exports.upsertCssMapImport = upsertCssMapImport;
16
+ exports.upsertCssMapVariable = upsertCssMapVariable;
17
+ exports.upsertTokenImport = upsertTokenImport;
18
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
19
+ var _eslintCodemodUtils = require("eslint-codemod-utils");
20
+ var _contextCompat = require("@atlaskit/eslint-utils/context-compat");
21
+ var ast = _interopRequireWildcard(require("../../ast-nodes"));
22
+ var _import = require("../../ast-nodes/import");
23
+ 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); }
24
+ var BOX_IMPORT_MODULE = exports.BOX_IMPORT_MODULE = '@atlaskit/primitives/compiled';
25
+ var BOX_IMPORT_MODULE_NON_COMPILED = exports.BOX_IMPORT_MODULE_NON_COMPILED = '@atlaskit/primitives';
26
+ var TOKEN_IMPORT_MODULE = exports.TOKEN_IMPORT_MODULE = '@atlaskit/tokens';
27
+ var CSS_IMPORT_MODULE = exports.CSS_IMPORT_MODULE = '@atlaskit/css';
28
+ var CSSMAP_VARIABLE_NAME = exports.CSSMAP_VARIABLE_NAME = 'iconSpacingStyles';
29
+
30
+ /**
31
+ * Padding token mapping based on icon size and spacing value.
32
+ * Same mapping as the codemod `icon-spacing-to-box-primitive`.
33
+ */
34
+ var SPACING_TO_PADDING = exports.SPACING_TO_PADDING = {
35
+ medium: {
36
+ compact: 'space.050',
37
+ spacious: 'space.050'
38
+ },
39
+ small: {
40
+ compact: 'space.025',
41
+ spacious: 'space.075'
42
+ }
43
+ };
44
+
45
+ /**
46
+ * Maps a padding token to a cssMap key name.
47
+ * e.g. 'space.050' → 'space050'
48
+ */
49
+ function getCssMapKey(paddingToken) {
50
+ return paddingToken.replace('space.', 'space');
51
+ }
52
+
53
+ /**
54
+ * Returns the `spacing` JSXAttribute from an icon element, or undefined.
55
+ */
56
+ function getSpacingAttribute(node) {
57
+ if (!(0, _eslintCodemodUtils.isNodeOfType)(node.openingElement, 'JSXOpeningElement')) {
58
+ return undefined;
59
+ }
60
+ return node.openingElement.attributes.find(function (a) {
61
+ return a.type === 'JSXAttribute' && a.name.name === 'spacing';
62
+ });
63
+ }
64
+
65
+ /**
66
+ * Returns the static string value of a JSXAttribute, or undefined if dynamic.
67
+ */
68
+ function getStaticAttributeValue(attr) {
69
+ if (attr.value && attr.value.type === 'Literal' && typeof attr.value.value === 'string') {
70
+ return attr.value.value;
71
+ }
72
+ return undefined;
73
+ }
74
+
75
+ /**
76
+ * Returns the static `size` prop value, defaulting to 'medium' if not present.
77
+ */
78
+ function getIconSize(node) {
79
+ if (!(0, _eslintCodemodUtils.isNodeOfType)(node.openingElement, 'JSXOpeningElement')) {
80
+ return 'medium';
81
+ }
82
+ var sizeAttr = node.openingElement.attributes.find(function (a) {
83
+ return a.type === 'JSXAttribute' && a.name.name === 'size';
84
+ });
85
+ if (!sizeAttr) {
86
+ return 'medium';
87
+ }
88
+ return getStaticAttributeValue(sizeAttr);
89
+ }
90
+
91
+ /**
92
+ * Returns true if the element has any JSXSpreadAttribute.
93
+ */
94
+ function hasSpreadProps(node) {
95
+ return node.openingElement.attributes.some(function (a) {
96
+ return a.type === 'JSXSpreadAttribute';
97
+ });
98
+ }
99
+
100
+ /**
101
+ * Upserts `Box` from `@atlaskit/primitives/compiled`, handling:
102
+ * 1. Already imported from `/compiled` → add Box if missing
103
+ * 2. Import from `@atlaskit/primitives` (non-compiled) → migrate path + add Box
104
+ * 3. No import → insert new `import { Box } from '@atlaskit/primitives/compiled'`
105
+ */
106
+ function upsertBoxImport(context, fixer) {
107
+ var root = (0, _contextCompat.getSourceCode)(context).ast.body;
108
+ var findExactImports = function findExactImports(module) {
109
+ return root.filter(function (node) {
110
+ return node.type === 'ImportDeclaration' && node.source.value === module;
111
+ });
112
+ };
113
+ var compiledImports = findExactImports(BOX_IMPORT_MODULE);
114
+ if (compiledImports.length > 0) {
115
+ var decl = compiledImports[0];
116
+ if (_import.Import.containsNamedSpecifier(decl, 'Box')) {
117
+ return undefined;
118
+ }
119
+ var specifiers = decl.specifiers.filter(function (s) {
120
+ return s.type === 'ImportSpecifier';
121
+ }).map(function (s) {
122
+ return s.local.name;
123
+ });
124
+ specifiers.push('Box');
125
+ return fixer.replaceText(decl, "import { ".concat(specifiers.join(', '), " } from '").concat(BOX_IMPORT_MODULE, "';"));
126
+ }
127
+ var nonCompiledImports = findExactImports(BOX_IMPORT_MODULE_NON_COMPILED);
128
+ if (nonCompiledImports.length > 0) {
129
+ var _decl = nonCompiledImports[0];
130
+ var _specifiers = _decl.specifiers.filter(function (s) {
131
+ return s.type === 'ImportSpecifier';
132
+ }).map(function (s) {
133
+ return s.local.name;
134
+ });
135
+ if (!_specifiers.includes('Box')) _specifiers.push('Box');
136
+ return fixer.replaceText(_decl, "import { ".concat(_specifiers.join(', '), " } from '").concat(BOX_IMPORT_MODULE, "';"));
137
+ }
138
+ return ast.Root.upsertNamedImportDeclaration({
139
+ module: BOX_IMPORT_MODULE,
140
+ specifiers: ['Box']
141
+ }, context, fixer);
142
+ }
143
+
144
+ /**
145
+ * Upserts `cssMap` from `@atlaskit/css`, handling:
146
+ * 1. Already imported → no-op
147
+ * 2. `@atlaskit/css` exists but missing `cssMap` → add specifier
148
+ * 3. No import → insert new `import { cssMap } from '@atlaskit/css'`
149
+ */
150
+ function upsertCssMapImport(context, fixer) {
151
+ var root = (0, _contextCompat.getSourceCode)(context).ast.body;
152
+ var cssImports = root.filter(function (node) {
153
+ return node.type === 'ImportDeclaration' && node.source.value === CSS_IMPORT_MODULE;
154
+ });
155
+ if (cssImports.length > 0) {
156
+ var decl = cssImports[0];
157
+ var hasCssMap = _import.Import.containsNamedSpecifier(decl, 'cssMap');
158
+ if (hasCssMap) {
159
+ return undefined;
160
+ }
161
+ var specifiers = decl.specifiers.filter(function (s) {
162
+ return s.type === 'ImportSpecifier';
163
+ }).map(function (s) {
164
+ return s.local.name;
165
+ });
166
+ if (!hasCssMap) specifiers.push('cssMap');
167
+ return fixer.replaceText(decl, "import { ".concat(specifiers.join(', '), " } from '").concat(CSS_IMPORT_MODULE, "';"));
168
+ }
169
+ return ast.Root.upsertNamedImportDeclaration({
170
+ module: CSS_IMPORT_MODULE,
171
+ specifiers: ['cssMap']
172
+ }, context, fixer);
173
+ }
174
+
175
+ /**
176
+ * Upserts `token` from `@atlaskit/tokens`, handling:
177
+ * 1. Already imported → no-op
178
+ * 2. `@atlaskit/tokens` exists but missing `token` → add specifier
179
+ * 3. No import → insert new `import { token } from '@atlaskit/tokens'`
180
+ */
181
+ function upsertTokenImport(context, fixer) {
182
+ var root = (0, _contextCompat.getSourceCode)(context).ast.body;
183
+ var tokenImports = root.filter(function (node) {
184
+ return node.type === 'ImportDeclaration' && node.source.value === TOKEN_IMPORT_MODULE;
185
+ });
186
+ if (tokenImports.length > 0) {
187
+ var decl = tokenImports[0];
188
+ if (_import.Import.containsNamedSpecifier(decl, 'token')) {
189
+ return undefined;
190
+ }
191
+ var specifiers = decl.specifiers.filter(function (s) {
192
+ return s.type === 'ImportSpecifier';
193
+ }).map(function (s) {
194
+ return s.local.name;
195
+ });
196
+ specifiers.push('token');
197
+ return fixer.replaceText(decl, "import { ".concat(specifiers.join(', '), " } from '").concat(TOKEN_IMPORT_MODULE, "';"));
198
+ }
199
+ return ast.Root.upsertNamedImportDeclaration({
200
+ module: TOKEN_IMPORT_MODULE,
201
+ specifiers: ['token']
202
+ }, context, fixer);
203
+ }
204
+
205
+ /**
206
+ * Inserts or updates `const iconSpacingStyles = cssMap({ spaceXXX: { padding: token('space.XXX') } })`
207
+ * after the last import statement.
208
+ *
209
+ * If `iconSpacingStyles` already exists, adds the new key to the existing cssMap object.
210
+ * If it doesn't exist, inserts a new declaration after the last import.
211
+ */
212
+ function upsertCssMapVariable(context, fixer, paddingToken) {
213
+ var sourceCode = (0, _contextCompat.getSourceCode)(context);
214
+ var body = sourceCode.ast.body;
215
+ var key = getCssMapKey(paddingToken);
216
+ var keyValuePair = " ".concat(key, ": { paddingTop: token('").concat(paddingToken, "'), paddingRight: token('").concat(paddingToken, "'), paddingBottom: token('").concat(paddingToken, "'), paddingLeft: token('").concat(paddingToken, "') }");
217
+
218
+ // Check if iconSpacingStyles cssMap variable already exists
219
+ var existingVar = body.find(function (node) {
220
+ var _node$declarations$, _node$declarations$0$;
221
+ return node.type === 'VariableDeclaration' && ((_node$declarations$ = node.declarations[0]) === null || _node$declarations$ === void 0 ? void 0 : _node$declarations$.type) === 'VariableDeclarator' && ((_node$declarations$0$ = node.declarations[0].id) === null || _node$declarations$0$ === void 0 ? void 0 : _node$declarations$0$.name) === CSSMAP_VARIABLE_NAME;
222
+ });
223
+ if (existingVar) {
224
+ // Check if the key already exists in the cssMap
225
+ var varText = sourceCode.getText(existingVar);
226
+ if (varText.includes(key + ':') || varText.includes("'".concat(key, "'"))) {
227
+ return undefined;
228
+ }
229
+ // Add the key to the existing cssMap — insert before the closing }
230
+ var closingBrace = sourceCode.getText(existingVar).lastIndexOf('}');
231
+ var existingVarStart = existingVar.range[0];
232
+ return fixer.insertTextAfterRange([existingVarStart, existingVarStart + closingBrace], ",\n".concat(keyValuePair, "\n"));
233
+ }
234
+
235
+ // Find last import to insert after it
236
+ var lastImport = (0, _toConsumableArray2.default)(body).reverse().find(function (n) {
237
+ return n.type === 'ImportDeclaration';
238
+ });
239
+ var declaration = "\nconst ".concat(CSSMAP_VARIABLE_NAME, " = cssMap({\n").concat(keyValuePair, ",\n});");
240
+ if (lastImport) {
241
+ return fixer.insertTextAfter(lastImport, declaration);
242
+ }
243
+
244
+ // No imports — insert at the start of the file
245
+ var firstNode = body[0];
246
+ if (firstNode) {
247
+ return fixer.insertTextBefore(firstNode, declaration);
248
+ }
249
+ return undefined;
250
+ }
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _isFromImportSource = require("../no-custom-icons/checks/is-from-import-source");
8
+ var _createRule = require("../utils/create-rule");
9
+ var _errorBoundary = require("../utils/error-boundary");
10
+ var _helpers = require("./helpers");
11
+ var rule = (0, _createRule.createLintRule)({
12
+ meta: {
13
+ name: 'no-icon-spacing-prop',
14
+ hasSuggestions: true,
15
+ type: 'suggestion',
16
+ docs: {
17
+ description: 'Disallows usage of the deprecated spacing prop on new icons. Use Box with cssMap for spacing instead.',
18
+ recommended: true,
19
+ severity: 'warn'
20
+ },
21
+ messages: {
22
+ noSpacingProp: "The `spacing` prop on icon component '{{iconName}}' is deprecated. Wrap the icon in a `<Box xcss={iconSpacingStyles.spaceXXX}>` using `cssMap` from `@atlaskit/css` instead.",
23
+ noSpacingPropManual: "The `spacing` prop on icon component '{{iconName}}' is deprecated but cannot be auto-fixed ({{reason}}). Manually wrap the icon in a `<Box xcss={...}>` using `cssMap` from `@atlaskit/css`.",
24
+ suggestRemoveSpacing: 'Remove the `spacing` prop.',
25
+ suggestWrapInBox: 'Wrap in `<Box xcss={{{cssMapVarName}}.{{cssMapKey}}}>` and remove the `spacing` prop.'
26
+ }
27
+ },
28
+ create: function create(context) {
29
+ var isNewIcon = (0, _isFromImportSource.createIsFromImportSourceFor)(/^@(atlaskit\/icon|atlaskit\/icon-lab|atlassian\/icon-private)\/core\//);
30
+ return (0, _errorBoundary.errorBoundary)({
31
+ JSXElement: function JSXElement(node) {
32
+ var _SPACING_TO_PADDING$s;
33
+ if (!isNewIcon(node)) {
34
+ return;
35
+ }
36
+ var spacingAttr = (0, _helpers.getSpacingAttribute)(node);
37
+ if (!spacingAttr) {
38
+ return;
39
+ }
40
+ var iconName = node.openingElement.name.type === 'JSXIdentifier' ? node.openingElement.name.name : 'Unknown';
41
+ var spacingValue = (0, _helpers.getStaticAttributeValue)(spacingAttr);
42
+ var hasSpread = (0, _helpers.hasSpreadProps)(node);
43
+ if (!spacingValue || hasSpread) {
44
+ var reason = hasSpread ? 'spread props present' : 'dynamic spacing value';
45
+ context.report({
46
+ node: node.openingElement,
47
+ messageId: 'noSpacingPropManual',
48
+ data: {
49
+ iconName: iconName,
50
+ reason: reason
51
+ }
52
+ });
53
+ return;
54
+ }
55
+ if (spacingValue === 'none') {
56
+ context.report({
57
+ node: node.openingElement,
58
+ messageId: 'noSpacingProp',
59
+ data: {
60
+ iconName: iconName
61
+ },
62
+ suggest: [{
63
+ messageId: 'suggestRemoveSpacing',
64
+ fix: function fix(fixer) {
65
+ return fixer.remove(spacingAttr);
66
+ }
67
+ }]
68
+ });
69
+ return;
70
+ }
71
+ var size = (0, _helpers.getIconSize)(node);
72
+ if (!size || !((_SPACING_TO_PADDING$s = _helpers.SPACING_TO_PADDING[size]) !== null && _SPACING_TO_PADDING$s !== void 0 && _SPACING_TO_PADDING$s[spacingValue])) {
73
+ context.report({
74
+ node: node.openingElement,
75
+ messageId: 'noSpacingPropManual',
76
+ data: {
77
+ iconName: iconName,
78
+ reason: "unknown size '".concat(size, "' or spacing '").concat(spacingValue, "'")
79
+ }
80
+ });
81
+ return;
82
+ }
83
+ var paddingToken = _helpers.SPACING_TO_PADDING[size][spacingValue];
84
+ var cssMapKey = (0, _helpers.getCssMapKey)(paddingToken);
85
+ context.report({
86
+ node: node.openingElement,
87
+ messageId: 'noSpacingProp',
88
+ data: {
89
+ iconName: iconName
90
+ },
91
+ suggest: [{
92
+ messageId: 'suggestWrapInBox',
93
+ data: {
94
+ cssMapVarName: _helpers.CSSMAP_VARIABLE_NAME,
95
+ cssMapKey: cssMapKey
96
+ },
97
+ fix: function fix(fixer) {
98
+ var fixes = [];
99
+
100
+ // 1. Remove spacing prop
101
+ fixes.push(fixer.remove(spacingAttr));
102
+
103
+ // 2. Wrap in Box with cssMap reference
104
+ fixes.push(fixer.insertTextBefore(node, "<Box xcss={".concat(_helpers.CSSMAP_VARIABLE_NAME, ".").concat(cssMapKey, "}>")));
105
+ fixes.push(fixer.insertTextAfter(node, "</Box>"));
106
+
107
+ // 3. Insert/update cssMap variable after last import
108
+ var cssMapFix = (0, _helpers.upsertCssMapVariable)(context, fixer, paddingToken);
109
+ if (cssMapFix) {
110
+ fixes.push(cssMapFix);
111
+ }
112
+
113
+ // 4. Add/update @atlaskit/css import (cssMap)
114
+ var cssFix = (0, _helpers.upsertCssMapImport)(context, fixer);
115
+ if (cssFix) {
116
+ fixes.push(cssFix);
117
+ }
118
+
119
+ // 5. Add Box to @atlaskit/primitives/compiled
120
+ var boxFix = (0, _helpers.upsertBoxImport)(context, fixer);
121
+ if (boxFix) {
122
+ fixes.push(boxFix);
123
+ }
124
+
125
+ // 6. Add token from @atlaskit/tokens
126
+ var tokenFix = (0, _helpers.upsertTokenImport)(context, fixer);
127
+ if (tokenFix) {
128
+ fixes.push(tokenFix);
129
+ }
130
+ return fixes;
131
+ }
132
+ }]
133
+ });
134
+ },
135
+ ImportDeclaration: isNewIcon.importDeclarationHook
136
+ });
137
+ }
138
+ });
139
+ var _default = exports.default = rule;
@@ -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::82ab0b678e51fc2eba27b6725ea60840>>
3
+ * @codegen <<SignedSource::6a7b233fc5b211ee3868899e1525bbdb>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -38,6 +38,7 @@ const rules = {
38
38
  '@atlaskit/design-system/no-html-select': 'warn',
39
39
  '@atlaskit/design-system/no-html-text-input': 'warn',
40
40
  '@atlaskit/design-system/no-html-textarea': 'warn',
41
+ '@atlaskit/design-system/no-icon-spacing-prop': 'warn',
41
42
  '@atlaskit/design-system/no-invalid-css-map': ['error', {
42
43
  allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
43
44
  }],
@@ -75,7 +76,6 @@ const rules = {
75
76
  '@atlaskit/design-system/use-primitives': 'warn',
76
77
  '@atlaskit/design-system/use-primitives-text': 'warn',
77
78
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
78
- '@atlaskit/design-system/use-side-nav-items-package': 'warn',
79
79
  '@atlaskit/design-system/use-simple-field': 'warn',
80
80
  '@atlaskit/design-system/use-simple-form': 'warn',
81
81
  '@atlaskit/design-system/use-spotlight-package': 'warn',
@@ -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::7ee6b956e557a4528e187fef69ff1014>>
3
+ * @codegen <<SignedSource::69b963bac3d18247c1cba21a3bca7bb4>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -37,6 +37,7 @@ const rules = {
37
37
  '@atlaskit/design-system/no-html-select': 'warn',
38
38
  '@atlaskit/design-system/no-html-text-input': 'warn',
39
39
  '@atlaskit/design-system/no-html-textarea': 'warn',
40
+ '@atlaskit/design-system/no-icon-spacing-prop': 'warn',
40
41
  '@atlaskit/design-system/no-invalid-css-map': ['error', {
41
42
  allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
42
43
  }],
@@ -74,7 +75,6 @@ const rules = {
74
75
  '@atlaskit/design-system/use-primitives': 'warn',
75
76
  '@atlaskit/design-system/use-primitives-text': 'warn',
76
77
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
77
- '@atlaskit/design-system/use-side-nav-items-package': 'warn',
78
78
  '@atlaskit/design-system/use-simple-field': 'warn',
79
79
  '@atlaskit/design-system/use-simple-form': 'warn',
80
80
  '@atlaskit/design-system/use-spotlight-package': 'warn',
@@ -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::7c689115fea10ca7f4a4d36b687d0d4b>>
3
+ * @codegen <<SignedSource::6f0d931df90a4eea8dc4201b3a8e0866>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -29,6 +29,7 @@ const rules = {
29
29
  '@atlaskit/design-system/no-html-select': 'warn',
30
30
  '@atlaskit/design-system/no-html-text-input': 'warn',
31
31
  '@atlaskit/design-system/no-html-textarea': 'warn',
32
+ '@atlaskit/design-system/no-icon-spacing-prop': 'warn',
32
33
  '@atlaskit/design-system/no-invalid-css-map': ['error', {
33
34
  allowedFunctionCalls: [['@atlaskit/tokens', 'token']]
34
35
  }],
@@ -57,7 +58,6 @@ const rules = {
57
58
  '@atlaskit/design-system/use-popup-label': 'warn',
58
59
  '@atlaskit/design-system/use-primitives-text': 'warn',
59
60
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
60
- '@atlaskit/design-system/use-side-nav-items-package': 'warn',
61
61
  '@atlaskit/design-system/use-simple-field': 'warn',
62
62
  '@atlaskit/design-system/use-simple-form': 'warn',
63
63
  '@atlaskit/design-system/use-tag-group-label': 'warn',