@atlaskit/eslint-plugin-design-system 10.9.0 → 10.10.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 (53) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +1 -0
  3. package/constellation/index/usage.mdx +1 -0
  4. package/constellation/no-custom-icons/usage.mdx +36 -0
  5. package/dist/cjs/presets/all.codegen.js +2 -1
  6. package/dist/cjs/rules/ensure-design-token-usage/index.js +199 -227
  7. package/dist/cjs/rules/index.codegen.js +3 -1
  8. package/dist/cjs/rules/no-custom-icons/checks/has-prop.js +12 -0
  9. package/dist/cjs/rules/no-custom-icons/checks/is-from-import-source.js +42 -0
  10. package/dist/cjs/rules/no-custom-icons/checks/is-imported-jsx-element.js +10 -0
  11. package/dist/cjs/rules/no-custom-icons/index.js +67 -0
  12. package/dist/cjs/rules/no-legacy-icons/index.js +11 -83
  13. package/dist/cjs/rules/use-tokens-typography/index.js +4 -8
  14. package/dist/cjs/rules/utils/error-boundary.js +58 -11
  15. package/dist/es2019/presets/all.codegen.js +2 -1
  16. package/dist/es2019/rules/ensure-design-token-usage/index.js +16 -30
  17. package/dist/es2019/rules/index.codegen.js +3 -1
  18. package/dist/es2019/rules/no-custom-icons/checks/has-prop.js +4 -0
  19. package/dist/es2019/rules/no-custom-icons/checks/is-from-import-source.js +23 -0
  20. package/dist/es2019/rules/no-custom-icons/checks/is-imported-jsx-element.js +4 -0
  21. package/dist/es2019/rules/no-custom-icons/index.js +61 -0
  22. package/dist/es2019/rules/no-legacy-icons/index.js +11 -65
  23. package/dist/es2019/rules/use-tokens-typography/index.js +3 -7
  24. package/dist/es2019/rules/utils/error-boundary.js +55 -11
  25. package/dist/esm/presets/all.codegen.js +2 -1
  26. package/dist/esm/rules/ensure-design-token-usage/index.js +199 -227
  27. package/dist/esm/rules/index.codegen.js +3 -1
  28. package/dist/esm/rules/no-custom-icons/checks/has-prop.js +6 -0
  29. package/dist/esm/rules/no-custom-icons/checks/is-from-import-source.js +36 -0
  30. package/dist/esm/rules/no-custom-icons/checks/is-imported-jsx-element.js +4 -0
  31. package/dist/esm/rules/no-custom-icons/index.js +61 -0
  32. package/dist/esm/rules/no-legacy-icons/index.js +11 -83
  33. package/dist/esm/rules/use-tokens-typography/index.js +4 -8
  34. package/dist/esm/rules/utils/error-boundary.js +56 -10
  35. package/dist/types/index.codegen.d.ts +1 -0
  36. package/dist/types/presets/all.codegen.d.ts +2 -1
  37. package/dist/types/rules/index.codegen.d.ts +1 -0
  38. package/dist/types/rules/no-custom-icons/checks/has-prop.d.ts +2 -0
  39. package/dist/types/rules/no-custom-icons/checks/is-from-import-source.d.ts +8 -0
  40. package/dist/types/rules/no-custom-icons/checks/is-imported-jsx-element.d.ts +8 -0
  41. package/dist/types/rules/no-custom-icons/index.d.ts +3 -0
  42. package/dist/types/rules/no-legacy-icons/index.d.ts +1 -2
  43. package/dist/types/rules/utils/error-boundary.d.ts +8 -5
  44. package/dist/types-ts4.5/index.codegen.d.ts +1 -0
  45. package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -1
  46. package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
  47. package/dist/types-ts4.5/rules/no-custom-icons/checks/has-prop.d.ts +2 -0
  48. package/dist/types-ts4.5/rules/no-custom-icons/checks/is-from-import-source.d.ts +8 -0
  49. package/dist/types-ts4.5/rules/no-custom-icons/checks/is-imported-jsx-element.d.ts +8 -0
  50. package/dist/types-ts4.5/rules/no-custom-icons/index.d.ts +3 -0
  51. package/dist/types-ts4.5/rules/no-legacy-icons/index.d.ts +1 -2
  52. package/dist/types-ts4.5/rules/utils/error-boundary.d.ts +8 -5
  53. package/package.json +1 -1
