@atlaskit/eslint-plugin-design-system 13.40.3 → 13.41.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 (36) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +0 -1
  3. package/dist/cjs/presets/all-flat.codegen.js +1 -2
  4. package/dist/cjs/presets/all.codegen.js +1 -2
  5. package/dist/cjs/presets/recommended-flat.codegen.js +1 -2
  6. package/dist/cjs/presets/recommended.codegen.js +1 -2
  7. package/dist/cjs/rules/index.codegen.js +1 -3
  8. package/dist/cjs/rules/use-spotlight-package/linters/import-declaration/index.js +25 -0
  9. package/dist/es2019/presets/all-flat.codegen.js +1 -2
  10. package/dist/es2019/presets/all.codegen.js +1 -2
  11. package/dist/es2019/presets/recommended-flat.codegen.js +1 -2
  12. package/dist/es2019/presets/recommended.codegen.js +1 -2
  13. package/dist/es2019/rules/index.codegen.js +1 -3
  14. package/dist/es2019/rules/use-spotlight-package/linters/import-declaration/index.js +25 -0
  15. package/dist/esm/presets/all-flat.codegen.js +1 -2
  16. package/dist/esm/presets/all.codegen.js +1 -2
  17. package/dist/esm/presets/recommended-flat.codegen.js +1 -2
  18. package/dist/esm/presets/recommended.codegen.js +1 -2
  19. package/dist/esm/rules/index.codegen.js +1 -3
  20. package/dist/esm/rules/use-spotlight-package/linters/import-declaration/index.js +25 -0
  21. package/dist/types/presets/all-flat.codegen.d.ts +1 -1
  22. package/dist/types/presets/all.codegen.d.ts +1 -1
  23. package/dist/types/presets/recommended-flat.codegen.d.ts +1 -1
  24. package/dist/types/presets/recommended.codegen.d.ts +1 -1
  25. package/dist/types/rules/index.codegen.d.ts +1 -1
  26. package/dist/types-ts4.5/presets/all-flat.codegen.d.ts +1 -1
  27. package/dist/types-ts4.5/presets/all.codegen.d.ts +1 -1
  28. package/dist/types-ts4.5/presets/recommended-flat.codegen.d.ts +1 -1
  29. package/dist/types-ts4.5/presets/recommended.codegen.d.ts +1 -1
  30. package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -1
  31. package/package.json +2 -2
  32. package/dist/cjs/rules/use-side-nav-items-package/index.js +0 -189
  33. package/dist/es2019/rules/use-side-nav-items-package/index.js +0 -152
  34. package/dist/esm/rules/use-side-nav-items-package/index.js +0 -182
  35. package/dist/types/rules/use-side-nav-items-package/index.d.ts +0 -3
  36. package/dist/types-ts4.5/rules/use-side-nav-items-package/index.d.ts +0 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/eslint-plugin-design-system
2
2
 
