@atlaskit/eslint-plugin-design-system 10.25.0 → 10.26.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 (32) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +1 -1
  3. package/dist/cjs/rules/no-deprecated-imports/checks.js +201 -0
  4. package/dist/cjs/rules/no-deprecated-imports/constants.js +8 -0
  5. package/dist/cjs/rules/no-deprecated-imports/handlers/icon.js +204 -0
  6. package/dist/cjs/rules/no-deprecated-imports/index.js +25 -118
  7. package/dist/cjs/rules/utils/get-deprecated-config.js +9 -1
  8. package/dist/es2019/rules/no-deprecated-imports/checks.js +175 -0
  9. package/dist/es2019/rules/no-deprecated-imports/constants.js +2 -0
  10. package/dist/es2019/rules/no-deprecated-imports/handlers/icon.js +153 -0
  11. package/dist/es2019/rules/no-deprecated-imports/index.js +23 -103
  12. package/dist/es2019/rules/utils/get-deprecated-config.js +12 -1
  13. package/dist/esm/rules/no-deprecated-imports/checks.js +195 -0
  14. package/dist/esm/rules/no-deprecated-imports/constants.js +2 -0
  15. package/dist/esm/rules/no-deprecated-imports/handlers/icon.js +197 -0
  16. package/dist/esm/rules/no-deprecated-imports/index.js +23 -117
  17. package/dist/esm/rules/utils/get-deprecated-config.js +9 -1
  18. package/dist/types/index.codegen.d.ts +3 -9
  19. package/dist/types/rules/index.codegen.d.ts +1 -3
  20. package/dist/types/rules/no-deprecated-imports/checks.d.ts +11 -0
  21. package/dist/types/rules/no-deprecated-imports/constants.d.ts +2 -0
  22. package/dist/types/rules/no-deprecated-imports/handlers/icon.d.ts +38 -0
  23. package/dist/types/rules/no-deprecated-imports/index.d.ts +1 -7
  24. package/dist/types/rules/utils/types.d.ts +1 -0
  25. package/dist/types-ts4.5/index.codegen.d.ts +3 -15
  26. package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -5
  27. package/dist/types-ts4.5/rules/no-deprecated-imports/checks.d.ts +11 -0
  28. package/dist/types-ts4.5/rules/no-deprecated-imports/constants.d.ts +2 -0
  29. package/dist/types-ts4.5/rules/no-deprecated-imports/handlers/icon.d.ts +38 -0
  30. package/dist/types-ts4.5/rules/no-deprecated-imports/index.d.ts +1 -9
  31. package/dist/types-ts4.5/rules/utils/types.d.ts +1 -0
  32. package/package.json +3 -2