@@ -0,0 +1,36 @@
1
+ import { isImportedJSXElement } from './is-imported-jsx-element';
2
+ export function createIsFromImportSourceFor() {
3
+ for (var _len = arguments.length, importSources = new Array(_len), _key = 0; _key < _len; _key++) {
4
+ importSources[_key] = arguments[_key];
5
+ }
6
+ var literalImportSources = importSources.filter(function (s) {
7
+ return typeof s === 'string';
8
+ });
9
+ var matchImportSources = importSources.filter(function (s) {
10
+ return s instanceof RegExp;
11
+ });
12
+ var varImportSourceMap = new Map();
13
+ function isFromImportSource(node) {
14
+ return isImportedJSXElement(node) && varImportSourceMap.has(node.openingElement.name.name);
15
+ }
16
+ isFromImportSource.importDeclarationHook = function (node) {
17
+ var source = node.source.value;
18
+ if (typeof source !== 'string' || !(literalImportSources.includes(source) || matchImportSources.some(function (r) {
19
+ return r.test(source);
20
+ }))) {
21
+ return;
22
+ }
23
+ node.specifiers.filter(function (spec) {
24
+ return ['ImportSpecifier', 'ImportDefaultSpecifier'].includes(spec.type);
25
+ }).forEach(function (spec) {
26
+ return varImportSourceMap.set(spec.local.name, source);
27
+ });
28
+ };
29
+ isFromImportSource.getImportSource = function (node) {
30
+ if (!isFromImportSource(node)) {
31
+ throw new Error('Node is not an imported JSX element');
32
+ }
33
+ return varImportSourceMap.get(node.openingElement.name.name);
34
+ };
35
+ return isFromImportSource;
36
+ }
@@ -0,0 +1,4 @@
1
+ import { isNodeOfType } from 'eslint-codemod-utils';
2
+ export function isImportedJSXElement(node) {
3
+ return isNodeOfType(node, 'JSXElement') && isNodeOfType(node.openingElement.name, 'JSXIdentifier');
4
+ }
@@ -0,0 +1,61 @@
1
+ // eslint-disable-next-line import/no-extraneous-dependencies
2
+
3
+ import { createLintRule } from '../utils/create-rule';
4
+ import { errorBoundary } from '../utils/error-boundary';
5
+ import { hasProp } from './checks/has-prop';
6
+ import { createIsFromImportSourceFor } from './checks/is-from-import-source';
7
+ var rule = createLintRule({
8
+ meta: {
9
+ name: 'no-custom-icons',
10
+ type: 'problem',
11
+ docs: {
12
+ description: 'Enforces custom glyph icons are used.',
13
+ recommended: false,
14
+ severity: 'warn'
15
+ },
16
+ schema: [{
17
+ type: 'object',
18
+ properties: {
19
+ centralLocation: {
20
+ type: 'string'
21
+ },
22
+ failSilently: {
23
+ type: 'boolean'
24
+ }
25
+ },
26
+ additionalProperties: false
27
+ }],
28
+ messages: {
29
+ noCustomIcons: "Custom icons from {{importSource}} are no longer supported. Migrate to an icon from '@atlaskit/(icon-labs|icon/core|icon/utility)'{{locationMessage}}.\n[Migration guide](https://hello.atlassian.net/wiki/spaces/DST/pages/3748692796/New+ADS+iconography+-+Code+migration+guide)."
30
+ }
31
+ },
32
+ create: function create(context) {
33
+ var _context$options$;
34
+ var isIconBase = createIsFromImportSourceFor('@atlaskit/icon', '@atlaskit/icon/base');
35
+ var _ref = (_context$options$ = context.options[0]) !== null && _context$options$ !== void 0 ? _context$options$ : {},
36
+ _ref$centralLocation = _ref.centralLocation,
37
+ centralLocation = _ref$centralLocation === void 0 ? '' : _ref$centralLocation,
38
+ _ref$failSilently = _ref.failSilently,
39
+ failSilently = _ref$failSilently === void 0 ? false : _ref$failSilently;
40
+ var locationMessage = centralLocation ? " or move the icon to '".concat(centralLocation, "'") : '';
41
+ return errorBoundary({
42
+ JSXElement: function JSXElement(node) {
43
+ var _isIconBase$getImport;
44
+ if (!isIconBase(node) || !hasProp(node, 'glyph')) {
45
+ return;
46
+ }
47
+ var importSource = (_isIconBase$getImport = isIconBase.getImportSource(node)) !== null && _isIconBase$getImport !== void 0 ? _isIconBase$getImport : '';
48
+ context.report({
49
+ node: node.openingElement,
50
+ messageId: 'noCustomIcons',
51
+ data: {
52
+ importSource: importSource,
53
+ locationMessage: locationMessage
54
+ }
55
+ });
56
+ },
57
+ ImportDeclaration: isIconBase.importDeclarationHook
58
+ }, failSilently);
59
+ }
60
+ });
61
+ export default rule;
@@ -54,95 +54,23 @@ var rule = createLintRule({
54
54
  checkJSXElement = _createChecks.checkJSXElement,
55
55
  checkCallExpression = _createChecks.checkCallExpression,
56
56
  throwErrors = _createChecks.throwErrors;
57
- return {
57
+ return errorBoundary({
58
58
  // Track imports of relevant components
59
- ImportDeclaration: function ImportDeclaration(node) {
60
- errorBoundary(function () {
61
- return checkImportDeclarations(node);
62
- }, {
63
- config: {
64
- failSilently: failSilently
65
- }
66
- });
67
- },
59
+ ImportDeclaration: checkImportDeclarations,
68
60
  // Keep track of the relevant variable declarations and renames
69
- VariableDeclaration: function VariableDeclaration(node) {
70
- errorBoundary(function () {
71
- return checkVariableDeclarations(node);
72
- }, {
73
- config: {
74
- failSilently: failSilently
75
- }
76
- });
77
- },
61
+ VariableDeclaration: checkVariableDeclarations,
78
62
  // Case: default re-exports. Can't be auto-migrated
79
- ExportDefaultDeclaration: function ExportDefaultDeclaration(node) {
80
- errorBoundary(function () {
81
- return checkExportDefaultDeclaration(node);
82
- }, {
83
- config: {
84
- failSilently: failSilently
85
- }
86
- });
87
- },
88
- ExportNamedDeclaration: function ExportNamedDeclaration(node) {
89
- errorBoundary(function () {
90
- return checkExportNamedVariables(node);
91
- }, {
92
- config: {
93
- failSilently: failSilently
94
- }
95
- });
96
- },
63
+ ExportDefaultDeclaration: checkExportDefaultDeclaration,
64
+ ExportNamedDeclaration: checkExportNamedVariables,
97
65
  // Legacy icons found in arrays/objects
98
- 'ObjectExpression > Property > Identifier, ArrayExpression > Identifier ': function ObjectExpressionPropertyIdentifierArrayExpressionIdentifier(node) {
99
- errorBoundary(function () {
100
- return checkArrayOrMap(node);
101
- }, {
102
- config: {
103
- failSilently: failSilently
104
- }
105
- });
106
- },
66
+ 'ObjectExpression > Property > Identifier, ArrayExpression > Identifier ': checkArrayOrMap,
107
67
  // Legacy icons passed in via props, as JSX identifier (i.e. icon={AddIcon})
108
- 'JSXOpeningElement > JSXAttribute > JSXExpressionContainer > Identifier': function JSXOpeningElementJSXAttributeJSXExpressionContainerIdentifier(node) {
109
- errorBoundary(function () {
110
- return checkIconAsProp(node);
111
- }, {
112
- config: {
113
- failSilently: failSilently
114
- }
115
- });
116
- },
117
- JSXElement: function JSXElement(node) {
118
- errorBoundary(function () {
119
- return checkJSXElement(node);
120
- }, {
121
- config: {
122
- failSilently: failSilently
123
- }
124
- });
125
- },
68
+ 'JSXOpeningElement > JSXAttribute > JSXExpressionContainer > Identifier': checkIconAsProp,
69
+ JSXElement: checkJSXElement,
126
70
  // Icons called as an argument of a function (i.e. icon={DefaultIcon(AddIcon)})
127
- CallExpression: function CallExpression(node) {
128
- errorBoundary(function () {
129
- return checkCallExpression(node);
130
- }, {
131
- config: {
132
- failSilently: failSilently
133
- }
134
- });
135
- },
136
- 'Program:exit': function ProgramExit() {
137
- errorBoundary(function () {
138
- return throwErrors();
139
- }, {
140
- config: {
141
- failSilently: failSilently
142
- }
143
- });
144
- }
145
- };
71
+ CallExpression: checkCallExpression,
72
+ 'Program:exit': throwErrors
73
+ }, failSilently);
146
74
  }
147
75
  });
