@atlaskit/eslint-plugin-design-system 13.21.3 → 13.23.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 (39) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +1 -0
  3. package/dist/cjs/presets/all-flat.codegen.js +2 -1
  4. package/dist/cjs/presets/all.codegen.js +2 -1
  5. package/dist/cjs/rules/index.codegen.js +3 -1
  6. package/dist/cjs/rules/no-deprecated-imports/handlers/icon.js +13 -2
  7. package/dist/cjs/rules/no-deprecated-imports/index.js +5 -1
  8. package/dist/cjs/rules/use-spotlight-package/index.js +34 -0
  9. package/dist/cjs/rules/use-spotlight-package/linters/import-declaration/index.js +38 -0
  10. package/dist/cjs/rules/use-spotlight-package/linters/index.js +12 -0
  11. package/dist/es2019/presets/all-flat.codegen.js +2 -1
  12. package/dist/es2019/presets/all.codegen.js +2 -1
  13. package/dist/es2019/rules/index.codegen.js +3 -1
  14. package/dist/es2019/rules/no-deprecated-imports/handlers/icon.js +13 -2
  15. package/dist/es2019/rules/no-deprecated-imports/index.js +5 -1
  16. package/dist/es2019/rules/use-spotlight-package/index.js +26 -0
  17. package/dist/es2019/rules/use-spotlight-package/linters/import-declaration/index.js +34 -0
  18. package/dist/es2019/rules/use-spotlight-package/linters/index.js +1 -0
  19. package/dist/esm/presets/all-flat.codegen.js +2 -1
  20. package/dist/esm/presets/all.codegen.js +2 -1
  21. package/dist/esm/rules/index.codegen.js +3 -1
  22. package/dist/esm/rules/no-deprecated-imports/handlers/icon.js +13 -2
  23. package/dist/esm/rules/no-deprecated-imports/index.js +5 -1
  24. package/dist/esm/rules/use-spotlight-package/index.js +27 -0
  25. package/dist/esm/rules/use-spotlight-package/linters/import-declaration/index.js +32 -0
  26. package/dist/esm/rules/use-spotlight-package/linters/index.js +1 -0
  27. package/dist/types/presets/all-flat.codegen.d.ts +1 -1
  28. package/dist/types/presets/all.codegen.d.ts +1 -1
  29. package/dist/types/rules/index.codegen.d.ts +1 -1
  30. package/dist/types/rules/use-spotlight-package/index.d.ts +3 -0
  31. package/dist/types/rules/use-spotlight-package/linters/import-declaration/index.d.ts +16 -0
  32. package/dist/types/rules/use-spotlight-package/linters/index.d.ts +1 -0
  33. package/dist/types-ts4.5/presets/all-flat.codegen.d.ts +1 -1
  34. package/dist/types-ts4.5/presets/all.codegen.d.ts +1 -1
  35. package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -1
  36. package/dist/types-ts4.5/rules/use-spotlight-package/index.d.ts +3 -0
  37. package/dist/types-ts4.5/rules/use-spotlight-package/linters/import-declaration/index.d.ts +16 -0
  38. package/dist/types-ts4.5/rules/use-spotlight-package/linters/index.d.ts +1 -0
  39. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/eslint-plugin-design-system
2
2
 
3
+ ## 13.23.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`8bb8c54e2f01f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/8bb8c54e2f01f) -
8
+ Create use-spotlight-package rule.
9
+
10
+ ## 13.22.0
11
+
12
+ ### Minor Changes
13
+
14
+ - [`4df3a43323a47`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/4df3a43323a47) -
15
+ Added `turnOffAutoFixer` configuration option to the `no-deprecated-imports` rule, allowing users
16
+ to disable automatic code fixes while still reporting deprecated import violations.
17
+
3
18
  ## 13.21.3
4
19
 
5
20
  ### Patch Changes