3
+ ## 13.41.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`dcbccb3da71a6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/dcbccb3da71a6) -
8
+ The `use-side-nav-items-package` rule has been removed.
9
+
10
+ ## 13.40.4
11
+
12
+ ### Patch Changes
13
+
14
+ - [`1f45f35f80c0a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1f45f35f80c0a) -
15
+ use-spotlight-package now triggers for specific import specifiers, and ignores modal related
16
+ specifiers.
17
+ - Updated dependencies
18
+
3
19
  ## 13.40.3
4
20
 
5
21
  ### Patch Changes
package/README.md CHANGED
@@ -117,7 +117,6 @@ module.exports = {
117
117
  | <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
118
  | <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
119
  | <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
120
  | <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
121
  | <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
122
  | <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::69a41e92769cc7bf48554540d18e5b05>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
11
11
  */
12
12
 
@@ -81,7 +81,6 @@ var rules = {
81
81
  '@atlaskit/design-system/use-primitives': 'warn',
82
82
  '@atlaskit/design-system/use-primitives-text': 'warn',
83
83
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
84
- '@atlaskit/design-system/use-side-nav-items-package': 'warn',
85
84
  '@atlaskit/design-system/use-simple-field': 'warn',
86
85
  '@atlaskit/design-system/use-simple-form': 'warn',
87
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::7ee6b956e557a4528e187fef69ff1014>>
9
+ * @codegen <<SignedSource::e10c3c048d506010c5f20f87bfb1aa06>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
11
11
  */
12
12
 
@@ -80,7 +80,6 @@ var rules = {
80
80
  '@atlaskit/design-system/use-primitives': 'warn',
81
81
  '@atlaskit/design-system/use-primitives-text': 'warn',
82
82
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
83
- '@atlaskit/design-system/use-side-nav-items-package': 'warn',
84
83
  '@atlaskit/design-system/use-simple-field': 'warn',
85
84
  '@atlaskit/design-system/use-simple-form': 'warn',
86
85
  '@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::88389ee149a3dbf7ed1590b5606e93cc>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
11
11
  */
12
12
 
@@ -63,7 +63,6 @@ var rules = {
63
63
  '@atlaskit/design-system/use-popup-label': 'warn',
64
64
  '@atlaskit/design-system/use-primitives-text': 'warn',
65
65
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
66
- '@atlaskit/design-system/use-side-nav-items-package': 'warn',
67
66
  '@atlaskit/design-system/use-simple-field': 'warn',
68
67
  '@atlaskit/design-system/use-simple-form': 'warn',
69
68
  '@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::056ca400a393297712ea364958b2b874>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
11
11
  */
12
12
 
@@ -62,7 +62,6 @@ var rules = {
62
62
  '@atlaskit/design-system/use-popup-label': 'warn',
63
63
  '@atlaskit/design-system/use-primitives-text': 'warn',
64
64
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
65
- '@atlaskit/design-system/use-side-nav-items-package': 'warn',
66
65
  '@atlaskit/design-system/use-simple-field': 'warn',
67
66
  '@atlaskit/design-system/use-simple-form': 'warn',
68
67
  '@atlaskit/design-system/use-tag-group-label': 'warn',
@@ -73,7 +73,6 @@ var _usePopupLabel = _interopRequireDefault(require("./use-popup-label"));
73
73
  var _usePrimitives = _interopRequireDefault(require("./use-primitives"));
74
74
  var _usePrimitivesText = _interopRequireDefault(require("./use-primitives-text"));
75
75
  var _useShouldRenderToParent = _interopRequireDefault(require("./use-should-render-to-parent"));
76
- var _useSideNavItemsPackage = _interopRequireDefault(require("./use-side-nav-items-package"));
77
76
  var _useSimpleField = _interopRequireDefault(require("./use-simple-field"));
78
77
  var _useSimpleForm = _interopRequireDefault(require("./use-simple-form"));
79
78
  var _useSpotlightPackage = _interopRequireDefault(require("./use-spotlight-package"));
@@ -84,7 +83,7 @@ var _useTokensTypography = _interopRequireDefault(require("./use-tokens-typograp
84
83
  var _useVisuallyHidden = _interopRequireDefault(require("./use-visually-hidden"));
85
84
  /**
86
85
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
87
- * @codegen <<SignedSource::9644eafd202e31d1b6f6c9b86ad519a2>>
86
+ * @codegen <<SignedSource::f499d8b88b96bcc50bbd5d7a0299ff6c>>
88
87
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
89
88
  */
90
89
 
@@ -157,7 +156,6 @@ var rules = exports.rules = {
157
156
  'use-primitives': _usePrimitives.default,
158
157
  'use-primitives-text': _usePrimitivesText.default,
159
158
  'use-should-render-to-parent': _useShouldRenderToParent.default,
160
- 'use-side-nav-items-package': _useSideNavItemsPackage.default,
161
159
  'use-simple-field': _useSimpleField.default,
162
160
  'use-simple-form': _useSimpleForm.default,
163
161
  'use-spotlight-package': _useSpotlightPackage.default,
@@ -8,6 +8,13 @@ var _eslintCodemodUtils = require("eslint-codemod-utils");
8
8
  /* eslint-disable @repo/internal/react/require-jsdoc */
9
9
 
10
10
  var messageId = 'use-spotlight-package';
11
+ var BANNED_IMPORTS = [
12
+ // 'Modal',
13
+ 'Spotlight', 'SpotlightCard', 'SpotlightManager', 'SpotlightTarget', 'SpotlightTransition',
14
+ // 'modalButtonTheme',
15
+ 'spotlightButtonTheme', 'useSpotlight',
16
+ // 'ModalTransition',
17
+ 'SpotlightPulse'];
11
18
  var ImportDeclaration = exports.ImportDeclaration = {
12
19
  lint: function lint(node, _ref) {
13
20
  var context = _ref.context;
@@ -30,6 +37,24 @@ var ImportDeclaration = exports.ImportDeclaration = {
30
37
  ref: undefined
31
38
  };
32
39
  }
40
+ if (!node.specifiers) {
41
+ return {
42
+ success: false,
43
+ ref: undefined
44
+ };
45
+ }
46
+ var isViolation = node.specifiers.some(function (specifier) {
47
+ if (!(0, _eslintCodemodUtils.isNodeOfType)(specifier, 'ImportSpecifier')) {
48
+ return false;
49
+ }
50
+ return BANNED_IMPORTS.includes(specifier.imported.name);
51
+ });
52
+ if (!isViolation) {
53
+ return {
54
+ success: false,
55
+ ref: undefined
56
+ };
57
+ }
33
58
  return {
34
59
  success: true,
35
60
  ref: node
@@ -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::69a41e92769cc7bf48554540d18e5b05>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -75,7 +75,6 @@ const rules = {
75
75
  '@atlaskit/design-system/use-primitives': 'warn',
76
76
  '@atlaskit/design-system/use-primitives-text': 'warn',
77
77
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
78
- '@atlaskit/design-system/use-side-nav-items-package': 'warn',
79
78
  '@atlaskit/design-system/use-simple-field': 'warn',
80
79
  '@atlaskit/design-system/use-simple-form': 'warn',
81
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::7ee6b956e557a4528e187fef69ff1014>>
3
+ * @codegen <<SignedSource::e10c3c048d506010c5f20f87bfb1aa06>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -74,7 +74,6 @@ const rules = {
74
74
  '@atlaskit/design-system/use-primitives': 'warn',
75
75
  '@atlaskit/design-system/use-primitives-text': 'warn',
76
76
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
77
- '@atlaskit/design-system/use-side-nav-items-package': 'warn',
78
77
  '@atlaskit/design-system/use-simple-field': 'warn',
79
78
  '@atlaskit/design-system/use-simple-form': 'warn',
80
79
  '@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::88389ee149a3dbf7ed1590b5606e93cc>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -57,7 +57,6 @@ const rules = {
57
57
  '@atlaskit/design-system/use-popup-label': 'warn',
58
58
  '@atlaskit/design-system/use-primitives-text': 'warn',
59
59
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
60
- '@atlaskit/design-system/use-side-nav-items-package': 'warn',
61
60
  '@atlaskit/design-system/use-simple-field': 'warn',
62
61
  '@atlaskit/design-system/use-simple-form': 'warn',
63
62
  '@atlaskit/design-system/use-tag-group-label': '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::70131b79da4231aaa59e2822b38790c1>>
3
+ * @codegen <<SignedSource::056ca400a393297712ea364958b2b874>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -56,7 +56,6 @@ const rules = {
56
56
  '@atlaskit/design-system/use-popup-label': 'warn',
57
57
  '@atlaskit/design-system/use-primitives-text': 'warn',
58
58
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
59
- '@atlaskit/design-system/use-side-nav-items-package': 'warn',
60
59
  '@atlaskit/design-system/use-simple-field': 'warn',
61
60
  '@atlaskit/design-system/use-simple-form': 'warn',
62
61
  '@atlaskit/design-system/use-tag-group-label': '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::9644eafd202e31d1b6f6c9b86ad519a2>>
3
+ * @codegen <<SignedSource::f499d8b88b96bcc50bbd5d7a0299ff6c>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -72,7 +72,6 @@ import usePopupLabel from './use-popup-label';
72
72
  import usePrimitives from './use-primitives';
73
73
  import usePrimitivesText from './use-primitives-text';
74
74
  import useShouldRenderToParent from './use-should-render-to-parent';
75
- import useSideNavItemsPackage from './use-side-nav-items-package';
76
75
  import useSimpleField from './use-simple-field';
77
76
  import useSimpleForm from './use-simple-form';
78
77
  import useSpotlightPackage from './use-spotlight-package';
@@ -150,7 +149,6 @@ export const rules = {
150
149
  'use-primitives': usePrimitives,
151
150
  'use-primitives-text': usePrimitivesText,
152
151
  'use-should-render-to-parent': useShouldRenderToParent,
153
- 'use-side-nav-items-package': useSideNavItemsPackage,
154
152
  'use-simple-field': useSimpleField,
155
153
  'use-simple-form': useSimpleForm,
156
154
  'use-spotlight-package': useSpotlightPackage,
@@ -2,6 +2,13 @@
2
2
 
3
3
  import { isNodeOfType } from 'eslint-codemod-utils';
4
4
  const messageId = 'use-spotlight-package';
5
+ const BANNED_IMPORTS = [
6
+ // 'Modal',
7
+ 'Spotlight', 'SpotlightCard', 'SpotlightManager', 'SpotlightTarget', 'SpotlightTransition',
8
+ // 'modalButtonTheme',
9
+ 'spotlightButtonTheme', 'useSpotlight',
10
+ // 'ModalTransition',
11
+ 'SpotlightPulse'];
5
12
  export const ImportDeclaration = {
6
13
  lint(node, {
7
14
  context
@@ -26,6 +33,24 @@ export const ImportDeclaration = {
26
33
  ref: undefined
27
34
  };
28
35
  }
36
+ if (!node.specifiers) {
37
+ return {
38
+ success: false,
39
+ ref: undefined
40
+ };
41
+ }
42
+ const isViolation = node.specifiers.some(specifier => {
43
+ if (!isNodeOfType(specifier, 'ImportSpecifier')) {
44
+ return false;
45
+ }
46
+ return BANNED_IMPORTS.includes(specifier.imported.name);
47
+ });
48
+ if (!isViolation) {
49
+ return {
50
+ success: false,
51
+ ref: undefined
52
+ };
53
+ }
29
54
  return {
30
55
  success: true,
31
56
  ref: node
@@ -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::69a41e92769cc7bf48554540d18e5b05>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -75,7 +75,6 @@ var rules = {
75
75
  '@atlaskit/design-system/use-primitives': 'warn',
76
76
  '@atlaskit/design-system/use-primitives-text': 'warn',
77
77
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
78
- '@atlaskit/design-system/use-side-nav-items-package': 'warn',
79
78
  '@atlaskit/design-system/use-simple-field': 'warn',
80
79
  '@atlaskit/design-system/use-simple-form': 'warn',
81
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::7ee6b956e557a4528e187fef69ff1014>>
3
+ * @codegen <<SignedSource::e10c3c048d506010c5f20f87bfb1aa06>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -74,7 +74,6 @@ var rules = {
74
74
  '@atlaskit/design-system/use-primitives': 'warn',
75
75
  '@atlaskit/design-system/use-primitives-text': 'warn',
76
76
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
77
- '@atlaskit/design-system/use-side-nav-items-package': 'warn',
78
77
  '@atlaskit/design-system/use-simple-field': 'warn',
79
78
  '@atlaskit/design-system/use-simple-form': 'warn',
80
79
  '@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::88389ee149a3dbf7ed1590b5606e93cc>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -57,7 +57,6 @@ var rules = {
57
57
  '@atlaskit/design-system/use-popup-label': 'warn',
58
58
  '@atlaskit/design-system/use-primitives-text': 'warn',
59
59
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
60
- '@atlaskit/design-system/use-side-nav-items-package': 'warn',
61
60
  '@atlaskit/design-system/use-simple-field': 'warn',
62
61
  '@atlaskit/design-system/use-simple-form': 'warn',
63
62
  '@atlaskit/design-system/use-tag-group-label': '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::70131b79da4231aaa59e2822b38790c1>>
3
+ * @codegen <<SignedSource::056ca400a393297712ea364958b2b874>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -56,7 +56,6 @@ var rules = {
56
56
  '@atlaskit/design-system/use-popup-label': 'warn',
57
57
  '@atlaskit/design-system/use-primitives-text': 'warn',
58
58
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
59
- '@atlaskit/design-system/use-side-nav-items-package': 'warn',
60
59
  '@atlaskit/design-system/use-simple-field': 'warn',
61
60
  '@atlaskit/design-system/use-simple-form': 'warn',
62
61
  '@atlaskit/design-system/use-tag-group-label': '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::9644eafd202e31d1b6f6c9b86ad519a2>>
3
+ * @codegen <<SignedSource::f499d8b88b96bcc50bbd5d7a0299ff6c>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -72,7 +72,6 @@ import usePopupLabel from './use-popup-label';
72
72
  import usePrimitives from './use-primitives';
73
73
  import usePrimitivesText from './use-primitives-text';
74
74
  import useShouldRenderToParent from './use-should-render-to-parent';
75
- import useSideNavItemsPackage from './use-side-nav-items-package';
76
75
  import useSimpleField from './use-simple-field';
77
76
  import useSimpleForm from './use-simple-form';
78
77
  import useSpotlightPackage from './use-spotlight-package';
@@ -150,7 +149,6 @@ export var rules = {
150
149
  'use-primitives': usePrimitives,
151
150
  'use-primitives-text': usePrimitivesText,
152
151
  'use-should-render-to-parent': useShouldRenderToParent,
153
- 'use-side-nav-items-package': useSideNavItemsPackage,
154
152
  'use-simple-field': useSimpleField,
155
153
  'use-simple-form': useSimpleForm,
156
154
  'use-spotlight-package': useSpotlightPackage,
@@ -2,6 +2,13 @@
2
2
 
3
3
  import { isNodeOfType } from 'eslint-codemod-utils';
4
4
  var messageId = 'use-spotlight-package';
5
+ var BANNED_IMPORTS = [
6
+ // 'Modal',
7
+ 'Spotlight', 'SpotlightCard', 'SpotlightManager', 'SpotlightTarget', 'SpotlightTransition',
8
+ // 'modalButtonTheme',
9
+ 'spotlightButtonTheme', 'useSpotlight',
10
+ // 'ModalTransition',
11
+ 'SpotlightPulse'];
5
12
  export var ImportDeclaration = {
6
13
  lint: function lint(node, _ref) {
7
14
  var context = _ref.context;
@@ -24,6 +31,24 @@ export var ImportDeclaration = {
24
31
  ref: undefined
25
32
  };
26
33
  }
34
+ if (!node.specifiers) {
35
+ return {
36
+ success: false,
37
+ ref: undefined
38
+ };
39
+ }
40
+ var isViolation = node.specifiers.some(function (specifier) {
41
+ if (!isNodeOfType(specifier, 'ImportSpecifier')) {
42
+ return false;
43
+ }
44
+ return BANNED_IMPORTS.includes(specifier.imported.name);
45
+ });
46
+ if (!isViolation) {
47
+ return {
48
+ success: false,
49
+ ref: undefined
50
+ };
51
+ }
27
52
  return {
28
53
  success: true,
29
54
  ref: node
@@ -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::69a41e92769cc7bf48554540d18e5b05>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  import type { Linter } from 'eslint';
@@ -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::e10c3c048d506010c5f20f87bfb1aa06>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  import type { ESLint } from 'eslint';
@@ -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::88389ee149a3dbf7ed1590b5606e93cc>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  import type { Linter } from 'eslint';
@@ -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::70131b79da4231aaa59e2822b38790c1>>
3
+ * @codegen <<SignedSource::056ca400a393297712ea364958b2b874>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  import type { ESLint } from 'eslint';
@@ -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::9644eafd202e31d1b6f6c9b86ad519a2>>
3
+ * @codegen <<SignedSource::f499d8b88b96bcc50bbd5d7a0299ff6c>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  import type { Rule } from 'eslint';
@@ -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::69a41e92769cc7bf48554540d18e5b05>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  import type { Linter } from 'eslint';
@@ -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::e10c3c048d506010c5f20f87bfb1aa06>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  import type { ESLint } from 'eslint';
@@ -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::88389ee149a3dbf7ed1590b5606e93cc>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  import type { Linter } from 'eslint';
@@ -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::70131b79da4231aaa59e2822b38790c1>>
3
+ * @codegen <<SignedSource::056ca400a393297712ea364958b2b874>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  import type { ESLint } from 'eslint';
@@ -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::9644eafd202e31d1b6f6c9b86ad519a2>>
3
+ * @codegen <<SignedSource::f499d8b88b96bcc50bbd5d7a0299ff6c>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  import type { Rule } from 'eslint';
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.40.3",
4
+ "version": "13.41.0",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
7
7
  "publishConfig": {
@@ -56,7 +56,7 @@
56
56
  "devDependencies": {
57
57
  "@af/formatting": "workspace:^",
58
58
  "@atlaskit/ds-lib": "^5.3.0",
59
- "@atlaskit/theme": "^21.0.0",
59
+ "@atlaskit/theme": "^22.0.0",
60
60
  "@atlassian/codegen": "^0.1.0",
61
61
  "@atlassian/eslint-utils": "^0.5.0",
62
62
  "@atlassian/ts-loader": "^0.1.0",
@@ -1,189 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
- var _eslintCodemodUtils = require("eslint-codemod-utils");
11
- var _createRule = require("../utils/create-rule");
12
- function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
13
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
14
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
15
- var DEPRECATED_PREFIX = '@atlaskit/navigation-system/side-nav-items';
16
- var BARREL_ENTRYPOINT = '@atlaskit/navigation-system';
17
- var REPLACEMENT_PREFIX = '@atlaskit/side-nav-items';
18
-
19
- // Mapping between the side nav item exports from the barrel entrypoint, to the new subpath in @atlaskit/side-nav-items
20
- var EXPORT_TO_ENTRYPOINT_SUBPATH = {
21
- ExpandableMenuItem: 'expandable-menu-item',
22
- ExpandableMenuItemProps: 'expandable-menu-item',
23
- ExpandableMenuItemTrigger: 'expandable-menu-item',
24
- ExpandableMenuItemTriggerProps: 'expandable-menu-item',
25
- ExpandableMenuItemContent: 'expandable-menu-item',
26
- ExpandableMenuItemContentProps: 'expandable-menu-item',
27
- useIsExpanded: 'expandable-menu-item',
28
- FlyoutMenuItem: 'flyout-menu-item',
29
- FlyoutMenuItemProps: 'flyout-menu-item',
30
- FlyoutMenuItemContent: 'flyout-menu-item',
31
- FlyoutMenuItemContentProps: 'flyout-menu-item',
32
- FlyoutMenuItemTrigger: 'flyout-menu-item',
33
- FlyoutMenuItemTriggerProps: 'flyout-menu-item',
34
- ButtonMenuItem: 'button-menu-item',
35
- ButtonMenuItemProps: 'button-menu-item',
36
- COLLAPSE_ELEM_BEFORE: 'button-menu-item',
37
- LinkMenuItem: 'link-menu-item',
38
- LinkMenuItemProps: 'link-menu-item',
39
- MenuListItem: 'menu-list-item',
40
- ContainerAvatar: 'container-avatar',
41
- ContainerAvatarProps: 'container-avatar',
42
- MenuList: 'menu-list',
43
- TopLevelSpacer: 'top-level-spacer',
44
- MenuSection: 'menu-section',
45
- MenuSectionHeading: 'menu-section',
46
- Divider: 'menu-section'
47
- };
48
- var rule = (0, _createRule.createLintRule)({
49
- meta: {
50
- name: 'use-side-nav-items-package',
51
- type: 'problem',
52
- fixable: 'code',
53
- hasSuggestions: true,
54
- docs: {
55
- description: 'Use @atlaskit/side-nav-items instead of @atlaskit/navigation-system/side-nav-items.',
56
- recommended: true,
57
- severity: 'warn'
58
- },
59
- messages: (0, _defineProperty2.default)((0, _defineProperty2.default)({}, 'use-side-nav-items-package', 'Side nav items have moved to @atlaskit/side-nav-items. Use the same subpath (e.g. @atlaskit/side-nav-items/button-menu-item instead of @atlaskit/navigation-system/side-nav-items/button-menu-item).'), 'use-side-nav-items-package-barrel', 'The following imports have moved to @atlaskit/side-nav-items: {{ names }}. Import them from @atlaskit/side-nav-items.')
60
- },
61
- create: function create(context) {
62
- return {
63
- ImportDeclaration: function ImportDeclaration(node) {
64
- var _node$specifiers;
65
- if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'ImportDeclaration')) {
66
- return;
67
- }
68
- var source = node.source;
69
- var value = typeof source.value === 'string' ? source.value : undefined;
70
- if (value === undefined) {
71
- return;
72
- }
73
-
74
- // Import is from an entrypoint starting with @atlaskit/navigation-system/side-nav-items/*
75
- if (value.startsWith(DEPRECATED_PREFIX)) {
76
- var replacement = REPLACEMENT_PREFIX + value.slice(DEPRECATED_PREFIX.length);
77
- context.report({
78
- node: node,
79
- messageId: 'use-side-nav-items-package',
80
- suggest: [{
81
- messageId: 'use-side-nav-items-package',
82
- fix: function fix(fixer) {
83
- return fixer.replaceText(source, "'".concat(replacement, "'"));
84
- }
85
- }]
86
- });
87
- return;
88
- }
89
-
90
- // Import is from the barrel entrypoint: @atlaskit/navigation-system
91
- if (value === BARREL_ENTRYPOINT && (_node$specifiers = node.specifiers) !== null && _node$specifiers !== void 0 && _node$specifiers.length) {
92
- var movedNames = [];
93
- var movedBySubpath = new Map();
94
- var _iterator = _createForOfIteratorHelper(node.specifiers),
95
- _step;
96
- try {
97
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
98
- var spec = _step.value;
99
- if (spec.type === 'ImportSpecifier' && spec.imported.type === 'Identifier') {
100
- var importedName = spec.imported.name;
101
- var localName = spec.local.name;
102
- var subpath = EXPORT_TO_ENTRYPOINT_SUBPATH[importedName];
103
- if (subpath) {
104
- var _movedBySubpath$get;
105
- movedNames.push(importedName);
106
- var list = (_movedBySubpath$get = movedBySubpath.get(subpath)) !== null && _movedBySubpath$get !== void 0 ? _movedBySubpath$get : [];
107
- list.push({
108
- imported: importedName,
109
- local: localName
110
- });
111
- movedBySubpath.set(subpath, list);
112
- }
113
- }
114
- }
115
- } catch (err) {
116
- _iterator.e(err);
117
- } finally {
118
- _iterator.f();
119
- }
120
- if (movedNames.length > 0) {
121
- var sourceCode = context.sourceCode;
122
- context.report({
123
- node: node,
124
- messageId: 'use-side-nav-items-package-barrel',
125
- data: {
126
- names: movedNames.join(', ')
127
- },
128
- suggest: [{
129
- messageId: 'use-side-nav-items-package-barrel',
130
- fix: function fix(fixer) {
131
- var keepSpecifiers = node.specifiers.filter(function (spec) {
132
- if (spec.type !== 'ImportSpecifier' || spec.imported.type !== 'Identifier') {
133
- return true;
134
- }
135
- return !(spec.imported.name in EXPORT_TO_ENTRYPOINT_SUBPATH);
136
- });
137
- var lines = [];
138
- if (keepSpecifiers.length > 0) {
139
- var defaultPart = keepSpecifiers.find(function (s) {
140
- return s.type === 'ImportDefaultSpecifier';
141
- });
142
- var namespacePart = keepSpecifiers.find(function (s) {
143
- return s.type === 'ImportNamespaceSpecifier';
144
- });
145
- var namedKeep = keepSpecifiers.filter(function (s) {
146
- return s.type === 'ImportSpecifier';
147
- });
148
- var keepParts = [];
149
- if (defaultPart) {
150
- keepParts.push(sourceCode.getText(defaultPart));
151
- }
152
- if (namespacePart) {
153
- keepParts.push(sourceCode.getText(namespacePart));
154
- }
155
- if (namedKeep.length) {
156
- keepParts.push("{ ".concat(namedKeep.map(function (s) {
157
- return sourceCode.getText(s);
158
- }).join(', '), " }"));
159
- }
160
- lines.push("import ".concat(keepParts.join(', '), " from '").concat(BARREL_ENTRYPOINT, "';"));
161
- }
162
- var _iterator2 = _createForOfIteratorHelper(movedBySubpath),
163
- _step2;
164
- try {
165
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
166
- var _step2$value = (0, _slicedToArray2.default)(_step2.value, 2),
167
- subpath = _step2$value[0],
168
- specs = _step2$value[1];
169
- var specStr = specs.map(function (s) {
170
- return s.imported === s.local ? s.imported : "".concat(s.imported, " as ").concat(s.local);
171
- }).join(', ');
172
- lines.push("import { ".concat(specStr, " } from '").concat(REPLACEMENT_PREFIX, "/").concat(subpath, "';"));
173
- }
174
- } catch (err) {
175
- _iterator2.e(err);
176
- } finally {
177
- _iterator2.f();
178
- }
179
- return fixer.replaceText(node, lines.join('\n'));
180
- }
181
- }]
182
- });
183
- }
184
- }
185
- }
186
- };
187
- }
188
- });
189
- var _default = exports.default = rule;
@@ -1,152 +0,0 @@
1
- import { isNodeOfType } from 'eslint-codemod-utils';
2
- import { createLintRule } from '../utils/create-rule';
3
- const DEPRECATED_PREFIX = '@atlaskit/navigation-system/side-nav-items';
4
- const BARREL_ENTRYPOINT = '@atlaskit/navigation-system';
5
- const REPLACEMENT_PREFIX = '@atlaskit/side-nav-items';
6
-
7
- // Mapping between the side nav item exports from the barrel entrypoint, to the new subpath in @atlaskit/side-nav-items
8
- const EXPORT_TO_ENTRYPOINT_SUBPATH = {
9
- ExpandableMenuItem: 'expandable-menu-item',
10
- ExpandableMenuItemProps: 'expandable-menu-item',
11
- ExpandableMenuItemTrigger: 'expandable-menu-item',
12
- ExpandableMenuItemTriggerProps: 'expandable-menu-item',
13
- ExpandableMenuItemContent: 'expandable-menu-item',
14
- ExpandableMenuItemContentProps: 'expandable-menu-item',
15
- useIsExpanded: 'expandable-menu-item',
16
- FlyoutMenuItem: 'flyout-menu-item',
17
- FlyoutMenuItemProps: 'flyout-menu-item',
18
- FlyoutMenuItemContent: 'flyout-menu-item',
19
- FlyoutMenuItemContentProps: 'flyout-menu-item',
20
- FlyoutMenuItemTrigger: 'flyout-menu-item',
21
- FlyoutMenuItemTriggerProps: 'flyout-menu-item',
22
- ButtonMenuItem: 'button-menu-item',
23
- ButtonMenuItemProps: 'button-menu-item',
24
- COLLAPSE_ELEM_BEFORE: 'button-menu-item',
25
- LinkMenuItem: 'link-menu-item',
26
- LinkMenuItemProps: 'link-menu-item',
27
- MenuListItem: 'menu-list-item',
28
- ContainerAvatar: 'container-avatar',
29
- ContainerAvatarProps: 'container-avatar',
30
- MenuList: 'menu-list',
31
- TopLevelSpacer: 'top-level-spacer',
32
- MenuSection: 'menu-section',
33
- MenuSectionHeading: 'menu-section',
34
- Divider: 'menu-section'
35
- };
36
- const rule = createLintRule({
37
- meta: {
38
- name: 'use-side-nav-items-package',
39
- type: 'problem',
40
- fixable: 'code',
41
- hasSuggestions: true,
42
- docs: {
43
- description: 'Use @atlaskit/side-nav-items instead of @atlaskit/navigation-system/side-nav-items.',
44
- recommended: true,
45
- severity: 'warn'
46
- },
47
- messages: {
48
- ['use-side-nav-items-package']: 'Side nav items have moved to @atlaskit/side-nav-items. Use the same subpath (e.g. @atlaskit/side-nav-items/button-menu-item instead of @atlaskit/navigation-system/side-nav-items/button-menu-item).',
49
- ['use-side-nav-items-package-barrel']: 'The following imports have moved to @atlaskit/side-nav-items: {{ names }}. Import them from @atlaskit/side-nav-items.'
50
- }
51
- },
52
- create(context) {
53
- return {
54
- ImportDeclaration(node) {
55
- var _node$specifiers;
56
- if (!isNodeOfType(node, 'ImportDeclaration')) {
57
- return;
58
- }
59
- const source = node.source;
60
- const value = typeof source.value === 'string' ? source.value : undefined;
61
- if (value === undefined) {
62
- return;
63
- }
64
-
65
- // Import is from an entrypoint starting with @atlaskit/navigation-system/side-nav-items/*
66
- if (value.startsWith(DEPRECATED_PREFIX)) {
67
- const replacement = REPLACEMENT_PREFIX + value.slice(DEPRECATED_PREFIX.length);
68
- context.report({
69
- node,
70
- messageId: 'use-side-nav-items-package',
71
- suggest: [{
72
- messageId: 'use-side-nav-items-package',
73
- fix(fixer) {
74
- return fixer.replaceText(source, `'${replacement}'`);
75
- }
76
- }]
77
- });
78
- return;
79
- }
80
-
81
- // Import is from the barrel entrypoint: @atlaskit/navigation-system
82
- if (value === BARREL_ENTRYPOINT && (_node$specifiers = node.specifiers) !== null && _node$specifiers !== void 0 && _node$specifiers.length) {
83
- const movedNames = [];
84
- const movedBySubpath = new Map();
85
- for (const spec of node.specifiers) {
86
- if (spec.type === 'ImportSpecifier' && spec.imported.type === 'Identifier') {
87
- const importedName = spec.imported.name;
88
- const localName = spec.local.name;
89
- const subpath = EXPORT_TO_ENTRYPOINT_SUBPATH[importedName];
90
- if (subpath) {
91
- var _movedBySubpath$get;
92
- movedNames.push(importedName);
93
- const list = (_movedBySubpath$get = movedBySubpath.get(subpath)) !== null && _movedBySubpath$get !== void 0 ? _movedBySubpath$get : [];
94
- list.push({
95
- imported: importedName,
96
- local: localName
97
- });
98
- movedBySubpath.set(subpath, list);
99
- }
100
- }
101
- }
102
- if (movedNames.length > 0) {
103
- const {
104
- sourceCode
105
- } = context;
106
- context.report({
107
- node,
108
- messageId: 'use-side-nav-items-package-barrel',
109
- data: {
110
- names: movedNames.join(', ')
111
- },
112
- suggest: [{
113
- messageId: 'use-side-nav-items-package-barrel',
114
- fix(fixer) {
115
- const keepSpecifiers = node.specifiers.filter(spec => {
116
- if (spec.type !== 'ImportSpecifier' || spec.imported.type !== 'Identifier') {
117
- return true;
118
- }
119
- return !(spec.imported.name in EXPORT_TO_ENTRYPOINT_SUBPATH);
120
- });
121
- const lines = [];
122
- if (keepSpecifiers.length > 0) {
123
- const defaultPart = keepSpecifiers.find(s => s.type === 'ImportDefaultSpecifier');
124
- const namespacePart = keepSpecifiers.find(s => s.type === 'ImportNamespaceSpecifier');
125
- const namedKeep = keepSpecifiers.filter(s => s.type === 'ImportSpecifier');
126
- const keepParts = [];
127
- if (defaultPart) {
128
- keepParts.push(sourceCode.getText(defaultPart));
129
- }
130
- if (namespacePart) {
131
- keepParts.push(sourceCode.getText(namespacePart));
132
- }
133
- if (namedKeep.length) {
134
- keepParts.push(`{ ${namedKeep.map(s => sourceCode.getText(s)).join(', ')} }`);
135
- }
136
- lines.push(`import ${keepParts.join(', ')} from '${BARREL_ENTRYPOINT}';`);
137
- }
138
- for (const [subpath, specs] of movedBySubpath) {
139
- const specStr = specs.map(s => s.imported === s.local ? s.imported : `${s.imported} as ${s.local}`).join(', ');
140
- lines.push(`import { ${specStr} } from '${REPLACEMENT_PREFIX}/${subpath}';`);
141
- }
142
- return fixer.replaceText(node, lines.join('\n'));
143
- }
144
- }]
145
- });
146
- }
147
- }
148
- }
149
- };
150
- }
151
- });
152
- export default rule;
@@ -1,182 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
- function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
4
- function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
5
- function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
6
- import { isNodeOfType } from 'eslint-codemod-utils';
7
- import { createLintRule } from '../utils/create-rule';
8
- var DEPRECATED_PREFIX = '@atlaskit/navigation-system/side-nav-items';
9
- var BARREL_ENTRYPOINT = '@atlaskit/navigation-system';
10
- var REPLACEMENT_PREFIX = '@atlaskit/side-nav-items';
11
-
12
- // Mapping between the side nav item exports from the barrel entrypoint, to the new subpath in @atlaskit/side-nav-items
13
- var EXPORT_TO_ENTRYPOINT_SUBPATH = {
14
- ExpandableMenuItem: 'expandable-menu-item',
15
- ExpandableMenuItemProps: 'expandable-menu-item',
16
- ExpandableMenuItemTrigger: 'expandable-menu-item',
17
- ExpandableMenuItemTriggerProps: 'expandable-menu-item',
18
- ExpandableMenuItemContent: 'expandable-menu-item',
19
- ExpandableMenuItemContentProps: 'expandable-menu-item',
20
- useIsExpanded: 'expandable-menu-item',
21
- FlyoutMenuItem: 'flyout-menu-item',
22
- FlyoutMenuItemProps: 'flyout-menu-item',
23
- FlyoutMenuItemContent: 'flyout-menu-item',
24
- FlyoutMenuItemContentProps: 'flyout-menu-item',
25
- FlyoutMenuItemTrigger: 'flyout-menu-item',
26
- FlyoutMenuItemTriggerProps: 'flyout-menu-item',
27
- ButtonMenuItem: 'button-menu-item',
28
- ButtonMenuItemProps: 'button-menu-item',
29
- COLLAPSE_ELEM_BEFORE: 'button-menu-item',
30
- LinkMenuItem: 'link-menu-item',
31
- LinkMenuItemProps: 'link-menu-item',
32
- MenuListItem: 'menu-list-item',
33
- ContainerAvatar: 'container-avatar',
34
- ContainerAvatarProps: 'container-avatar',
35
- MenuList: 'menu-list',
36
- TopLevelSpacer: 'top-level-spacer',
37
- MenuSection: 'menu-section',
38
- MenuSectionHeading: 'menu-section',
39
- Divider: 'menu-section'
40
- };
41
- var rule = createLintRule({
42
- meta: {
43
- name: 'use-side-nav-items-package',
44
- type: 'problem',
45
- fixable: 'code',
46
- hasSuggestions: true,
47
- docs: {
48
- description: 'Use @atlaskit/side-nav-items instead of @atlaskit/navigation-system/side-nav-items.',
49
- recommended: true,
50
- severity: 'warn'
51
- },
52
- messages: _defineProperty(_defineProperty({}, 'use-side-nav-items-package', 'Side nav items have moved to @atlaskit/side-nav-items. Use the same subpath (e.g. @atlaskit/side-nav-items/button-menu-item instead of @atlaskit/navigation-system/side-nav-items/button-menu-item).'), 'use-side-nav-items-package-barrel', 'The following imports have moved to @atlaskit/side-nav-items: {{ names }}. Import them from @atlaskit/side-nav-items.')
53
- },
54
- create: function create(context) {
55
- return {
56
- ImportDeclaration: function ImportDeclaration(node) {
57
- var _node$specifiers;
58
- if (!isNodeOfType(node, 'ImportDeclaration')) {
59
- return;
60
- }
61
- var source = node.source;
62
- var value = typeof source.value === 'string' ? source.value : undefined;
63
- if (value === undefined) {
64
- return;
65
- }
66
-
67
- // Import is from an entrypoint starting with @atlaskit/navigation-system/side-nav-items/*
68
- if (value.startsWith(DEPRECATED_PREFIX)) {
69
- var replacement = REPLACEMENT_PREFIX + value.slice(DEPRECATED_PREFIX.length);
70
- context.report({
71
- node: node,
72
- messageId: 'use-side-nav-items-package',
73
- suggest: [{
74
- messageId: 'use-side-nav-items-package',
75
- fix: function fix(fixer) {
76
- return fixer.replaceText(source, "'".concat(replacement, "'"));
77
- }
78
- }]
79
- });
80
- return;
81
- }
82
-
83
- // Import is from the barrel entrypoint: @atlaskit/navigation-system
84
- if (value === BARREL_ENTRYPOINT && (_node$specifiers = node.specifiers) !== null && _node$specifiers !== void 0 && _node$specifiers.length) {
85
- var movedNames = [];
86
- var movedBySubpath = new Map();
87
- var _iterator = _createForOfIteratorHelper(node.specifiers),
88
- _step;
89
- try {
90
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
91
- var spec = _step.value;
92
- if (spec.type === 'ImportSpecifier' && spec.imported.type === 'Identifier') {
93
- var importedName = spec.imported.name;
94
- var localName = spec.local.name;
95
- var subpath = EXPORT_TO_ENTRYPOINT_SUBPATH[importedName];
96
- if (subpath) {
97
- var _movedBySubpath$get;
98
- movedNames.push(importedName);
99
- var list = (_movedBySubpath$get = movedBySubpath.get(subpath)) !== null && _movedBySubpath$get !== void 0 ? _movedBySubpath$get : [];
100
- list.push({
101
- imported: importedName,
102
- local: localName
103
- });
104
- movedBySubpath.set(subpath, list);
105
- }
106
- }
107
- }
108
- } catch (err) {
109
- _iterator.e(err);
110
- } finally {
111
- _iterator.f();
112
- }
113
- if (movedNames.length > 0) {
114
- var sourceCode = context.sourceCode;
115
- context.report({
116
- node: node,
117
- messageId: 'use-side-nav-items-package-barrel',
118
- data: {
119
- names: movedNames.join(', ')
120
- },
121
- suggest: [{
122
- messageId: 'use-side-nav-items-package-barrel',
123
- fix: function fix(fixer) {
124
- var keepSpecifiers = node.specifiers.filter(function (spec) {
125
- if (spec.type !== 'ImportSpecifier' || spec.imported.type !== 'Identifier') {
126
- return true;
127
- }
128
- return !(spec.imported.name in EXPORT_TO_ENTRYPOINT_SUBPATH);
129
- });
130
- var lines = [];
131
- if (keepSpecifiers.length > 0) {
132
- var defaultPart = keepSpecifiers.find(function (s) {
133
- return s.type === 'ImportDefaultSpecifier';
134
- });
135
- var namespacePart = keepSpecifiers.find(function (s) {
136
- return s.type === 'ImportNamespaceSpecifier';
137
- });
138
- var namedKeep = keepSpecifiers.filter(function (s) {
139
- return s.type === 'ImportSpecifier';
140
- });
141
- var keepParts = [];
142
- if (defaultPart) {
143
- keepParts.push(sourceCode.getText(defaultPart));
144
- }
145
- if (namespacePart) {
146
- keepParts.push(sourceCode.getText(namespacePart));
147
- }
148
- if (namedKeep.length) {
149
- keepParts.push("{ ".concat(namedKeep.map(function (s) {
150
- return sourceCode.getText(s);
151
- }).join(', '), " }"));
152
- }
153
- lines.push("import ".concat(keepParts.join(', '), " from '").concat(BARREL_ENTRYPOINT, "';"));
154
- }
155
- var _iterator2 = _createForOfIteratorHelper(movedBySubpath),
156
- _step2;
157
- try {
158
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
159
- var _step2$value = _slicedToArray(_step2.value, 2),
160
- subpath = _step2$value[0],
161
- specs = _step2$value[1];
162
- var specStr = specs.map(function (s) {
163
- return s.imported === s.local ? s.imported : "".concat(s.imported, " as ").concat(s.local);
164
- }).join(', ');
165
- lines.push("import { ".concat(specStr, " } from '").concat(REPLACEMENT_PREFIX, "/").concat(subpath, "';"));
166
- }
167
- } catch (err) {
168
- _iterator2.e(err);
169
- } finally {
170
- _iterator2.f();
171
- }
172
- return fixer.replaceText(node, lines.join('\n'));
173
- }
174
- }]
175
- });
176
- }
177
- }
178
- }
179
- };
180
- }
181
- });
182
- export default rule;
@@ -1,3 +0,0 @@
1
- import type { Rule } from 'eslint';
2
- declare const rule: Rule.RuleModule;
3
- export default rule;
@@ -1,3 +0,0 @@
1
- import type { Rule } from 'eslint';
2
- declare const rule: Rule.RuleModule;
3
- export default rule;