148
76
  export default rule;
@@ -6,16 +6,12 @@ var create = function create(context) {
6
6
  var config = getConfig(context.options[0]);
7
7
  return {
8
8
  // const styles = css({ fontSize: '14px, ... }), styled.div({ fontSize: 14, ... })
9
- ObjectExpression: function ObjectExpression(node) {
10
- return errorBoundary(function () {
11
- return StyleObject.lint(node, {
12
- context: context,
13
- config: config
14
- });
15
- }, {
9
+ ObjectExpression: errorBoundary(function (node) {
10
+ return StyleObject.lint(node, {
11
+ context: context,
16
12
  config: config
17
13
  });
18
- }
14
+ }, config)
19
15
  };
20
16
  };
21
17
  var rule = createLintRule({
@@ -1,3 +1,11 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _typeof from "@babel/runtime/helpers/typeof";
3
+ // eslint-disable-next-line import/no-extraneous-dependencies
4
+
5
+ // Need to intersect type RuleListener with a generic function to allow use of Parameters<...> to be used
6
+
7
+ // Allow config to be to be easily passed from rules
8
+
1
9
  /**
2
10
  * ESLint rules should NEVER throw exceptions, because that breaks the VSCode ESLint server
3
11
  * (and probably the IntelliJ one too), which causes linting to fail in a file.
@@ -5,14 +13,52 @@
5
13
  * It also breaks CI, which was the reason this error boundary was added. It's a final
6
14
  * catch all.
7
15
  */
8
- export var errorBoundary = function errorBoundary(func, _ref) {
9
- var config = _ref.config;
10
- try {
11
- func();
12
- } catch (err) {
13
- if (!config.failSilently) {
14
- // eslint-disable-next-line no-console
15
- console.warn(err);
16
- }
16
+ export function errorBoundary(ruleOrRules) {
17
+ var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
18
+ var failSilently = failSilentlyFromConfig(config);
19
+ if (isSingleRuleListener(ruleOrRules)) {
20
+ return wrapSingleRuleListener(ruleOrRules, failSilently);
21
+ }
22
+ return wrapRuleListener(ruleOrRules, failSilently);
23
+ }
24
+ function isSingleRuleListener(rule) {
25
+ return typeof rule === 'function';
26
+ }
27
+ function failSilentlyFromConfig(c) {
28
+ switch (_typeof(c)) {
29
+ case 'undefined':
30
+ return false;
31
+ case 'boolean':
32
+ return c;
33
+ case 'object':
34
+ if ('failSilently' in c) {
35
+ var _c$failSilently;
36
+ return (_c$failSilently = c.failSilently) !== null && _c$failSilently !== void 0 ? _c$failSilently : false;
37
+ } else if ('config' in c) {
38
+ var _c$config$failSilentl;
39
+ return (_c$config$failSilentl = c.config.failSilently) !== null && _c$config$failSilentl !== void 0 ? _c$config$failSilentl : false;
40
+ }
41
+ return false;
42
+ default:
43
+ throw new Error('Invalid config');
17
44
  }
18
- };
45
+ }
46
+ function wrapSingleRuleListener(rule, failSilently) {
47
+ return function () {
48
+ try {
49
+ rule.apply(void 0, arguments);
50
+ } catch (err) {
51
+ if (!failSilently) {
52
+ // eslint-disable-next-line no-console
53
+ console.warn(err);
54
+ }
55
+ }
56
+ };
57
+ }
58
+ function wrapRuleListener(ruleListener, failSilently) {
59
+ return Object.entries(ruleListener).reduce(function (wrappedRuleListener, e) {
60
+ var ruleName = e[0];
61
+ var rule = e[1];
62
+ return Object.assign(wrappedRuleListener, _defineProperty({}, ruleName, wrapSingleRuleListener(rule, failSilently)));
63
+ }, {});
64
+ }
@@ -9,6 +9,7 @@ export declare const configs: {
9
9
  '@atlaskit/design-system/icon-label': string;
10
10
  '@atlaskit/design-system/no-banned-imports': string;
11
11
  '@atlaskit/design-system/no-css-tagged-template-expression': string;
12
+ '@atlaskit/design-system/no-custom-icons': string;
12
13
  '@atlaskit/design-system/no-deprecated-apis': string;
13
14
  '@atlaskit/design-system/no-deprecated-design-token-usage': string;
14
15
  '@atlaskit/design-system/no-deprecated-imports': string;
@@ -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::9bb5329713677543f16019954484ae2f>>
3
+ * @codegen <<SignedSource::ab43b6e1a867d07b9a27eae78d48834a>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  declare const _default: {
@@ -12,6 +12,7 @@ declare const _default: {
12
12
  '@atlaskit/design-system/icon-label': string;
13
13
  '@atlaskit/design-system/no-banned-imports': string;
14
14
  '@atlaskit/design-system/no-css-tagged-template-expression': string;
15
+ '@atlaskit/design-system/no-custom-icons': string;
15
16
  '@atlaskit/design-system/no-deprecated-apis': string;
16
17
  '@atlaskit/design-system/no-deprecated-design-token-usage': string;
17
18
  '@atlaskit/design-system/no-deprecated-imports': string;
@@ -5,6 +5,7 @@ declare const _default: {
5
5
  'icon-label': import("eslint").Rule.RuleModule;
6
6
  'no-banned-imports': import("eslint").Rule.RuleModule;
7
7
  'no-css-tagged-template-expression': import("eslint").Rule.RuleModule;
8
+ 'no-custom-icons': import("eslint").Rule.RuleModule;
8
9
  'no-deprecated-apis': import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<string, [{
9
10
  deprecatedConfig: import("./utils/types").DeprecatedConfig;
10
11
  }], import("@typescript-eslint/utils/dist/ts-eslint").RuleListener>;
@@ -0,0 +1,2 @@
1
+ import { type JSXElement } from 'eslint-codemod-utils';
2
+ export declare function hasProp(node: JSXElement, propName: string): boolean;
@@ -0,0 +1,8 @@
1
+ import type { Rule } from 'eslint';
2
+ import type { ImportDeclaration } from 'eslint-codemod-utils';
3
+ import { type ImportedJSXElement } from './is-imported-jsx-element';
4
+ export declare function createIsFromImportSourceFor(...importSources: (string | RegExp)[]): {
5
+ (node: Rule.Node): node is ImportedJSXElement;
6
+ importDeclarationHook(node: ImportDeclaration): void;
7
+ getImportSource(node: Rule.Node): string;
8
+ };
@@ -0,0 +1,8 @@
1
+ import type { Rule } from 'eslint';
2
+ import { type JSXElement, type JSXIdentifier, type JSXOpeningElement } from 'eslint-codemod-utils';
3
+ export type ImportedJSXElement = JSXElement & Rule.NodeParentExtension & {
4
+ openingElement: JSXOpeningElement & {
5
+ name: JSXIdentifier;
6
+ };
7
+ };
8
+ export declare function isImportedJSXElement(node: Rule.Node): node is ImportedJSXElement;
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ declare const rule: Rule.RuleModule;
3
+ export default rule;
@@ -1,3 +1,2 @@
1
- import type { Rule } from 'eslint';
2
- declare const rule: Rule.RuleModule;
1
+ declare const rule: import("eslint").Rule.RuleModule;
3
2
  export default rule;
@@ -1,6 +1,11 @@
1
- type RuleConfig = {
1
+ import type { Rule } from 'eslint';
2
+ type SingleRuleListener = Rule.RuleListener[keyof Rule.RuleListener] & ((...args: any[]) => void);
3
+ type ErrorBoundaryConfig = undefined | boolean | {
2
4
  failSilently?: boolean;
3
- shouldEnforceFallbacks?: boolean;
5
+ } | {
6
+ config: {
7
+ failSilently?: boolean;
8
+ };
4
9
  };
5
10
  /**
6
11
  * ESLint rules should NEVER throw exceptions, because that breaks the VSCode ESLint server
@@ -9,7 +14,5 @@ type RuleConfig = {
9
14
  * It also breaks CI, which was the reason this error boundary was added. It's a final
10
15
  * catch all.
11
16
  */
12
- export declare const errorBoundary: (func: () => void, { config }: {
13
- config: RuleConfig;
14
- }) => void;
17
+ export declare function errorBoundary<R extends SingleRuleListener | Rule.RuleListener>(ruleOrRules: R, config?: ErrorBoundaryConfig): R;
15
18
  export {};
@@ -9,6 +9,7 @@ export declare const configs: {
9
9
  '@atlaskit/design-system/icon-label': string;
10
10
  '@atlaskit/design-system/no-banned-imports': string;
11
11
  '@atlaskit/design-system/no-css-tagged-template-expression': string;
12
+ '@atlaskit/design-system/no-custom-icons': string;
12
13
  '@atlaskit/design-system/no-deprecated-apis': string;
13
14
  '@atlaskit/design-system/no-deprecated-design-token-usage': string;
14
15
  '@atlaskit/design-system/no-deprecated-imports': string;
@@ -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::9bb5329713677543f16019954484ae2f>>
3
+ * @codegen <<SignedSource::ab43b6e1a867d07b9a27eae78d48834a>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  declare const _default: {
@@ -12,6 +12,7 @@ declare const _default: {
12
12
  '@atlaskit/design-system/icon-label': string;
13
13
  '@atlaskit/design-system/no-banned-imports': string;
14
14
  '@atlaskit/design-system/no-css-tagged-template-expression': string;
15
+ '@atlaskit/design-system/no-custom-icons': string;
15
16
  '@atlaskit/design-system/no-deprecated-apis': string;
16
17
  '@atlaskit/design-system/no-deprecated-design-token-usage': string;
17
18
  '@atlaskit/design-system/no-deprecated-imports': string;
@@ -5,6 +5,7 @@ declare const _default: {
5
5
  'icon-label': import("eslint").Rule.RuleModule;
6
6
  'no-banned-imports': import("eslint").Rule.RuleModule;
7
7
  'no-css-tagged-template-expression': import("eslint").Rule.RuleModule;
8
+ 'no-custom-icons': import("eslint").Rule.RuleModule;
8
9
  'no-deprecated-apis': import("@typescript-eslint/utils/dist/ts-eslint").RuleModule<string, [
9
10
  {
10
11
  deprecatedConfig: import("./utils/types").DeprecatedConfig;
@@ -0,0 +1,2 @@
1
+ import { type JSXElement } from 'eslint-codemod-utils';
2
+ export declare function hasProp(node: JSXElement, propName: string): boolean;
@@ -0,0 +1,8 @@
1
+ import type { Rule } from 'eslint';
2
+ import type { ImportDeclaration } from 'eslint-codemod-utils';
3
+ import { type ImportedJSXElement } from './is-imported-jsx-element';
4
+ export declare function createIsFromImportSourceFor(...importSources: (string | RegExp)[]): {
5
+ (node: Rule.Node): node is ImportedJSXElement;
6
+ importDeclarationHook(node: ImportDeclaration): void;
7
+ getImportSource(node: Rule.Node): string;
8
+ };
@@ -0,0 +1,8 @@
1
+ import type { Rule } from 'eslint';
2
+ import { type JSXElement, type JSXIdentifier, type JSXOpeningElement } from 'eslint-codemod-utils';
3
+ export type ImportedJSXElement = JSXElement & Rule.NodeParentExtension & {
4
+ openingElement: JSXOpeningElement & {
5
+ name: JSXIdentifier;
6
+ };
7
+ };
8
+ export declare function isImportedJSXElement(node: Rule.Node): node is ImportedJSXElement;
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ declare const rule: Rule.RuleModule;
3
+ export default rule;
@@ -1,3 +1,2 @@
1
- import type { Rule } from 'eslint';
2
- declare const rule: Rule.RuleModule;
1
+ declare const rule: import("eslint").Rule.RuleModule;
3
2
  export default rule;
@@ -1,6 +1,11 @@
1
- type RuleConfig = {
1
+ import type { Rule } from 'eslint';
2
+ type SingleRuleListener = Rule.RuleListener[keyof Rule.RuleListener] & ((...args: any[]) => void);
3
+ type ErrorBoundaryConfig = undefined | boolean | {
2
4
  failSilently?: boolean;
3
- shouldEnforceFallbacks?: boolean;
5
+ } | {
6
+ config: {
7
+ failSilently?: boolean;
8
+ };
4
9
  };
5
10
  /**
6
11
  * ESLint rules should NEVER throw exceptions, because that breaks the VSCode ESLint server
@@ -9,7 +14,5 @@ type RuleConfig = {
9
14
  * It also breaks CI, which was the reason this error boundary was added. It's a final
10
15
  * catch all.
11
16
  */
12
- export declare const errorBoundary: (func: () => void, { config }: {
13
- config: RuleConfig;
14
- }) => void;
17
+ export declare function errorBoundary<R extends SingleRuleListener | Rule.RuleListener>(ruleOrRules: R, config?: ErrorBoundaryConfig): R;
15
18
  export {};
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": "10.9.0",
4
+ "version": "10.10.0",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
7
7
  "publishConfig": {