package/README.md CHANGED
@@ -111,6 +111,7 @@ module.exports = {
111
111
  | <a href="./packages/design-system/eslint-plugin/src/rules/use-primitives/README.md">use-primitives</a> | Encourage the usage of primitives components. | | Yes | Yes |
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
+ | <a href="./packages/design-system/eslint-plugin/src/rules/use-spotlight-package/README.md">use-spotlight-package</a> | Discourage the use of deprecated imports from @atlaskit/onboarding in favor of @atlaskit/spotlight. | | Yes | Yes |
114
115
  | <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
116
  | <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 |
116
117
  | <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 |
@@ -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::6210f09c70f4d44befb986dfd548ed3e>>
9
+ * @codegen <<SignedSource::5aac2d8dc7c2832bcb8a96a143d60db5>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
11
11
  */
12
12
 
@@ -75,6 +75,7 @@ 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-spotlight-package': 'warn',
78
79
  '@atlaskit/design-system/use-tag-group-label': 'warn',
79
80
  '@atlaskit/design-system/use-tokens-shape': 'error',
80
81
  '@atlaskit/design-system/use-tokens-space': 'error',
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  /**
8
8
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
9
- * @codegen <<SignedSource::daf4a5893d65c7a1592f8bc6e51920c6>>
9
+ * @codegen <<SignedSource::43ea4411c4e338a916772d4bfda146cc>>
10
10
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
11
11
  */
12
12
 
@@ -74,6 +74,7 @@ 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-spotlight-package': 'warn',
77
78
  '@atlaskit/design-system/use-tag-group-label': 'warn',
78
79
  '@atlaskit/design-system/use-tokens-shape': 'error',
79
80
  '@atlaskit/design-system/use-tokens-space': 'error',
@@ -67,6 +67,7 @@ var _usePopupLabel = _interopRequireDefault(require("./use-popup-label"));
67
67
  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
+ var _useSpotlightPackage = _interopRequireDefault(require("./use-spotlight-package"));
70
71
  var _useTagGroupLabel = _interopRequireDefault(require("./use-tag-group-label"));
71
72
  var _useTokensShape = _interopRequireDefault(require("./use-tokens-shape"));
72
73
  var _useTokensSpace = _interopRequireDefault(require("./use-tokens-space"));
@@ -74,7 +75,7 @@ var _useTokensTypography = _interopRequireDefault(require("./use-tokens-typograp
74
75
  var _useVisuallyHidden = _interopRequireDefault(require("./use-visually-hidden"));
75
76
  /**
76
77
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
77
- * @codegen <<SignedSource::4693db80b637ac078521dd6e0591f75b>>
78
+ * @codegen <<SignedSource::732bff0fc39d7ff05b6688694101698d>>
78
79
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
79
80
  */
80
81
 
@@ -141,6 +142,7 @@ var rules = exports.rules = {
141
142
  'use-primitives': _usePrimitives.default,
142
143
  'use-primitives-text': _usePrimitivesText.default,
143
144
  'use-should-render-to-parent': _useShouldRenderToParent.default,
145
+ 'use-spotlight-package': _useSpotlightPackage.default,
144
146
  'use-tag-group-label': _useTagGroupLabel.default,
145
147
  'use-tokens-shape': _useTokensShape.default,
146
148
  'use-tokens-space': _useTokensSpace.default,
@@ -24,6 +24,12 @@ var getDeprecationIconHandler = exports.getDeprecationIconHandler = function get
24
24
  var identifiers = new Map();
25
25
  var importErrors = {};
26
26
  var exportErrors = {};
27
+ var getConfigFlag = function getConfigFlag(key, defaultValue) {
28
+ if (context.options && context.options.length > 0 && context.options[0] && context.options[0].hasOwnProperty(key)) {
29
+ return context.options[0][key] === !defaultValue ? !defaultValue : defaultValue;
30
+ }
31
+ return defaultValue;
32
+ };
27
33
  var getIconComponentName = function getIconComponentName(name) {
28
34
  return name.split(/\W/).map(function (part) {
29
35
  return "".concat(part[0].toUpperCase()).concat(part.slice(1));
@@ -63,6 +69,7 @@ var getDeprecationIconHandler = exports.getDeprecationIconHandler = function get
63
69
  }
64
70
  };
65
71
  var throwErrors = function throwErrors() {
72
+ var shouldTurnOffAutoFixer = getConfigFlag('turnOffAutoFixer', false);
66
73
  for (var _i = 0, _Object$entries = Object.entries(importErrors); _i < _Object$entries.length; _i++) {
67
74
  var _Object$entries$_i = (0, _slicedToArray2.default)(_Object$entries[_i], 2),
68
75
  importSource = _Object$entries$_i[0],
@@ -83,7 +90,9 @@ var getDeprecationIconHandler = exports.getDeprecationIconHandler = function get
83
90
  var replacement = metadata === null || metadata === void 0 || (_metadata$deprecatedI = metadata[deprecatedIconName]) === null || _metadata$deprecatedI === void 0 ? void 0 : _metadata$deprecatedI.replacement;
84
91
  if (replacement && ((_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.unfixable) === 'false') {
85
92
  var newIconName = getIconComponentName(replacement.name);
86
- addAutoFix(error, importSource, "".concat(replacement.location, "/").concat(replacement.type, "/migration/").concat(replacement.name, "--").concat(legacyIconName), newIconName);
93
+ if (!shouldTurnOffAutoFixer) {
94
+ addAutoFix(error, importSource, "".concat(replacement.location, "/").concat(replacement.type, "/migration/").concat(replacement.name, "--").concat(legacyIconName), newIconName);
95
+ }
87
96
  }
88
97
  } else {
89
98
  var _metadata2;
@@ -101,7 +110,9 @@ var getDeprecationIconHandler = exports.getDeprecationIconHandler = function get
101
110
  var _replacement = (_metadata2 = _metadata) === null || _metadata2 === void 0 || (_metadata2 = _metadata2[_name]) === null || _metadata2 === void 0 ? void 0 : _metadata2.replacement;
102
111
  if (_replacement) {
103
112
  var _newIconName = getIconComponentName(_replacement.name);
104
- addAutoFix(error, importSource, "".concat(_replacement.location, "/").concat(_replacement.type, "/").concat(_replacement.name), _newIconName);
113
+ if (!shouldTurnOffAutoFixer) {
114
+ addAutoFix(error, importSource, "".concat(_replacement.location, "/").concat(_replacement.type, "/").concat(_replacement.name), _newIconName);
115
+ }
105
116
  }
106
117
  }
107
118
  context.report(error);
@@ -53,6 +53,9 @@ var rule = (0, _createRule.createLintRule)({
53
53
  schema: [{
54
54
  type: 'object',
55
55
  properties: {
56
+ turnOffAutoFixer: {
57
+ type: 'boolean'
58
+ },
56
59
  deprecatedConfig: {
57
60
  type: 'object',
58
61
  properties: {
@@ -81,7 +84,8 @@ var rule = (0, _createRule.createLintRule)({
81
84
  }
82
85
  }
83
86
  }
84
- }
87
+ },
88
+ additionalProperties: false
85
89
  }]
86
90
  },
87
91
  create: function create(context) {
@@ -0,0 +1,34 @@
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 _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
+ var _createRule = require("../utils/create-rule");
10
+ var _linters = require("./linters");
11
+ var rule = (0, _createRule.createLintRule)({
12
+ meta: {
13
+ name: 'use-spotlight-package',
14
+ type: 'problem',
15
+ fixable: 'code',
16
+ hasSuggestions: true,
17
+ docs: {
18
+ description: 'Discourage the use of deprecated imports from @atlaskit/onboarding in favor of @atlaskit/spotlight.',
19
+ recommended: false,
20
+ severity: 'warn'
21
+ },
22
+ messages: (0, _defineProperty2.default)({}, 'use-spotlight-package', '@atlaskit/onboarding is being deprecated in favor of @atlaskit/spotlight. Please migrate your spotlight experiences accordingly.')
23
+ },
24
+ create: function create(context) {
25
+ return {
26
+ 'ImportDeclaration[source.value="@atlaskit/onboarding"]': function ImportDeclarationSourceValueAtlaskit_onboarding(node) {
27
+ return _linters.ImportDeclaration.lint(node, {
28
+ context: context
29
+ });
30
+ }
31
+ };
32
+ }
33
+ });
34
+ var _default = exports.default = rule;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ImportDeclaration = void 0;
7
+ var _eslintCodemodUtils = require("eslint-codemod-utils");
8
+ /* eslint-disable @repo/internal/react/require-jsdoc */
9
+
10
+ var messageId = 'use-spotlight-package';
11
+ var ImportDeclaration = exports.ImportDeclaration = {
12
+ lint: function lint(node, _ref) {
13
+ var context = _ref.context;
14
+ // Check whether all criteria needed to make a transformation are met
15
+ var _ImportDeclaration$_c = ImportDeclaration._check(node),
16
+ success = _ImportDeclaration$_c.success,
17
+ ref = _ImportDeclaration$_c.ref;
18
+ if (!success) {
19
+ return;
20
+ }
21
+ context.report({
22
+ node: ref,
23
+ messageId: messageId
24
+ });
25
+ },
26
+ _check: function _check(node) {
27
+ if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'ImportDeclaration')) {
28
+ return {
29
+ success: false,
30
+ ref: undefined
31
+ };
32
+ }
33
+ return {
34
+ success: true,
35
+ ref: node
36
+ };
37
+ }
38
+ };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "ImportDeclaration", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _importDeclaration.ImportDeclaration;
10
+ }
11
+ });
12
+ var _importDeclaration = require("./import-declaration");
@@ -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::6210f09c70f4d44befb986dfd548ed3e>>
3
+ * @codegen <<SignedSource::5aac2d8dc7c2832bcb8a96a143d60db5>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -69,6 +69,7 @@ const rules = {
69
69
  '@atlaskit/design-system/use-primitives': 'warn',
70
70
  '@atlaskit/design-system/use-primitives-text': 'warn',
71
71
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
72
+ '@atlaskit/design-system/use-spotlight-package': 'warn',
72
73
  '@atlaskit/design-system/use-tag-group-label': 'warn',
73
74
  '@atlaskit/design-system/use-tokens-shape': 'error',
74
75
  '@atlaskit/design-system/use-tokens-space': 'error',
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::daf4a5893d65c7a1592f8bc6e51920c6>>
3
+ * @codegen <<SignedSource::43ea4411c4e338a916772d4bfda146cc>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -68,6 +68,7 @@ const rules = {
68
68
  '@atlaskit/design-system/use-primitives': 'warn',
69
69
  '@atlaskit/design-system/use-primitives-text': 'warn',
70
70
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
71
+ '@atlaskit/design-system/use-spotlight-package': 'warn',
71
72
  '@atlaskit/design-system/use-tag-group-label': 'warn',
72
73
  '@atlaskit/design-system/use-tokens-shape': 'error',
73
74
  '@atlaskit/design-system/use-tokens-space': 'error',
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::4693db80b637ac078521dd6e0591f75b>>
3
+ * @codegen <<SignedSource::732bff0fc39d7ff05b6688694101698d>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -66,6 +66,7 @@ import usePopupLabel from './use-popup-label';
66
66
  import usePrimitives from './use-primitives';
67
67
  import usePrimitivesText from './use-primitives-text';
68
68
  import useShouldRenderToParent from './use-should-render-to-parent';
69
+ import useSpotlightPackage from './use-spotlight-package';
69
70
  import useTagGroupLabel from './use-tag-group-label';
70
71
  import useTokensShape from './use-tokens-shape';
71
72
  import useTokensSpace from './use-tokens-space';
@@ -134,6 +135,7 @@ export const rules = {
134
135
  'use-primitives': usePrimitives,
135
136
  'use-primitives-text': usePrimitivesText,
136
137
  'use-should-render-to-parent': useShouldRenderToParent,
138
+ 'use-spotlight-package': useSpotlightPackage,
137
139
  'use-tag-group-label': useTagGroupLabel,
138
140
  'use-tokens-shape': useTokensShape,
139
141
  'use-tokens-space': useTokensSpace,
@@ -13,6 +13,12 @@ export const getDeprecationIconHandler = context => {
13
13
  const identifiers = new Map();
14
14
  const importErrors = {};
15
15
  const exportErrors = {};
16
+ const getConfigFlag = (key, defaultValue) => {
17
+ if (context.options && context.options.length > 0 && context.options[0] && context.options[0].hasOwnProperty(key)) {
18
+ return context.options[0][key] === !defaultValue ? !defaultValue : defaultValue;
19
+ }
20
+ return defaultValue;
21
+ };
16
22
  const getIconComponentName = name => {
17
23
  return name.split(/\W/).map(part => `${part[0].toUpperCase()}${part.slice(1)}`).join('').concat('Icon');
18
24
  };
@@ -52,6 +58,7 @@ export const getDeprecationIconHandler = context => {
52
58
  }
53
59
  };
54
60
  const throwErrors = () => {
61
+ const shouldTurnOffAutoFixer = getConfigFlag('turnOffAutoFixer', false);
55
62
  for (const [importSource, error] of Object.entries(importErrors)) {
56
63
  if (importSource.includes('/migration/')) {
57
64
  var _metadata$deprecatedI, _error$data;
@@ -61,7 +68,9 @@ export const getDeprecationIconHandler = context => {
61
68
  const replacement = metadata === null || metadata === void 0 ? void 0 : (_metadata$deprecatedI = metadata[deprecatedIconName]) === null || _metadata$deprecatedI === void 0 ? void 0 : _metadata$deprecatedI.replacement;
62
69
  if (replacement && ((_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.unfixable) === 'false') {
63
70
  const newIconName = getIconComponentName(replacement.name);
64
- addAutoFix(error, importSource, `${replacement.location}/${replacement.type}/migration/${replacement.name}--${legacyIconName}`, newIconName);
71
+ if (!shouldTurnOffAutoFixer) {
72
+ addAutoFix(error, importSource, `${replacement.location}/${replacement.type}/migration/${replacement.name}--${legacyIconName}`, newIconName);
73
+ }
65
74
  }
66
75
  } else {
67
76
  var _metadata, _metadata$name;
@@ -75,7 +84,9 @@ export const getDeprecationIconHandler = context => {
75
84
  const replacement = (_metadata = metadata) === null || _metadata === void 0 ? void 0 : (_metadata$name = _metadata[name]) === null || _metadata$name === void 0 ? void 0 : _metadata$name.replacement;
76
85
  if (replacement) {
77
86
  const newIconName = getIconComponentName(replacement.name);
78
- addAutoFix(error, importSource, `${replacement.location}/${replacement.type}/${replacement.name}`, newIconName);
87
+ if (!shouldTurnOffAutoFixer) {
88
+ addAutoFix(error, importSource, `${replacement.location}/${replacement.type}/${replacement.name}`, newIconName);
89
+ }
79
90
  }
80
91
  }
81
92
  context.report(error);
@@ -47,6 +47,9 @@ const rule = createLintRule({
47
47
  schema: [{
48
48
  type: 'object',
49
49
  properties: {
50
+ turnOffAutoFixer: {
51
+ type: 'boolean'
52
+ },
50
53
  deprecatedConfig: {
51
54
  type: 'object',
52
55
  properties: {
@@ -75,7 +78,8 @@ const rule = createLintRule({
75
78
  }
76
79
  }
77
80
  }
78
- }
81
+ },
82
+ additionalProperties: false
79
83
  }]
80
84
  },
81
85
  create(context) {
@@ -0,0 +1,26 @@
1
+ import { createLintRule } from '../utils/create-rule';
2
+ import { ImportDeclaration } from './linters';
3
+ const rule = createLintRule({
4
+ meta: {
5
+ name: 'use-spotlight-package',
6
+ type: 'problem',
7
+ fixable: 'code',
8
+ hasSuggestions: true,
9
+ docs: {
10
+ description: 'Discourage the use of deprecated imports from @atlaskit/onboarding in favor of @atlaskit/spotlight.',
11
+ recommended: false,
12
+ severity: 'warn'
13
+ },
14
+ messages: {
15
+ ['use-spotlight-package']: '@atlaskit/onboarding is being deprecated in favor of @atlaskit/spotlight. Please migrate your spotlight experiences accordingly.'
16
+ }
17
+ },
18
+ create(context) {
19
+ return {
20
+ 'ImportDeclaration[source.value="@atlaskit/onboarding"]': node => ImportDeclaration.lint(node, {
21
+ context
22
+ })
23
+ };
24
+ }
25
+ });
26
+ export default rule;
@@ -0,0 +1,34 @@
1
+ /* eslint-disable @repo/internal/react/require-jsdoc */
2
+
3
+ import { isNodeOfType } from 'eslint-codemod-utils';
4
+ const messageId = 'use-spotlight-package';
5
+ export const ImportDeclaration = {
6
+ lint(node, {
7
+ context
8
+ }) {
9
+ // Check whether all criteria needed to make a transformation are met
10
+ const {
11
+ success,
12
+ ref
13
+ } = ImportDeclaration._check(node);
14
+ if (!success) {
15
+ return;
16
+ }
17
+ context.report({
18
+ node: ref,
19
+ messageId
20
+ });
21
+ },
22
+ _check(node) {
23
+ if (!isNodeOfType(node, 'ImportDeclaration')) {
24
+ return {
25
+ success: false,
26
+ ref: undefined
27
+ };
28
+ }
29
+ return {
30
+ success: true,
31
+ ref: node
32
+ };
33
+ }
34
+ };
@@ -0,0 +1 @@
1
+ export { ImportDeclaration } from './import-declaration';
@@ -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::6210f09c70f4d44befb986dfd548ed3e>>
3
+ * @codegen <<SignedSource::5aac2d8dc7c2832bcb8a96a143d60db5>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -69,6 +69,7 @@ var rules = {
69
69
  '@atlaskit/design-system/use-primitives': 'warn',
70
70
  '@atlaskit/design-system/use-primitives-text': 'warn',
71
71
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
72
+ '@atlaskit/design-system/use-spotlight-package': 'warn',
72
73
  '@atlaskit/design-system/use-tag-group-label': 'warn',
73
74
  '@atlaskit/design-system/use-tokens-shape': 'error',
74
75
  '@atlaskit/design-system/use-tokens-space': 'error',
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::daf4a5893d65c7a1592f8bc6e51920c6>>
3
+ * @codegen <<SignedSource::43ea4411c4e338a916772d4bfda146cc>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -68,6 +68,7 @@ var rules = {
68
68
  '@atlaskit/design-system/use-primitives': 'warn',
69
69
  '@atlaskit/design-system/use-primitives-text': 'warn',
70
70
  '@atlaskit/design-system/use-should-render-to-parent': 'warn',
71
+ '@atlaskit/design-system/use-spotlight-package': 'warn',
71
72
  '@atlaskit/design-system/use-tag-group-label': 'warn',
72
73
  '@atlaskit/design-system/use-tokens-shape': 'error',
73
74
  '@atlaskit/design-system/use-tokens-space': 'error',
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
- * @codegen <<SignedSource::4693db80b637ac078521dd6e0591f75b>>
3
+ * @codegen <<SignedSource::732bff0fc39d7ff05b6688694101698d>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
 
@@ -66,6 +66,7 @@ import usePopupLabel from './use-popup-label';
66
66
  import usePrimitives from './use-primitives';
67
67
  import usePrimitivesText from './use-primitives-text';
68
68
  import useShouldRenderToParent from './use-should-render-to-parent';
69
+ import useSpotlightPackage from './use-spotlight-package';
69
70
  import useTagGroupLabel from './use-tag-group-label';
70
71
  import useTokensShape from './use-tokens-shape';
71
72
  import useTokensSpace from './use-tokens-space';
@@ -134,6 +135,7 @@ export var rules = {
134
135
  'use-primitives': usePrimitives,
135
136
  'use-primitives-text': usePrimitivesText,
136
137
  'use-should-render-to-parent': useShouldRenderToParent,
138
+ 'use-spotlight-package': useSpotlightPackage,
137
139
  'use-tag-group-label': useTagGroupLabel,
138
140
  'use-tokens-shape': useTokensShape,
139
141
  'use-tokens-space': useTokensSpace,
@@ -17,6 +17,12 @@ export var getDeprecationIconHandler = function getDeprecationIconHandler(contex
17
17
  var identifiers = new Map();
18
18
  var importErrors = {};
19
19
  var exportErrors = {};
20
+ var getConfigFlag = function getConfigFlag(key, defaultValue) {
21
+ if (context.options && context.options.length > 0 && context.options[0] && context.options[0].hasOwnProperty(key)) {
22
+ return context.options[0][key] === !defaultValue ? !defaultValue : defaultValue;
23
+ }
24
+ return defaultValue;
25
+ };
20
26
  var getIconComponentName = function getIconComponentName(name) {
21
27
  return name.split(/\W/).map(function (part) {
22
28
  return "".concat(part[0].toUpperCase()).concat(part.slice(1));
@@ -56,6 +62,7 @@ export var getDeprecationIconHandler = function getDeprecationIconHandler(contex
56
62
  }
57
63
  };
58
64
  var throwErrors = function throwErrors() {
65
+ var shouldTurnOffAutoFixer = getConfigFlag('turnOffAutoFixer', false);
59
66
  for (var _i = 0, _Object$entries = Object.entries(importErrors); _i < _Object$entries.length; _i++) {
60
67
  var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
61
68
  importSource = _Object$entries$_i[0],
@@ -76,7 +83,9 @@ export var getDeprecationIconHandler = function getDeprecationIconHandler(contex
76
83
  var replacement = metadata === null || metadata === void 0 || (_metadata$deprecatedI = metadata[deprecatedIconName]) === null || _metadata$deprecatedI === void 0 ? void 0 : _metadata$deprecatedI.replacement;
77
84
  if (replacement && ((_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.unfixable) === 'false') {
78
85
  var newIconName = getIconComponentName(replacement.name);
79
- addAutoFix(error, importSource, "".concat(replacement.location, "/").concat(replacement.type, "/migration/").concat(replacement.name, "--").concat(legacyIconName), newIconName);
86
+ if (!shouldTurnOffAutoFixer) {
87
+ addAutoFix(error, importSource, "".concat(replacement.location, "/").concat(replacement.type, "/migration/").concat(replacement.name, "--").concat(legacyIconName), newIconName);
88
+ }
80
89
  }
81
90
  } else {
82
91
  var _metadata2;
@@ -94,7 +103,9 @@ export var getDeprecationIconHandler = function getDeprecationIconHandler(contex
94
103
  var _replacement = (_metadata2 = _metadata) === null || _metadata2 === void 0 || (_metadata2 = _metadata2[_name]) === null || _metadata2 === void 0 ? void 0 : _metadata2.replacement;
95
104
  if (_replacement) {
96
105
  var _newIconName = getIconComponentName(_replacement.name);
97
- addAutoFix(error, importSource, "".concat(_replacement.location, "/").concat(_replacement.type, "/").concat(_replacement.name), _newIconName);
106
+ if (!shouldTurnOffAutoFixer) {
107
+ addAutoFix(error, importSource, "".concat(_replacement.location, "/").concat(_replacement.type, "/").concat(_replacement.name), _newIconName);
108
+ }
98
109
  }
99
110
  }
100
111
  context.report(error);
@@ -47,6 +47,9 @@ var rule = createLintRule({
47
47
  schema: [{
48
48
  type: 'object',
49
49
  properties: {
50
+ turnOffAutoFixer: {
51
+ type: 'boolean'
52
+ },
50
53
  deprecatedConfig: {
51
54
  type: 'object',
52
55
  properties: {
@@ -75,7 +78,8 @@ var rule = createLintRule({
75
78
  }
76
79
  }
77
80
  }
78
- }
81
+ },
82
+ additionalProperties: false
79
83
  }]
80
84
  },
81
85
  create: function create(context) {
@@ -0,0 +1,27 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import { createLintRule } from '../utils/create-rule';
3
+ import { ImportDeclaration } from './linters';
4
+ var rule = createLintRule({
5
+ meta: {
6
+ name: 'use-spotlight-package',
7
+ type: 'problem',
8
+ fixable: 'code',
9
+ hasSuggestions: true,
10
+ docs: {
11
+ description: 'Discourage the use of deprecated imports from @atlaskit/onboarding in favor of @atlaskit/spotlight.',
12
+ recommended: false,
13
+ severity: 'warn'
14
+ },
15
+ messages: _defineProperty({}, 'use-spotlight-package', '@atlaskit/onboarding is being deprecated in favor of @atlaskit/spotlight. Please migrate your spotlight experiences accordingly.')
16
+ },
17
+ create: function create(context) {
18
+ return {
19
+ 'ImportDeclaration[source.value="@atlaskit/onboarding"]': function ImportDeclarationSourceValueAtlaskit_onboarding(node) {
20
+ return ImportDeclaration.lint(node, {
21
+ context: context
22
+ });
23
+ }
24
+ };
25
+ }
26
+ });
27
+ export default rule;
@@ -0,0 +1,32 @@
1
+ /* eslint-disable @repo/internal/react/require-jsdoc */
2
+
3
+ import { isNodeOfType } from 'eslint-codemod-utils';
4
+ var messageId = 'use-spotlight-package';
5
+ export var ImportDeclaration = {
6
+ lint: function lint(node, _ref) {
7
+ var context = _ref.context;
8
+ // Check whether all criteria needed to make a transformation are met
9
+ var _ImportDeclaration$_c = ImportDeclaration._check(node),
10
+ success = _ImportDeclaration$_c.success,
11
+ ref = _ImportDeclaration$_c.ref;
12
+ if (!success) {
13
+ return;
14
+ }
15
+ context.report({
16
+ node: ref,
17
+ messageId: messageId
18
+ });
19
+ },
20
+ _check: function _check(node) {
21
+ if (!isNodeOfType(node, 'ImportDeclaration')) {
22
+ return {
23
+ success: false,
24
+ ref: undefined
25
+ };
26
+ }
27
+ return {
28
+ success: true,
29
+ ref: node
30
+ };
31
+ }
32
+ };
@@ -0,0 +1 @@
1
+ export { ImportDeclaration } from './import-declaration';
@@ -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::6210f09c70f4d44befb986dfd548ed3e>>
3
+ * @codegen <<SignedSource::5aac2d8dc7c2832bcb8a96a143d60db5>>
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::daf4a5893d65c7a1592f8bc6e51920c6>>
3
+ * @codegen <<SignedSource::43ea4411c4e338a916772d4bfda146cc>>
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::4693db80b637ac078521dd6e0591f75b>>
3
+ * @codegen <<SignedSource::732bff0fc39d7ff05b6688694101698d>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  import type { Rule } from 'eslint';
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ declare const rule: Rule.RuleModule;
3
+ export default rule;
@@ -0,0 +1,16 @@
1
+ import type { Rule } from 'eslint';
2
+ import { type ImportDeclaration as ImportDeclarationNode } from 'eslint-codemod-utils';
3
+ type Check = {
4
+ success: false;
5
+ ref: undefined;
6
+ } | {
7
+ success: true;
8
+ ref: ImportDeclarationNode;
9
+ };
10
+ export declare const ImportDeclaration: {
11
+ lint(node: Rule.Node, { context }: {
12
+ context: Rule.RuleContext;
13
+ }): void;
14
+ _check(node: Rule.Node): Check;
15
+ };
16
+ export {};
@@ -0,0 +1 @@
1
+ export { ImportDeclaration } from './import-declaration';
@@ -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::6210f09c70f4d44befb986dfd548ed3e>>
3
+ * @codegen <<SignedSource::5aac2d8dc7c2832bcb8a96a143d60db5>>
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::daf4a5893d65c7a1592f8bc6e51920c6>>
3
+ * @codegen <<SignedSource::43ea4411c4e338a916772d4bfda146cc>>
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::4693db80b637ac078521dd6e0591f75b>>
3
+ * @codegen <<SignedSource::732bff0fc39d7ff05b6688694101698d>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  import type { Rule } from 'eslint';
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ declare const rule: Rule.RuleModule;
3
+ export default rule;
@@ -0,0 +1,16 @@
1
+ import type { Rule } from 'eslint';
2
+ import { type ImportDeclaration as ImportDeclarationNode } from 'eslint-codemod-utils';
3
+ type Check = {
4
+ success: false;
5
+ ref: undefined;
6
+ } | {
7
+ success: true;
8
+ ref: ImportDeclarationNode;
9
+ };
10
+ export declare const ImportDeclaration: {
11
+ lint(node: Rule.Node, { context }: {
12
+ context: Rule.RuleContext;
13
+ }): void;
14
+ _check(node: Rule.Node): Check;
15
+ };
16
+ export {};
@@ -0,0 +1 @@
1
+ export { ImportDeclaration } from './import-declaration';
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.21.3",
4
+ "version": "13.23.0",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
7
7
  "publishConfig": {