@@ -0,0 +1,2 @@
1
+ export var importNameWithCustomMessageId = 'importNameWithCustomMessage';
2
+ export var pathWithCustomMessageId = 'pathWithCustomMessage';
@@ -0,0 +1,197 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ 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; } } }; }
3
+ 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; } }
4
+ 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; }
5
+ import { isNodeOfType, literal } from 'eslint-codemod-utils';
6
+ import coreIconLabMetadata from '@atlaskit/icon-lab/metadata';
7
+ import { coreIconMetadata, utilityIconMetadata } from '@atlaskit/icon/metadata';
8
+ import { pathWithCustomMessageId } from '../constants';
9
+ /**
10
+ * __Deprecation icon handler__
11
+ *
12
+ * A deprecation icon handler which is responsible for displaying an error for deprecated icons.
13
+ * It also includes a fixer to replace the deprecated icon with the new icon if a replacement exists.
14
+ */
15
+ export var getDeprecationIconHandler = function getDeprecationIconHandler(context) {
16
+ var jsxElements = new Map();
17
+ var identifiers = new Map();
18
+ var importErrors = {};
19
+ var exportErrors = {};
20
+ var getIconComponentName = function getIconComponentName(name) {
21
+ return name.split(/\W/).map(function (part) {
22
+ return "".concat(part[0].toUpperCase()).concat(part.slice(1));
23
+ }).join('').concat('Icon');
24
+ };
25
+ var createImportError = function createImportError(_ref) {
26
+ var node = _ref.node,
27
+ importSource = _ref.importSource,
28
+ config = _ref.config;
29
+ if (config.message) {
30
+ var myError = {
31
+ node: node,
32
+ messageId: pathWithCustomMessageId,
33
+ data: {
34
+ importSource: importSource,
35
+ customMessage: config.message,
36
+ unfixable: config.unfixable ? 'true' : 'false'
37
+ }
38
+ };
39
+ importErrors[node.source.value] = myError;
40
+ }
41
+ };
42
+ var createExportError = function createExportError(_ref2) {
43
+ var node = _ref2.node,
44
+ importSource = _ref2.importSource,
45
+ config = _ref2.config;
46
+ if (config.message) {
47
+ var myError = {
48
+ node: node,
49
+ messageId: pathWithCustomMessageId,
50
+ data: {
51
+ importSource: importSource,
52
+ customMessage: config.message
53
+ }
54
+ };
55
+ exportErrors[importSource] = myError;
56
+ }
57
+ };
58
+ var throwErrors = function throwErrors() {
59
+ for (var _i = 0, _Object$entries = Object.entries(importErrors); _i < _Object$entries.length; _i++) {
60
+ var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
61
+ importSource = _Object$entries$_i[0],
62
+ error = _Object$entries$_i[1];
63
+ if (importSource.includes('/migration/')) {
64
+ var _metadata$deprecatedI, _error$data;
65
+ var _importSource$split$s = importSource.split('/').slice(1),
66
+ _importSource$split$s2 = _slicedToArray(_importSource$split$s, 4),
67
+ _location = _importSource$split$s2[0],
68
+ type = _importSource$split$s2[1],
69
+ _migration = _importSource$split$s2[2],
70
+ name = _importSource$split$s2[3];
71
+ var metadata = type === 'core' ? coreIconMetadata : utilityIconMetadata;
72
+ var _name$split = name.split('--'),
73
+ _name$split2 = _slicedToArray(_name$split, 2),
74
+ deprecatedIconName = _name$split2[0],
75
+ legacyIconName = _name$split2[1];
76
+ var replacement = metadata === null || metadata === void 0 || (_metadata$deprecatedI = metadata[deprecatedIconName]) === null || _metadata$deprecatedI === void 0 ? void 0 : _metadata$deprecatedI.replacement;
77
+ if (replacement && ((_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.unfixable) === 'false') {
78
+ var newIconName = getIconComponentName(replacement.name);
79
+ addAutoFix(error, importSource, "".concat(replacement.location, "/").concat(replacement.type, "/migration/").concat(replacement.name, "--").concat(legacyIconName), newIconName);
80
+ }
81
+ } else {
82
+ var _metadata2;
83
+ var _importSource$split$s3 = importSource.split('/').slice(1),
84
+ _importSource$split$s4 = _slicedToArray(_importSource$split$s3, 3),
85
+ location = _importSource$split$s4[0],
86
+ _type = _importSource$split$s4[1],
87
+ _name = _importSource$split$s4[2];
88
+ var _metadata = void 0;
89
+ if (location === 'icon') {
90
+ _metadata = _type === 'core' ? coreIconMetadata : utilityIconMetadata;
91
+ } else if (location === 'icon-lab') {
92
+ _metadata = coreIconLabMetadata;
93
+ }
94
+ var _replacement = (_metadata2 = _metadata) === null || _metadata2 === void 0 || (_metadata2 = _metadata2[_name]) === null || _metadata2 === void 0 ? void 0 : _metadata2.replacement;
95
+ if (_replacement) {
96
+ var _newIconName = getIconComponentName(_replacement.name);
97
+ addAutoFix(error, importSource, "".concat(_replacement.location, "/").concat(_replacement.type, "/").concat(_replacement.name), _newIconName);
98
+ }
99
+ }
100
+ context.report(error);
101
+ }
102
+ for (var _i2 = 0, _Object$values = Object.values(exportErrors); _i2 < _Object$values.length; _i2++) {
103
+ var _error = _Object$values[_i2];
104
+ context.report(_error);
105
+ }
106
+ };
107
+ var addAutoFix = function addAutoFix(error, importSource, newImportSource, newIconName) {
108
+ error.fix = function (fixer) {
109
+ var fixes = [];
110
+
111
+ //Find and update all usages of this icon in JSX with the replacement icon
112
+ var jsxUsageNodes = jsxElements.get(importSource);
113
+ if (jsxUsageNodes) {
114
+ var _iterator = _createForOfIteratorHelper(jsxUsageNodes),
115
+ _step;
116
+ try {
117
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
118
+ var usageNode = _step.value;
119
+ fixes.push(fixer.replaceText(usageNode.openingElement.name, newIconName));
120
+ }
121
+ } catch (err) {
122
+ _iterator.e(err);
123
+ } finally {
124
+ _iterator.f();
125
+ }
126
+ }
127
+
128
+ //Find and update all usages of this icon in identifiers with the replacement icon
129
+ var usageNodes = identifiers.get(importSource);
130
+ if (usageNodes) {
131
+ var _iterator2 = _createForOfIteratorHelper(usageNodes),
132
+ _step2;
133
+ try {
134
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
135
+ var _usageNode = _step2.value;
136
+ fixes.push(fixer.replaceText(_usageNode.parent, "{".concat(newIconName, "}")));
137
+ }
138
+ } catch (err) {
139
+ _iterator2.e(err);
140
+ } finally {
141
+ _iterator2.f();
142
+ }
143
+ }
144
+ fixes.push(fixer.replaceText(error.node, "".concat(literal("import ".concat(newIconName, " from '").concat(newImportSource, "'")), ";")));
145
+ return fixes;
146
+ };
147
+ };
148
+ var checkJSXElement = function checkJSXElement(node) {
149
+ if (!('openingElement' in node) || !isNodeOfType(node.openingElement.name, 'JSXIdentifier')) {
150
+ return;
151
+ }
152
+ for (var _i3 = 0, _Object$entries2 = Object.entries(importErrors); _i3 < _Object$entries2.length; _i3++) {
153
+ var _Object$entries2$_i = _slicedToArray(_Object$entries2[_i3], 2),
154
+ importSource = _Object$entries2$_i[0],
155
+ error = _Object$entries2$_i[1];
156
+ var importIconName = error.node.specifiers[0].local.name;
157
+ var iconName = node.openingElement.name.name;
158
+ if (iconName === importIconName) {
159
+ if (jsxElements.has(importSource)) {
160
+ var _jsxElements$get;
161
+ (_jsxElements$get = jsxElements.get(importSource)) === null || _jsxElements$get === void 0 || _jsxElements$get.push(node);
162
+ } else {
163
+ jsxElements.set(importSource, [node]);
164
+ }
165
+ break;
166
+ }
167
+ }
168
+ };
169
+ var checkIdentifier = function checkIdentifier(node) {
170
+ if (node.type !== 'Identifier' || node.parent.type !== 'JSXExpressionContainer') {
171
+ return;
172
+ }
173
+ for (var _i4 = 0, _Object$entries3 = Object.entries(importErrors); _i4 < _Object$entries3.length; _i4++) {
174
+ var _Object$entries3$_i = _slicedToArray(_Object$entries3[_i4], 2),
175
+ importSource = _Object$entries3$_i[0],
176
+ error = _Object$entries3$_i[1];
177
+ var importIconName = error.node.specifiers[0].local.name;
178
+ var iconName = node.name;
179
+ if (iconName === importIconName) {
180
+ if (identifiers.has(importSource)) {
181
+ var _identifiers$get;
182
+ (_identifiers$get = identifiers.get(importSource)) === null || _identifiers$get === void 0 || _identifiers$get.push(node);
183
+ } else {
184
+ identifiers.set(importSource, [node]);
185
+ }
186
+ break;
187
+ }
188
+ }
189
+ };
190
+ return {
191
+ createImportError: createImportError,
192
+ createExportError: createExportError,
193
+ checkJSXElement: checkJSXElement,
194
+ checkIdentifier: checkIdentifier,
195
+ throwErrors: throwErrors
196
+ };
197
+ };
@@ -1,7 +1,3 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- 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; } } }; }
3
- 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; } }
4
- 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; }
5
1
  /**
6
2
  * Forked from original `no-restricted-imports` although the source has been substantially changed.
7
3
  *
@@ -29,22 +25,20 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
29
25
  * THE SOFTWARE.
30
26
  */
