@atlaskit/eslint-plugin-design-system 10.8.1 → 10.9.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 (44) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/constellation/consistent-css-prop-usage/usage.mdx +9 -0
  3. package/dist/cjs/rules/consistent-css-prop-usage/index.js +19 -2
  4. package/dist/cjs/rules/ensure-design-token-usage/index.js +1 -1
  5. package/dist/cjs/rules/no-legacy-icons/checks.js +484 -0
  6. package/dist/cjs/rules/no-legacy-icons/helpers.js +289 -0
  7. package/dist/cjs/rules/no-legacy-icons/index.js +111 -131
  8. package/dist/cjs/rules/no-legacy-icons/migration-map-temp.js +4090 -0
  9. package/dist/cjs/rules/use-tokens-typography/index.js +1 -1
  10. package/dist/es2019/rules/consistent-css-prop-usage/index.js +19 -2
  11. package/dist/es2019/rules/ensure-design-token-usage/index.js +1 -1
  12. package/dist/es2019/rules/no-legacy-icons/checks.js +388 -0
  13. package/dist/es2019/rules/no-legacy-icons/helpers.js +275 -0
  14. package/dist/es2019/rules/no-legacy-icons/index.js +96 -97
  15. package/dist/es2019/rules/no-legacy-icons/migration-map-temp.js +4082 -0
  16. package/dist/es2019/rules/use-tokens-typography/index.js +1 -1
  17. package/dist/esm/rules/consistent-css-prop-usage/index.js +19 -2
  18. package/dist/esm/rules/ensure-design-token-usage/index.js +1 -1
  19. package/dist/esm/rules/no-legacy-icons/checks.js +477 -0
  20. package/dist/esm/rules/no-legacy-icons/helpers.js +279 -0
  21. package/dist/esm/rules/no-legacy-icons/index.js +111 -131
  22. package/dist/esm/rules/no-legacy-icons/migration-map-temp.js +4084 -0
  23. package/dist/esm/rules/use-tokens-typography/index.js +1 -1
  24. package/dist/types/rules/consistent-css-prop-usage/types.d.ts +1 -0
  25. package/dist/types/rules/no-legacy-icons/checks.d.ts +13 -0
  26. package/dist/types/rules/no-legacy-icons/helpers.d.ts +82 -0
  27. package/dist/types/rules/no-legacy-icons/index.d.ts +2 -1
  28. package/dist/types/rules/no-legacy-icons/migration-map-temp.d.ts +22 -0
  29. package/dist/{types-ts4.5/rules/use-tokens-typography → types/rules/utils}/error-boundary.d.ts +5 -1
  30. package/dist/types-ts4.5/rules/consistent-css-prop-usage/types.d.ts +1 -0
  31. package/dist/types-ts4.5/rules/no-legacy-icons/checks.d.ts +13 -0
  32. package/dist/types-ts4.5/rules/no-legacy-icons/helpers.d.ts +82 -0
  33. package/dist/types-ts4.5/rules/no-legacy-icons/index.d.ts +2 -1
  34. package/dist/types-ts4.5/rules/no-legacy-icons/migration-map-temp.d.ts +27 -0
  35. package/dist/types-ts4.5/rules/{ensure-design-token-usage → utils}/error-boundary.d.ts +5 -1
  36. package/package.json +1 -1
  37. package/dist/cjs/rules/use-tokens-typography/error-boundary.js +0 -24
  38. package/dist/es2019/rules/use-tokens-typography/error-boundary.js +0 -19
  39. package/dist/esm/rules/use-tokens-typography/error-boundary.js +0 -18
  40. package/dist/types/rules/ensure-design-token-usage/error-boundary.d.ts +0 -11
  41. package/dist/types/rules/use-tokens-typography/error-boundary.d.ts +0 -11
  42. /package/dist/cjs/rules/{ensure-design-token-usage → utils}/error-boundary.js +0 -0
  43. /package/dist/es2019/rules/{ensure-design-token-usage → utils}/error-boundary.js +0 -0
  44. /package/dist/esm/rules/{ensure-design-token-usage → utils}/error-boundary.js +0 -0
@@ -1,6 +1,6 @@
1
1
  import { createLintRule } from '../utils/create-rule';
2
+ import { errorBoundary } from '../utils/error-boundary';
2
3
  import { getConfig, ruleSchema } from './config';
3
- import { errorBoundary } from './error-boundary';
4
4
  import { StyleObject } from './transformers/style-object';
