@atlaskit/eslint-plugin-design-system 10.12.4 → 10.13.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 (50) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/cjs/rules/no-legacy-icons/checks.js +90 -44
  3. package/dist/cjs/rules/no-legacy-icons/helpers.js +44 -12
  4. package/dist/cjs/rules/no-legacy-icons/index.js +5 -3
  5. package/dist/cjs/rules/use-heading/config/index.js +2 -1
  6. package/dist/cjs/rules/use-heading/transformers/native-elements.js +61 -31
  7. package/dist/cjs/rules/use-primitives-text/config/index.js +2 -1
  8. package/dist/cjs/rules/use-primitives-text/transformers/emphasis-elements.js +48 -26
  9. package/dist/cjs/rules/use-primitives-text/transformers/paragraph-elements.js +62 -51
  10. package/dist/cjs/rules/use-primitives-text/transformers/span-elements.js +56 -32
  11. package/dist/cjs/rules/use-primitives-text/transformers/strong-elements.js +48 -26
  12. package/dist/es2019/rules/no-legacy-icons/checks.js +75 -33
  13. package/dist/es2019/rules/no-legacy-icons/helpers.js +43 -11
  14. package/dist/es2019/rules/no-legacy-icons/index.js +5 -3
  15. package/dist/es2019/rules/use-heading/config/index.js +2 -1
  16. package/dist/es2019/rules/use-heading/transformers/native-elements.js +60 -29
  17. package/dist/es2019/rules/use-primitives-text/config/index.js +2 -1
  18. package/dist/es2019/rules/use-primitives-text/transformers/emphasis-elements.js +47 -24
  19. package/dist/es2019/rules/use-primitives-text/transformers/paragraph-elements.js +63 -52
  20. package/dist/es2019/rules/use-primitives-text/transformers/span-elements.js +55 -30
  21. package/dist/es2019/rules/use-primitives-text/transformers/strong-elements.js +47 -24
  22. package/dist/esm/rules/no-legacy-icons/checks.js +91 -45
  23. package/dist/esm/rules/no-legacy-icons/helpers.js +43 -11
  24. package/dist/esm/rules/no-legacy-icons/index.js +5 -3
  25. package/dist/esm/rules/use-heading/config/index.js +2 -1
  26. package/dist/esm/rules/use-heading/transformers/native-elements.js +61 -31
  27. package/dist/esm/rules/use-primitives-text/config/index.js +2 -1
  28. package/dist/esm/rules/use-primitives-text/transformers/emphasis-elements.js +48 -26
  29. package/dist/esm/rules/use-primitives-text/transformers/paragraph-elements.js +62 -51
  30. package/dist/esm/rules/use-primitives-text/transformers/span-elements.js +56 -32
  31. package/dist/esm/rules/use-primitives-text/transformers/strong-elements.js +48 -26
  32. package/dist/types/rules/no-legacy-icons/checks.d.ts +4 -1
  33. package/dist/types/rules/no-legacy-icons/helpers.d.ts +21 -14
  34. package/dist/types/rules/use-heading/config/index.d.ts +2 -1
  35. package/dist/types/rules/use-heading/transformers/native-elements.d.ts +5 -1
  36. package/dist/types/rules/use-primitives-text/config/index.d.ts +1 -0
  37. package/dist/types/rules/use-primitives-text/transformers/emphasis-elements.d.ts +6 -1
  38. package/dist/types/rules/use-primitives-text/transformers/paragraph-elements.d.ts +1 -0
  39. package/dist/types/rules/use-primitives-text/transformers/span-elements.d.ts +6 -1
  40. package/dist/types/rules/use-primitives-text/transformers/strong-elements.d.ts +6 -1
  41. package/dist/types-ts4.5/rules/no-legacy-icons/checks.d.ts +4 -1
  42. package/dist/types-ts4.5/rules/no-legacy-icons/helpers.d.ts +21 -14
  43. package/dist/types-ts4.5/rules/use-heading/config/index.d.ts +2 -1
  44. package/dist/types-ts4.5/rules/use-heading/transformers/native-elements.d.ts +5 -1
  45. package/dist/types-ts4.5/rules/use-primitives-text/config/index.d.ts +1 -0
  46. package/dist/types-ts4.5/rules/use-primitives-text/transformers/emphasis-elements.d.ts +6 -1
  47. package/dist/types-ts4.5/rules/use-primitives-text/transformers/paragraph-elements.d.ts +1 -0
  48. package/dist/types-ts4.5/rules/use-primitives-text/transformers/span-elements.d.ts +6 -1
  49. package/dist/types-ts4.5/rules/use-primitives-text/transformers/strong-elements.d.ts +6 -1
  50. package/package.json +2 -2
@@ -1,13 +1,16 @@
1
1
  import type { Rule } from 'eslint';