31
27
 
32
- import { createRule } from '../utils/create-rule';
33
- import { getConfig } from '../utils/get-deprecated-config';
34
- import { isDeprecatedImportConfig } from '../utils/types';
28
+ import { createLintRule } from '../utils/create-rule';
29
+ import { errorBoundary } from '../utils/error-boundary';
30
+ import { createChecks } from './checks';
35
31
  export var name = 'no-deprecated-imports';
36
- export var importNameWithCustomMessageId = 'importNameWithCustomMessage';
37
- export var pathWithCustomMessageId = 'pathWithCustomMessage';
38
- var rule = createRule({
39
- name: name,
40
- defaultOptions: [{
41
- deprecatedConfig: getConfig('imports')
42
- }],
32
+ var rule = createLintRule({
43
33
  meta: {
34
+ name: name,
35
+ fixable: 'code',
36
+ hasSuggestions: true,
44
37
  type: 'suggestion',
45
38
  docs: {
46
39
  description: 'Disallow importing deprecated modules.',
47
- recommended: 'error'
40
+ recommended: true,
41
+ severity: 'error'
48
42
  },
49
43
  messages: {
50
44
  pathWithCustomMessage: "'{{importSource}}' import is restricted from being used. {{customMessage}}",
@@ -84,108 +78,20 @@ var rule = createRule({
84
78
  }
85
79
  }]
86
80
  },
87
- create: function create(context, _ref) {
88
- var _context$options$;
89
- var _ref2 = _slicedToArray(_ref, 1),
90
- options = _ref2[0];
91
- var defaultDeprecatedConfig = options.deprecatedConfig;
92
- var restrictedPathMessages = ((_context$options$ = context.options[0]) === null || _context$options$ === void 0 ? void 0 : _context$options$.deprecatedConfig) || defaultDeprecatedConfig;
93
- if (!isDeprecatedImportConfig(restrictedPathMessages)) {
94
- throw new Error('Config is invalid for deprecated imports');
95
- }
96
-
97
- /**
98
- * Report a restricted path.
99
- * @param {string} importSource path of the import
100
- * @param {node} node representing the restricted path reference
101
- * @param {Map<string,TSESTree.Node>} importNames Map of import names that are being imported
102
- * @returns {void}
103
- * @private
104
- */
105
- function checkRestrictedPathAndReport(importSource, node, importNames) {
106
- if (!Object.prototype.hasOwnProperty.call(restrictedPathMessages, importSource)) {
107
- return;
108
- }
109
- var config = restrictedPathMessages[importSource];
110
-
111
- // The message will only exist if the import is completely banned,
112
- // eg a deprecated package
113
- if ('message' in config) {
114
- context.report({
115
- node: node,
116
- messageId: pathWithCustomMessageId,
117
- data: {
118
- importSource: importSource,
119
- customMessage: config.message
120
- }
121
- });
122
- }
123
-
124
- // if there are specific named exports that are banned,
125
- // iterate through and check if they're being imported
126
- if ('importSpecifiers' in config) {
127
- var _config$importSpecifi;
128
- (_config$importSpecifi = config.importSpecifiers) === null || _config$importSpecifi === void 0 || _config$importSpecifi.forEach(function (restrictedImport) {
129
- if (importNames.has(restrictedImport.importName)) {
130
- context.report({
131
- node: importNames.get(restrictedImport.importName),
132
- messageId: importNameWithCustomMessageId,
133
- data: {
134
- importName: restrictedImport.importName,
135
- importSource: importSource,
136
- customMessage: restrictedImport.message
137
- }
138
- });
139
- }
140
- });
141
- }
142
- }
143
-
144
- /**
145
- * Checks a node to see if any problems should be reported.
146
- * @param {ASTNode} node The node to check.
147
- * @returns {void}
148
- * @private
149
- */
150
- var checkNode = function checkNode(node) {
151
- var importSource = node.source.value.trim();
152
- var importNames = new Map();
153
- if ('specifiers' in node) {
154
- var _iterator = _createForOfIteratorHelper(node.specifiers),
155
- _step;
156
- try {
157
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
158
- var specifier = _step.value;
159
- var _name = void 0;
160
- if (specifier.type === 'ImportDefaultSpecifier') {
161
- _name = 'default';
162
- } else if (specifier.type === 'ImportNamespaceSpecifier') {
163
- _name = '*';
164
- } else if (specifier.type === 'ImportSpecifier') {
165
- _name = specifier.imported.name;
166
- } else if (specifier.local) {
167
- _name = specifier.local.name;
168
- }
169
- if (_name) {
170
- importNames.set(_name, specifier);
171
- }
172
- }
173
- } catch (err) {
174
- _iterator.e(err);
175
- } finally {
176
- _iterator.f();
177
- }
178
- }
179
- checkRestrictedPathAndReport(importSource, node, importNames);
180
- };
181
- return {
182
- ImportDeclaration: checkNode,
183
- ExportNamedDeclaration: function ExportNamedDeclaration(node) {
184
- if (node.source) {
185
- checkNode(node);
186
- }
187
- }
188
- };
81
+ create: function create(context) {
82
+ var _createChecks = createChecks(context),
83
+ checkImportNode = _createChecks.checkImportNode,
84
+ checkExportNode = _createChecks.checkExportNode,
85
+ checkJSXElement = _createChecks.checkJSXElement,
86
+ checkIdentifier = _createChecks.checkIdentifier,
87
+ throwErrors = _createChecks.throwErrors;
88
+ return errorBoundary({
89
+ ImportDeclaration: checkImportNode,
90
+ ExportNamedDeclaration: checkExportNode,
91
+ JSXElement: checkJSXElement,
92
+ Identifier: checkIdentifier,
93
+ 'Program:exit': throwErrors
94
+ });
189
95
  }
190
96
  });
191
97
  export default rule;
@@ -1,8 +1,16 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
1
4
  import fs from 'fs';
2
5
  import path from 'path';
6
+ import { deprecatedCore as deprecatedIconLabCore } from '@atlaskit/icon-lab/deprecated-map';
7
+ import { deprecatedCore as deprecatedIconCore, deprecatedUtility as deprecatedIconUtility } from '@atlaskit/icon/deprecated-map';
3
8
  export var getConfig = function getConfig(specifier) {
4
9
  var configPath = path.resolve(__dirname, '..', '..', '..', 'configs', 'deprecated.json');
5
10
  var source = fs.readFileSync(configPath, 'utf8');
6
11
  var parsedConfig = JSON.parse(source);
7
- return parsedConfig[specifier];
12
+ var combinedConfig = _objectSpread(_objectSpread({}, parsedConfig), {}, {
13
+ imports: _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, parsedConfig.imports), deprecatedIconCore), deprecatedIconUtility), deprecatedIconLabCore)
14
+ });
15
+ return combinedConfig[specifier];
8
16
  };