5
5
  var create = function create(context) {
6
6
  var config = getConfig(context.options[0]);
@@ -6,4 +6,5 @@ export type RuleConfig = {
6
6
  xcssImportSource: ImportSource;
7
7
  excludeReactComponents: boolean;
8
8
  autoFix: boolean;
9
+ shouldAlwaysCheckXcss: boolean;
9
10
  };
@@ -0,0 +1,13 @@
1
+ import type { Rule } from 'eslint';
2
+ import { type CallExpression, type ExportDefaultDeclaration, type ExportNamedDeclaration, type Identifier, type ImportDeclaration, type VariableDeclaration } from 'eslint-codemod-utils';
3
+ export declare const createChecks: (context: Rule.RuleContext) => {
4
+ checkImportDeclarations: (node: ImportDeclaration & Rule.NodeParentExtension) => void;
5
+ checkVariableDeclarations: (node: VariableDeclaration & Rule.NodeParentExtension) => void;
6
+ checkExportDefaultDeclaration: (node: ExportDefaultDeclaration & Rule.NodeParentExtension) => void;
7
+ checkExportNamedVariables: (node: ExportNamedDeclaration & Rule.NodeParentExtension) => void;
8
+ checkArrayOrMap: (node: Identifier) => void;
9
+ checkIconAsProp: (node: Identifier) => void;
10
+ checkJSXElement: (node: Rule.Node) => void;
11
+ checkCallExpression: (node: CallExpression & Rule.NodeParentExtension) => void;
12
+ throwErrors: () => void;
13
+ };
@@ -0,0 +1,82 @@
1
+ import type { Rule } from 'eslint';
2
+ import { type JSXAttribute, type JSXOpeningElement, type Node } from 'eslint-codemod-utils';
3
+ import { type Size } from './migration-map-temp';
4
+ export type iconMigrationError = Rule.ReportDescriptor;
5
+ export type errorsListManual = {
6
+ [loc: string]: {
7
+ errors: iconMigrationError[];
8
+ iconName: string;
9
+ importSource: string;
10
+ };
11
+ };
12
+ export type errorsListAuto = {
13
+ [loc: string]: iconMigrationError;
14
+ };
15
+ export type guidanceList = {
16
+ [loc: string]: string;
17
+ };
18
+ /**
19
+ * Returns the migration map object for a legacy icon or null if not found
20
+ * @param iconPackage The name of the legacy icon package
21
+ * @returns The migration map object for the legacy icon or null if not found
22
+ */
23
+ export declare const getMigrationMapObject: (iconPackage: string) => {
24
+ sizeGuidance: {
25
+ small: string;
26
+ medium: string;
27
+ large: string;
28
+ xlarge: string;
29
+ };
30
+ newIcon?: {
31
+ name: string;
32
+ type: string;
33
+ library: string;
34
+ } | undefined;
35
+ } | null;
36
+ /**
37
+ * Returns the key of a legacy icon
38
+ * @param iconPackage The name of the legacy icon package
39
+ * @returns The unique identifier for the icon (the part after "@atlaskit/icon/glyph")
40
+ */
41
+ export declare const getIconKey: (iconPackage: string) => string;
42
+ /**
43
+ * Checks if a new icon can be auto-migrated based on guidance from the migration map
44
+ */
45
+ export declare const canAutoMigrateNewIconBasedOnSize: (guidance?: string) => boolean;
46
+ /**
47
+ * Creates the written guidance for migrating a legacy icon to a new icon
48
+ */
49
+ export declare const createGuidance: (iconPackage: string, size?: Size) => string;
50
+ /**
51
+ * Checks if the color can be migrated
52
+ * @param color String representing the color to check
53
+ * @returns True if the color can be migrated, false otherwise
54
+ */
55
+ export declare const canMigrateColor: (color: string) => boolean;
56
+ export declare const locToString: (node: Node) => string;
57
+ export declare const createCantMigrateReExportError: (node: Node, packageName: string, exportName: string, errors: errorsListManual) => void;
58
+ export declare const createCantMigrateIdentifierError: (node: Node, packageName: string, exportName: string, errors: errorsListManual) => void;
59
+ export declare const findUNSAFEProp: (iconAttr: JSXAttribute, button: JSXOpeningElement) => {
60
+ UNSAFE_size: "small" | "large" | "xlarge" | null;
61
+ UNSAFE_propName: "UNSAFE_iconAfter_size" | "UNSAFE_iconBefore_size" | "UNSAFE_size" | null;
62
+ };
63
+ export declare const createCantMigrateUnsafeProp: (node: Node, propName: string, value: string, packageName: string, iconName: string, errors: errorsListManual) => void;
64
+ export declare const createCantFindSuitableReplacementError: (node: Node, importSource: string, iconName: string, errors: errorsListManual) => void;
65
+ export declare const createCantMigrateFunctionUnknownError: (node: Node, importSource: string, iconName: string, errors: errorsListManual) => void;
66
+ export declare const createCantMigrateColorError: (node: Node, colorValue: string, errors: errorsListManual, importSource: string, iconName: string) => void;
67
+ export declare const createCantMigrateSpreadPropsError: (node: Node, missingProps: string[], errors: errorsListManual, importSource: string, iconName: string) => void;
68
+ export declare const createCantMigrateSizeUnknown: (node: Node, errors: errorsListManual, importSource: string, iconName: string) => void;
69
+ export declare const createAutoMigrationError: (node: Node, importSource: string, iconName: string, newIcon: {
70
+ name: string;
71
+ type: string;
72
+ library: string;
73
+ }, oldIconName: string, errors: errorsListAuto) => void;
74
+ export declare const getLiteralStringValue: (value: any) => string | undefined;
75
+ export declare const createHelpers: (context: Rule.RuleContext) => {
76
+ /**
77
+ * Extracts the primaryColor value from a JSXAttribute
78
+ */
79
+ getPrimaryColor(attr: JSXAttribute): string | null;
80
+ getTokenCallValue: (value: any) => string | undefined;
81
+ getConfigFlag: (key: string, defaultValue: boolean) => boolean;
82
+ };
@@ -1,2 +1,3 @@
1
- declare const rule: import("eslint").Rule.RuleModule;
1
+ import type { Rule } from 'eslint';
2
+ declare const rule: Rule.RuleModule;
2
3
  export default rule;
@@ -0,0 +1,22 @@
1
+ export declare const outcomeDescriptionMap: {
2
+ [key: string]: string;
3
+ };
4
+ export declare const sizes: readonly ["small", "medium", "large", "xlarge"];
5
+ export type Size = (typeof sizes)[number];
6
+ export declare const isSize: (size: any) => size is "small" | "medium" | "large" | "xlarge";
7
+ declare const migrationMap: {
8
+ [lib: string]: {
9
+ sizeGuidance: {
10
+ small: string;
11
+ medium: string;
12
+ large: string;
13
+ xlarge: string;
14
+ };
15
+ newIcon?: {
16
+ name: string;
17
+ type: string;
18
+ library: string;
19
+ };
20
+ };
21
+ };
22
+ export default migrationMap;
@@ -1,4 +1,7 @@
1
- import { type RuleConfig } from './config';
1
+ type RuleConfig = {
2
+ failSilently?: boolean;
3
+ shouldEnforceFallbacks?: boolean;
4
+ };
2
5
  /**
3
6
  * ESLint rules should NEVER throw exceptions, because that breaks the VSCode ESLint server
4
7
  * (and probably the IntelliJ one too), which causes linting to fail in a file.
@@ -9,3 +12,4 @@ import { type RuleConfig } from './config';
9
12
  export declare const errorBoundary: (func: () => void, { config }: {
10
13
  config: RuleConfig;
11
14
  }) => void;
15
+ export {};
@@ -6,4 +6,5 @@ export type RuleConfig = {
6
6
  xcssImportSource: ImportSource;
7
7
  excludeReactComponents: boolean;
8
8
  autoFix: boolean;
9
+ shouldAlwaysCheckXcss: boolean;
9
10
  };
@@ -0,0 +1,13 @@
1
+ import type { Rule } from 'eslint';
2
+ import { type CallExpression, type ExportDefaultDeclaration, type ExportNamedDeclaration, type Identifier, type ImportDeclaration, type VariableDeclaration } from 'eslint-codemod-utils';
3
+ export declare const createChecks: (context: Rule.RuleContext) => {
4
+ checkImportDeclarations: (node: ImportDeclaration & Rule.NodeParentExtension) => void;
5
+ checkVariableDeclarations: (node: VariableDeclaration & Rule.NodeParentExtension) => void;
6
+ checkExportDefaultDeclaration: (node: ExportDefaultDeclaration & Rule.NodeParentExtension) => void;
7
+ checkExportNamedVariables: (node: ExportNamedDeclaration & Rule.NodeParentExtension) => void;
8
+ checkArrayOrMap: (node: Identifier) => void;
9
+ checkIconAsProp: (node: Identifier) => void;
10
+ checkJSXElement: (node: Rule.Node) => void;
11
+ checkCallExpression: (node: CallExpression & Rule.NodeParentExtension) => void;
12
+ throwErrors: () => void;
13
+ };
@@ -0,0 +1,82 @@
1
+ import type { Rule } from 'eslint';
2
+ import { type JSXAttribute, type JSXOpeningElement, type Node } from 'eslint-codemod-utils';
3
+ import { type Size } from './migration-map-temp';
4
+ export type iconMigrationError = Rule.ReportDescriptor;
5
+ export type errorsListManual = {
6
+ [loc: string]: {
7
+ errors: iconMigrationError[];
8
+ iconName: string;
9
+ importSource: string;
10
+ };
11
+ };
12
+ export type errorsListAuto = {
13
+ [loc: string]: iconMigrationError;
14
+ };
15
+ export type guidanceList = {
16
+ [loc: string]: string;
17
+ };
18
+ /**
19
+ * Returns the migration map object for a legacy icon or null if not found
20
+ * @param iconPackage The name of the legacy icon package
21
+ * @returns The migration map object for the legacy icon or null if not found
22
+ */
23
+ export declare const getMigrationMapObject: (iconPackage: string) => {
24
+ sizeGuidance: {
25
+ small: string;
26
+ medium: string;
27
+ large: string;
28
+ xlarge: string;
29
+ };
30
+ newIcon?: {
31
+ name: string;
32
+ type: string;
33
+ library: string;
34
+ } | undefined;
35
+ } | null;
36
+ /**
37
+ * Returns the key of a legacy icon
38
+ * @param iconPackage The name of the legacy icon package
39
+ * @returns The unique identifier for the icon (the part after "@atlaskit/icon/glyph")
40
+ */
41
+ export declare const getIconKey: (iconPackage: string) => string;
42
+ /**
43
+ * Checks if a new icon can be auto-migrated based on guidance from the migration map
44
+ */
45
+ export declare const canAutoMigrateNewIconBasedOnSize: (guidance?: string) => boolean;
46
+ /**
47
+ * Creates the written guidance for migrating a legacy icon to a new icon
48
+ */
49
+ export declare const createGuidance: (iconPackage: string, size?: Size) => string;
50
+ /**
51
+ * Checks if the color can be migrated
52
+ * @param color String representing the color to check
53
+ * @returns True if the color can be migrated, false otherwise
54
+ */
55
+ export declare const canMigrateColor: (color: string) => boolean;
56
+ export declare const locToString: (node: Node) => string;
57
+ export declare const createCantMigrateReExportError: (node: Node, packageName: string, exportName: string, errors: errorsListManual) => void;
58
+ export declare const createCantMigrateIdentifierError: (node: Node, packageName: string, exportName: string, errors: errorsListManual) => void;
59
+ export declare const findUNSAFEProp: (iconAttr: JSXAttribute, button: JSXOpeningElement) => {
60
+ UNSAFE_size: "small" | "large" | "xlarge" | null;
61
+ UNSAFE_propName: "UNSAFE_iconAfter_size" | "UNSAFE_iconBefore_size" | "UNSAFE_size" | null;
62
+ };
63
+ export declare const createCantMigrateUnsafeProp: (node: Node, propName: string, value: string, packageName: string, iconName: string, errors: errorsListManual) => void;
64
+ export declare const createCantFindSuitableReplacementError: (node: Node, importSource: string, iconName: string, errors: errorsListManual) => void;
65
+ export declare const createCantMigrateFunctionUnknownError: (node: Node, importSource: string, iconName: string, errors: errorsListManual) => void;
66
+ export declare const createCantMigrateColorError: (node: Node, colorValue: string, errors: errorsListManual, importSource: string, iconName: string) => void;
67
+ export declare const createCantMigrateSpreadPropsError: (node: Node, missingProps: string[], errors: errorsListManual, importSource: string, iconName: string) => void;
68
+ export declare const createCantMigrateSizeUnknown: (node: Node, errors: errorsListManual, importSource: string, iconName: string) => void;
69
+ export declare const createAutoMigrationError: (node: Node, importSource: string, iconName: string, newIcon: {
70
+ name: string;
71
+ type: string;
72
+ library: string;
73
+ }, oldIconName: string, errors: errorsListAuto) => void;
74
+ export declare const getLiteralStringValue: (value: any) => string | undefined;
75
+ export declare const createHelpers: (context: Rule.RuleContext) => {
76
+ /**
77
+ * Extracts the primaryColor value from a JSXAttribute
78
+ */
79
+ getPrimaryColor(attr: JSXAttribute): string | null;
80
+ getTokenCallValue: (value: any) => string | undefined;
81
+ getConfigFlag: (key: string, defaultValue: boolean) => boolean;
82
+ };
@@ -1,2 +1,3 @@
1
- declare const rule: import("eslint").Rule.RuleModule;
1
+ import type { Rule } from 'eslint';
2
+ declare const rule: Rule.RuleModule;
2
3
  export default rule;
@@ -0,0 +1,27 @@
1
+ export declare const outcomeDescriptionMap: {
2
+ [key: string]: string;
3
+ };
4
+ export declare const sizes: readonly [
5
+ "small",
6
+ "medium",
7
+ "large",
8
+ "xlarge"
9
+ ];
10
+ export type Size = (typeof sizes)[number];
11
+ export declare const isSize: (size: any) => size is "small" | "medium" | "large" | "xlarge";
12
+ declare const migrationMap: {
13
+ [lib: string]: {
14
+ sizeGuidance: {
15
+ small: string;
16
+ medium: string;
17
+ large: string;
18
+ xlarge: string;
19
+ };
20
+ newIcon?: {
21
+ name: string;
22
+ type: string;
23
+ library: string;
24
+ };
25
+ };
26
+ };
27
+ export default migrationMap;
@@ -1,4 +1,7 @@
1
- import { type RuleConfig } from './types';
1
+ type RuleConfig = {
2
+ failSilently?: boolean;
3
+ shouldEnforceFallbacks?: boolean;
4
+ };
2
5
  /**
3
6
  * ESLint rules should NEVER throw exceptions, because that breaks the VSCode ESLint server
4
7
  * (and probably the IntelliJ one too), which causes linting to fail in a file.
@@ -9,3 +12,4 @@ import { type RuleConfig } from './types';
9
12
  export declare const errorBoundary: (func: () => void, { config }: {
10
13
  config: RuleConfig;
11
14
  }) => void;
15
+ 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.8.1",
4
+ "version": "10.9.0",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
7
7
  "publishConfig": {
@@ -1,24 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.errorBoundary = void 0;
7
- /**
8
- * ESLint rules should NEVER throw exceptions, because that breaks the VSCode ESLint server
9
- * (and probably the IntelliJ one too), which causes linting to fail in a file.
10
- *
11
- * It also breaks CI, which was the reason this error boundary was added. It's a final
12
- * catch all.
13
- */
14
- var errorBoundary = exports.errorBoundary = function errorBoundary(func, _ref) {
15
- var config = _ref.config;
16
- try {
17
- func();
18
- } catch (err) {
19
- if (!config.failSilently) {
20
- // eslint-disable-next-line no-console
21
- console.warn(err);
22
- }
23
- }
24
- };
@@ -1,19 +0,0 @@
1
- /**
2
- * ESLint rules should NEVER throw exceptions, because that breaks the VSCode ESLint server
3
- * (and probably the IntelliJ one too), which causes linting to fail in a file.
4
- *
5
- * It also breaks CI, which was the reason this error boundary was added. It's a final
6
- * catch all.
7
- */
8
- export const errorBoundary = (func, {
9
- config
10
- }) => {
11
- try {
12
- func();
13
- } catch (err) {
14
- if (!config.failSilently) {
15
- // eslint-disable-next-line no-console
16
- console.warn(err);
17
- }
18
- }
19
- };
@@ -1,18 +0,0 @@
1
- /**
2
- * ESLint rules should NEVER throw exceptions, because that breaks the VSCode ESLint server
3
- * (and probably the IntelliJ one too), which causes linting to fail in a file.
4
- *
5
- * It also breaks CI, which was the reason this error boundary was added. It's a final
6
- * catch all.
7
- */
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
- }
17
- }
18
- };
@@ -1,11 +0,0 @@
1
- import { type RuleConfig } from './types';
2
- /**
3
- * ESLint rules should NEVER throw exceptions, because that breaks the VSCode ESLint server
4
- * (and probably the IntelliJ one too), which causes linting to fail in a file.
5
- *
6
- * It also breaks CI, which was the reason this error boundary was added. It's a final
7
- * catch all.
8
- */
9
- export declare const errorBoundary: (func: () => void, { config }: {
10
- config: RuleConfig;
11
- }) => void;
@@ -1,11 +0,0 @@
1
- import { type RuleConfig } from './config';
2
- /**
3
- * ESLint rules should NEVER throw exceptions, because that breaks the VSCode ESLint server
4
- * (and probably the IntelliJ one too), which causes linting to fail in a file.
5
- *
6
- * It also breaks CI, which was the reason this error boundary was added. It's a final
7
- * catch all.
8
- */
9
- export declare const errorBoundary: (func: () => void, { config }: {
10
- config: RuleConfig;
11
- }) => void;