2
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) => {
3
+ type ReturnObject = {
4
4
  checkImportDeclarations: (node: ImportDeclaration & Rule.NodeParentExtension) => void;
5
5
  checkVariableDeclarations: (node: VariableDeclaration & Rule.NodeParentExtension) => void;
6
6
  checkExportDefaultDeclaration: (node: ExportDefaultDeclaration & Rule.NodeParentExtension) => void;
7
7
  checkExportNamedVariables: (node: ExportNamedDeclaration & Rule.NodeParentExtension) => void;
8
8
  checkArrayOrMap: (node: Identifier) => void;
9
9
  checkIconAsProp: (node: Identifier) => void;
10
+ checkIconReference: (node: Identifier & Rule.NodeParentExtension) => void;
10
11
  checkJSXElement: (node: Rule.Node) => void;
11
12
  checkCallExpression: (node: CallExpression & Rule.NodeParentExtension) => void;
12
13
  throwErrors: () => void;
13
14
  };
15
+ export declare const createChecks: (context: Rule.RuleContext) => ReturnObject;
16
+ export {};
@@ -1,18 +1,22 @@
1
1
  import type { Rule } from 'eslint';
2
2
  import { type JSXAttribute, type Node } from 'eslint-codemod-utils';
3
3
  import { type IconMigrationSizeGuidance } from '@atlaskit/icon/UNSAFE_migration-map';
4
- export type iconMigrationError = Rule.ReportDescriptor;
5
- export type errorsListManual = {
4
+ export type IconMigrationError = Rule.ReportDescriptor;
5
+ export type RangeList = {
6
+ start: number;
7
+ end: number;
8
+ }[];
9
+ export type ErrorListManual = {
6
10
  [loc: string]: {
7
- errors: iconMigrationError[];
11
+ errors: IconMigrationError[];
8
12
  iconName: string;
9
13
  importSource: string;
10
14
  };
11
15
  };
12
- export type errorsListAuto = {
13
- [loc: string]: iconMigrationError;
16
+ export type ErrorListAuto = {
17
+ [loc: string]: IconMigrationError;
14
18
  };
15
- export type guidanceList = {
19
+ export type GuidanceList = {
16
20
  [loc: string]: string;
17
21
  };
18
22
  declare const sizes: readonly [
@@ -47,14 +51,15 @@ export declare const createGuidance: (iconPackage: string, insideNewButton?: boo
47
51
  */
48
52
  export declare const canMigrateColor: (color: string) => boolean;
49
53
  export declare const locToString: (node: Node) => string;
50
- export declare const createCantMigrateReExportError: (node: Node, packageName: string, exportName: string, errors: errorsListManual) => void;
51
- export declare const createCantMigrateIdentifierError: (node: Node, packageName: string, exportName: string, errors: errorsListManual) => void;
52
- export declare const createCantFindSuitableReplacementError: (node: Node, importSource: string, iconName: string, errors: errorsListManual, sizeIssue?: boolean) => void;
53
- export declare const createCantMigrateFunctionUnknownError: (node: Node, importSource: string, iconName: string, errors: errorsListManual) => void;
54
- export declare const createCantMigrateColorError: (node: Node, colorValue: string, errors: errorsListManual, importSource: string, iconName: string) => void;
55
- export declare const createCantMigrateSpreadPropsError: (node: Node, missingProps: string[], errors: errorsListManual, importSource: string, iconName: string) => void;
56
- export declare const createCantMigrateSizeUnknown: (node: Node, errors: errorsListManual, importSource: string, iconName: string) => void;
57
- export declare const createAutoMigrationError: (node: Node, importSource: string, iconName: string, errors: errorsListAuto) => void;
54
+ export declare const createCantMigrateReExportError: (node: Node, packageName: string, exportName: string, errors: ErrorListManual) => void;
55
+ export declare const createCantMigrateIdentifierMapOrArrayError: (node: Node, packageName: string, exportName: string, errors: ErrorListManual) => void;
56
+ export declare const createCantMigrateIdentifierError: (node: Node, packageName: string, exportName: string, errors: ErrorListManual) => void;
57
+ export declare const createCantFindSuitableReplacementError: (node: Node, importSource: string, iconName: string, errors: ErrorListManual, sizeIssue?: boolean) => void;
58
+ export declare const createCantMigrateFunctionUnknownError: (node: Node, importSource: string, iconName: string, errors: ErrorListManual) => void;
59
+ export declare const createCantMigrateColorError: (node: Node, colorValue: string, errors: ErrorListManual, importSource: string, iconName: string) => void;
60
+ export declare const createCantMigrateSpreadPropsError: (node: Node, missingProps: string[], errors: ErrorListManual, importSource: string, iconName: string) => void;
61
+ export declare const createCantMigrateSizeUnknown: (node: Node, errors: ErrorListManual, importSource: string, iconName: string) => void;
62
+ export declare const createAutoMigrationError: (node: Node, importSource: string, iconName: string, errors: ErrorListAuto) => void;
58
63
  export declare const getLiteralStringValue: (value: any) => string | undefined;
59
64
  export declare const createHelpers: (context: Rule.RuleContext) => {
60
65
  /**
@@ -64,4 +69,6 @@ export declare const createHelpers: (context: Rule.RuleContext) => {
64
69
  getTokenCallValue: (value: any) => string | undefined;
65
70
  getConfigFlag: (key: string, defaultValue: boolean) => boolean;
66
71
  };
72
+ export declare const addToListOfRanges: (node: Node, sortedListOfRangesForErrors: RangeList) => void;
73
+ export declare const isInRangeList: (node: Node, sortedListOfRangesForErrors: RangeList) => boolean;
67
74
  export {};
@@ -2,7 +2,8 @@ type Pattern = 'native-elements';
2
2
  export interface RuleConfig {
3
3
  failSilently: boolean;
4
4
  patterns: Pattern[];
5
- enableUnsafeAutofix: false;
5
+ enableUnsafeAutofix: boolean;
6
+ enableUnsafeReport: boolean;
6
7
  }
7
8
  export declare const getConfig: (overrides: Partial<RuleConfig>) => RuleConfig;
8
9
  export {};
@@ -10,9 +10,13 @@ interface ValidHeadingElement extends JSXElement {
10
10
  };
11
11
  } & JSXOpeningElement;
12
12
  }
13
+ type CheckResult = {
14
+ success: boolean;
15
+ autoFixable?: boolean;
16
+ };
13
17
  export declare const NativeElements: {
14
18
  lint(node: Rule.Node, { context, config }: MetaData): void;
15
- _check(node: Rule.Node, { config }: MetaData): node is ValidHeadingElement;
19
+ _check(node: Rule.Node, { config }: MetaData): CheckResult;
16
20
  _fix(node: ValidHeadingElement, { context }: MetaData): Rule.ReportFixer;
17
21
  };
18
22
  export {};
@@ -4,6 +4,7 @@ export interface RuleConfig {
4
4
  patterns: Pattern[];
5
5
  inheritColor: boolean;
6
6
  enableUnsafeAutofix: boolean;
7
+ enableUnsafeReport: boolean;
7
8
  }
8
9
  export declare const getConfig: (overrides: Partial<RuleConfig>) => RuleConfig;
9
10
  export {};
@@ -1,8 +1,13 @@
1
1
  import type { Rule } from 'eslint';
2
2
  import { type JSXElement } from 'eslint-codemod-utils';
3
3
  import { type MetaData } from './common';
4
+ type CheckResult = {
5
+ success: boolean;
6
+ autoFixable?: boolean;
7
+ };
4
8
  export declare const EmphasisElements: {
5
9
  lint(node: Rule.Node, { context, config }: MetaData): void;
6
- _check(node: JSXElement, { context, config }: MetaData): boolean;
10
+ _check(node: JSXElement, { context, config }: MetaData): CheckResult;
7
11
  _fix(node: JSXElement, { context, config }: MetaData): Rule.ReportFixer;
8
12
  };
13
+ export {};
@@ -6,6 +6,7 @@ type CheckResult = {
6
6
  refs: {
7
7
  siblings: JSXElement['children'];
8
8
  };
9
+ autoFixable?: boolean;
9
10
  };
10
11
  export declare const ParagraphElements: {
11
12
  lint(node: Rule.Node, { context, config }: MetaData): void;
@@ -1,8 +1,13 @@
1
1
  import type { Rule } from 'eslint';
2
2
  import { type JSXElement } from 'eslint-codemod-utils';
3
3
  import { type MetaData } from './common';
4
+ type CheckResult = {
5
+ success: boolean;
6
+ autoFixable?: boolean;
7
+ };
4
8
  export declare const SpanElements: {
5
9
  lint(node: Rule.Node, { context, config }: MetaData): void;
6
- _check(node: JSXElement, { context, config }: MetaData): boolean;
10
+ _check(node: JSXElement, { context, config }: MetaData): CheckResult;
7
11
  _fix(node: JSXElement, { context, config }: MetaData): Rule.ReportFixer;
8
12
  };
13
+ export {};
@@ -1,8 +1,13 @@
1
1
  import type { Rule } from 'eslint';
2
2
  import { type JSXElement } from 'eslint-codemod-utils';
3
3
  import { type MetaData } from './common';
4
+ type CheckResult = {
5
+ success: boolean;
6
+ autoFixable?: boolean;
7
+ };
4
8
  export declare const StrongElements: {
5
9
  lint(node: Rule.Node, { context, config }: MetaData): void;
6
- _check(node: JSXElement, { context, config }: MetaData): boolean;
10
+ _check(node: JSXElement, { context, config }: MetaData): CheckResult;
7
11
  _fix(node: JSXElement, { context, config }: MetaData): Rule.ReportFixer;
8
12
  };
13
+ 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.12.4",
4
+ "version": "10.13.0",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
7
7
  "publishConfig": {
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@atlaskit/eslint-utils": "^1.6.0",
45
- "@atlaskit/icon": "^22.10.0",
45
+ "@atlaskit/icon": "^22.11.0",
46
46
  "@atlaskit/tokens": "*",
47
47
  "@babel/runtime": "^7.0.0",
48
48
  "@typescript-eslint/utils": "^5.48.1",