@@ -17,9 +17,7 @@ export declare const plugin: {
17
17
  deprecatedConfig: import("./rules/utils/types").DeprecatedConfig;
18
18
  }], import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
19
19
  'no-deprecated-design-token-usage': import("eslint").Rule.RuleModule;
20
- 'no-deprecated-imports': import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<string, [{
21
- deprecatedConfig: import("./rules/utils/types").DeprecatedConfig;
22
- }], import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
20
+ 'no-deprecated-imports': import("eslint").Rule.RuleModule;
23
21
  'no-direct-use-of-web-platform-drag-and-drop': import("eslint").Rule.RuleModule;
24
22
  'no-empty-styled-expression': import("eslint").Rule.RuleModule;
25
23
  'no-exported-css': import("eslint").Rule.RuleModule;
@@ -309,9 +307,7 @@ export declare const configs: {
309
307
  deprecatedConfig: import("./rules/utils/types").DeprecatedConfig;
310
308
  }], import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
311
309
  'no-deprecated-design-token-usage': import("eslint").Rule.RuleModule;
312
- 'no-deprecated-imports': import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<string, [{
313
- deprecatedConfig: import("./rules/utils/types").DeprecatedConfig;
314
- }], import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
310
+ 'no-deprecated-imports': import("eslint").Rule.RuleModule;
315
311
  'no-direct-use-of-web-platform-drag-and-drop': import("eslint").Rule.RuleModule;
316
312
  'no-empty-styled-expression': import("eslint").Rule.RuleModule;
317
313
  'no-exported-css': import("eslint").Rule.RuleModule;
@@ -456,9 +452,7 @@ export declare const configs: {
456
452
  deprecatedConfig: import("./rules/utils/types").DeprecatedConfig;
457
453
  }], import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
458
454
  'no-deprecated-design-token-usage': import("eslint").Rule.RuleModule;
459
- 'no-deprecated-imports': import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<string, [{
460
- deprecatedConfig: import("./rules/utils/types").DeprecatedConfig;
461
- }], import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
455
+ 'no-deprecated-imports': import("eslint").Rule.RuleModule;
462
456
  'no-direct-use-of-web-platform-drag-and-drop': import("eslint").Rule.RuleModule;
463
457
  'no-empty-styled-expression': import("eslint").Rule.RuleModule;
464
458
  'no-exported-css': import("eslint").Rule.RuleModule;
@@ -12,9 +12,7 @@ export declare const rules: {
12
12
  deprecatedConfig: import("./utils/types").DeprecatedConfig;
13
13
  }], import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
14
14
  'no-deprecated-design-token-usage': import("eslint").Rule.RuleModule;
15
- 'no-deprecated-imports': import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<string, [{
16
- deprecatedConfig: import("./utils/types").DeprecatedConfig;
17
- }], import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
15
+ 'no-deprecated-imports': import("eslint").Rule.RuleModule;
18
16
  'no-direct-use-of-web-platform-drag-and-drop': import("eslint").Rule.RuleModule;
19
17
  'no-empty-styled-expression': import("eslint").Rule.RuleModule;
20
18
  'no-exported-css': import("eslint").Rule.RuleModule;
@@ -0,0 +1,11 @@
1
+ import type { Rule } from 'eslint';
2
+ import { type ExportNamedDeclaration, type ImportDeclaration } from 'eslint-codemod-utils';
3
+ type ReturnObject = {
4
+ checkImportNode: (node: ImportDeclaration & Rule.NodeParentExtension) => void;
5
+ checkExportNode: (node: ExportNamedDeclaration & Rule.NodeParentExtension) => void;
6
+ checkJSXElement: (node: Rule.Node) => void;
7
+ checkIdentifier: (node: Rule.Node) => void;
8
+ throwErrors: () => void;
9
+ };
10
+ export declare const createChecks: (context: Rule.RuleContext) => ReturnObject;
11
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare const importNameWithCustomMessageId = "importNameWithCustomMessage";
2
+ export declare const pathWithCustomMessageId = "pathWithCustomMessage";
@@ -0,0 +1,38 @@
1
+ import type { Rule } from 'eslint';
2
+ import { type ExportNamedDeclaration, type ImportDeclaration, type JSXElement } from 'eslint-codemod-utils';
3
+ import { type DeprecatedImportConfigEntry } from '../../utils/types';
4
+ export type ImportIconDeprecationError = Rule.ReportDescriptor & {
5
+ node: ImportDeclaration;
6
+ };
7
+ export type ExportIconDeprecationError = Rule.ReportDescriptor & {
8
+ node: ExportNamedDeclaration;
9
+ };
10
+ export type ImportIconDeprecationErrorListAuto = {
11
+ [key: string]: ImportIconDeprecationError;
12
+ };
13
+ export type ExportIconDeprecationErrorListAuto = {
14
+ [key: string]: ExportIconDeprecationError;
15
+ };
16
+ type DeprecationIconHandler = (context: Rule.RuleContext) => {
17
+ createImportError: (args: {
18
+ node: ImportDeclaration;
19
+ importSource: string;
20
+ config: DeprecatedImportConfigEntry;
21
+ }) => void;
22
+ createExportError: (args: {
23
+ node: ExportNamedDeclaration;
24
+ importSource: string;
25
+ config: DeprecatedImportConfigEntry;
26
+ }) => void;
27
+ checkJSXElement: (node: JSXElement) => void;
28
+ checkIdentifier: (node: Rule.Node) => void;
29
+ throwErrors: () => void;
30
+ };
31
+ /**
32
+ * __Deprecation icon handler__
33
+ *
34
+ * A deprecation icon handler which is responsible for displaying an error for deprecated icons.
35
+ * It also includes a fixer to replace the deprecated icon with the new icon if a replacement exists.
36
+ */
37
+ export declare const getDeprecationIconHandler: DeprecationIconHandler;
38
+ export {};
@@ -24,12 +24,6 @@
24
24
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
25
  * THE SOFTWARE.
26
26
  */
27
- import { type TSESLint } from '@typescript-eslint/utils';
28
- import { type DeprecatedConfig } from '../utils/types';
29
27
  export declare const name = "no-deprecated-imports";
30
- export declare const importNameWithCustomMessageId = "importNameWithCustomMessage";
31
- export declare const pathWithCustomMessageId = "pathWithCustomMessage";
32
- declare const rule: TSESLint.RuleModule<string, [{
33
- deprecatedConfig: DeprecatedConfig;
34
- }], TSESLint.RuleListener>;
28
+ declare const rule: import("eslint").Rule.RuleModule;
35
29
  export default rule;
@@ -17,6 +17,7 @@ export type DeprecatedImportConfigEntry = {
17
17
  importName: string;
18
18
  message: string;
19
19
  }[];
20
+ unfixable?: boolean;
20
21
  };
21
22
  export declare const isDeprecatedImportConfig: (config: DeprecatedImportConfig | DeprecatedJSXAttributeConfig) => config is DeprecatedImportConfig;
22
23
  export declare const isDeprecatedJSXAttributeConfig: (config: DeprecatedImportConfig | DeprecatedJSXAttributeConfig) => config is DeprecatedJSXAttributeConfig;
@@ -19,11 +19,7 @@ export declare const plugin: {
19
19
  }
20
20
  ], import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
21
21
  'no-deprecated-design-token-usage': import("eslint").Rule.RuleModule;
22
- 'no-deprecated-imports': import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<string, [
23
- {
24
- deprecatedConfig: import("./rules/utils/types").DeprecatedConfig;
25
- }
26
- ], import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
22
+ 'no-deprecated-imports': import("eslint").Rule.RuleModule;
27
23
  'no-direct-use-of-web-platform-drag-and-drop': import("eslint").Rule.RuleModule;
28
24
  'no-empty-styled-expression': import("eslint").Rule.RuleModule;
29
25
  'no-exported-css': import("eslint").Rule.RuleModule;
@@ -361,11 +357,7 @@ export declare const configs: {
361
357
  }
362
358
  ], import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
363
359
  'no-deprecated-design-token-usage': import("eslint").Rule.RuleModule;
364
- 'no-deprecated-imports': import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<string, [
365
- {
366
- deprecatedConfig: import("./rules/utils/types").DeprecatedConfig;
367
- }
368
- ], import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
360
+ 'no-deprecated-imports': import("eslint").Rule.RuleModule;
369
361
  'no-direct-use-of-web-platform-drag-and-drop': import("eslint").Rule.RuleModule;
370
362
  'no-empty-styled-expression': import("eslint").Rule.RuleModule;
371
363
  'no-exported-css': import("eslint").Rule.RuleModule;
@@ -530,11 +522,7 @@ export declare const configs: {
530
522
  }
531
523
  ], import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
532
524
  'no-deprecated-design-token-usage': import("eslint").Rule.RuleModule;
533
- 'no-deprecated-imports': import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<string, [
534
- {
535
- deprecatedConfig: import("./rules/utils/types").DeprecatedConfig;
536
- }
537
- ], import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
525
+ 'no-deprecated-imports': import("eslint").Rule.RuleModule;
538
526
  'no-direct-use-of-web-platform-drag-and-drop': import("eslint").Rule.RuleModule;
539
527
  'no-empty-styled-expression': import("eslint").Rule.RuleModule;
540
528
  'no-exported-css': import("eslint").Rule.RuleModule;
@@ -14,11 +14,7 @@ export declare const rules: {
14
14
  }
15
15
  ], import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
16
16
  'no-deprecated-design-token-usage': import("eslint").Rule.RuleModule;
17
- 'no-deprecated-imports': import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<string, [
18
- {
19
- deprecatedConfig: import("./utils/types").DeprecatedConfig;
20
- }
21
- ], import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
17
+ 'no-deprecated-imports': import("eslint").Rule.RuleModule;
22
18
  'no-direct-use-of-web-platform-drag-and-drop': import("eslint").Rule.RuleModule;
23
19
  'no-empty-styled-expression': import("eslint").Rule.RuleModule;
24
20
  'no-exported-css': import("eslint").Rule.RuleModule;
@@ -0,0 +1,11 @@
1
+ import type { Rule } from 'eslint';
2
+ import { type ExportNamedDeclaration, type ImportDeclaration } from 'eslint-codemod-utils';
3
+ type ReturnObject = {
4
+ checkImportNode: (node: ImportDeclaration & Rule.NodeParentExtension) => void;
5
+ checkExportNode: (node: ExportNamedDeclaration & Rule.NodeParentExtension) => void;
6
+ checkJSXElement: (node: Rule.Node) => void;
7
+ checkIdentifier: (node: Rule.Node) => void;
8
+ throwErrors: () => void;
9
+ };
10
+ export declare const createChecks: (context: Rule.RuleContext) => ReturnObject;
11
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare const importNameWithCustomMessageId = "importNameWithCustomMessage";
2
+ export declare const pathWithCustomMessageId = "pathWithCustomMessage";
@@ -0,0 +1,38 @@
1
+ import type { Rule } from 'eslint';
2
+ import { type ExportNamedDeclaration, type ImportDeclaration, type JSXElement } from 'eslint-codemod-utils';
3
+ import { type DeprecatedImportConfigEntry } from '../../utils/types';
4
+ export type ImportIconDeprecationError = Rule.ReportDescriptor & {
5
+ node: ImportDeclaration;
6
+ };
7
+ export type ExportIconDeprecationError = Rule.ReportDescriptor & {
8
+ node: ExportNamedDeclaration;
9
+ };
10
+ export type ImportIconDeprecationErrorListAuto = {
11
+ [key: string]: ImportIconDeprecationError;
12
+ };
13
+ export type ExportIconDeprecationErrorListAuto = {
14
+ [key: string]: ExportIconDeprecationError;
15
+ };
16
+ type DeprecationIconHandler = (context: Rule.RuleContext) => {
17
+ createImportError: (args: {
18
+ node: ImportDeclaration;
19
+ importSource: string;
20
+ config: DeprecatedImportConfigEntry;
21
+ }) => void;
22
+ createExportError: (args: {
23
+ node: ExportNamedDeclaration;
24
+ importSource: string;
25
+ config: DeprecatedImportConfigEntry;
26
+ }) => void;
27
+ checkJSXElement: (node: JSXElement) => void;
28
+ checkIdentifier: (node: Rule.Node) => void;
29
+ throwErrors: () => void;
30
+ };
31
+ /**
32
+ * __Deprecation icon handler__
33
+ *
34
+ * A deprecation icon handler which is responsible for displaying an error for deprecated icons.
35
+ * It also includes a fixer to replace the deprecated icon with the new icon if a replacement exists.
36
+ */
37
+ export declare const getDeprecationIconHandler: DeprecationIconHandler;
38
+ export {};
@@ -24,14 +24,6 @@
24
24
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
25
  * THE SOFTWARE.
26
26
  */
27
- import { type TSESLint } from '@typescript-eslint/utils';
28
- import { type DeprecatedConfig } from '../utils/types';
29
27
  export declare const name = "no-deprecated-imports";
30
- export declare const importNameWithCustomMessageId = "importNameWithCustomMessage";
31
- export declare const pathWithCustomMessageId = "pathWithCustomMessage";
32
- declare const rule: TSESLint.RuleModule<string, [
33
- {
34
- deprecatedConfig: DeprecatedConfig;
35
- }
36
- ], TSESLint.RuleListener>;
28
+ declare const rule: import("eslint").Rule.RuleModule;
37
29
  export default rule;
@@ -17,6 +17,7 @@ export type DeprecatedImportConfigEntry = {
17
17
  importName: string;
18
18
  message: string;
19
19
  }[];
20
+ unfixable?: boolean;
20
21
  };
21
22
  export declare const isDeprecatedImportConfig: (config: DeprecatedImportConfig | DeprecatedJSXAttributeConfig) => config is DeprecatedImportConfig;
22
23
  export declare const isDeprecatedJSXAttributeConfig: (config: DeprecatedImportConfig | DeprecatedJSXAttributeConfig) => config is DeprecatedJSXAttributeConfig;