@atlaskit/eslint-plugin-design-system 8.27.0 → 8.29.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 (107) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +31 -29
  3. package/constellation/consistent-css-prop-usage/usage.mdx +193 -0
  4. package/constellation/ensure-design-token-usage/usage.mdx +72 -0
  5. package/constellation/ensure-design-token-usage-preview/usage.mdx +5 -0
  6. package/constellation/icon-label/usage.mdx +39 -0
  7. package/constellation/index/usage.mdx +31 -1508
  8. package/constellation/local-cx-xcss/usage.mdx +37 -0
  9. package/constellation/no-banned-imports/usage.mdx +17 -0
  10. package/constellation/no-css-tagged-template-expression/usage.mdx +66 -0
  11. package/constellation/no-deprecated-apis/usage.mdx +76 -0
  12. package/constellation/no-deprecated-design-token-usage/usage.mdx +27 -0
  13. package/constellation/no-deprecated-imports/usage.mdx +62 -0
  14. package/constellation/no-empty-styled-expression/usage.mdx +77 -0
  15. package/constellation/no-exported-css/usage.mdx +50 -0
  16. package/constellation/no-exported-keyframes/usage.mdx +50 -0
  17. package/constellation/no-invalid-css-map/usage.mdx +199 -0
  18. package/constellation/no-keyframes-tagged-template-expression/usage.mdx +76 -0
  19. package/constellation/no-margin/usage.mdx +20 -0
  20. package/constellation/no-nested-styles/usage.mdx +47 -0
  21. package/constellation/no-physical-properties/usage.mdx +53 -0
  22. package/constellation/no-styled-tagged-template-expression/usage.mdx +90 -0
  23. package/constellation/no-unsafe-design-token-usage/usage.mdx +49 -0
  24. package/constellation/no-unsafe-style-overrides/usage.mdx +49 -0
  25. package/constellation/no-unsupported-drag-and-drop-libraries/usage.mdx +17 -0
  26. package/constellation/prefer-primitives/usage.mdx +31 -0
  27. package/constellation/use-button-group-label/usage.mdx +58 -0
  28. package/constellation/use-drawer-label/usage.mdx +53 -0
  29. package/constellation/use-heading-level-in-spotlight-card/usage.mdx +20 -0
  30. package/constellation/use-href-in-link-item/usage.mdx +18 -0
  31. package/constellation/use-primitives/usage.mdx +77 -0
  32. package/constellation/use-visually-hidden/usage.mdx +34 -0
  33. package/dist/cjs/presets/all.codegen.js +3 -1
  34. package/dist/cjs/rules/index.codegen.js +5 -1
  35. package/dist/cjs/rules/no-css-tagged-template-expression/index.js +3 -2
  36. package/dist/cjs/rules/no-keyframes-tagged-template-expression/index.js +27 -0
  37. package/dist/cjs/rules/no-styled-tagged-template-expression/index.js +27 -0
  38. package/dist/cjs/rules/no-styled-tagged-template-expression/is-styled.js +53 -0
  39. package/dist/cjs/rules/use-primitives/transformers/css-to-xcss.js +17 -3
  40. package/dist/cjs/rules/use-primitives/utils/is-valid-css-properties-to-transform.js +7 -0
  41. package/dist/cjs/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/index.js +26 -6
  42. package/dist/cjs/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/to-arguments.js +28 -2
  43. package/dist/cjs/rules/utils/create-rule.js +7 -5
  44. package/dist/cjs/rules/utils/is-supported-import.js +7 -10
  45. package/dist/es2019/presets/all.codegen.js +3 -1
  46. package/dist/es2019/rules/index.codegen.js +5 -1
  47. package/dist/es2019/rules/no-css-tagged-template-expression/index.js +3 -2
  48. package/dist/es2019/rules/no-keyframes-tagged-template-expression/index.js +21 -0
  49. package/dist/es2019/rules/no-styled-tagged-template-expression/index.js +21 -0
  50. package/dist/es2019/rules/no-styled-tagged-template-expression/is-styled.js +45 -0
  51. package/dist/es2019/rules/use-primitives/transformers/css-to-xcss.js +13 -1
  52. package/dist/es2019/rules/use-primitives/utils/is-valid-css-properties-to-transform.js +6 -1
  53. package/dist/es2019/rules/utils/create-no-tagged-template-expression-rule/index.js +84 -0
  54. package/dist/es2019/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/to-arguments.js +28 -2
  55. package/dist/es2019/rules/utils/create-rule.js +7 -5
  56. package/dist/es2019/rules/utils/is-supported-import.js +7 -8
  57. package/dist/esm/presets/all.codegen.js +3 -1
  58. package/dist/esm/rules/index.codegen.js +5 -1
  59. package/dist/esm/rules/no-css-tagged-template-expression/index.js +3 -2
  60. package/dist/esm/rules/no-keyframes-tagged-template-expression/index.js +21 -0
  61. package/dist/esm/rules/no-styled-tagged-template-expression/index.js +21 -0
  62. package/dist/esm/rules/no-styled-tagged-template-expression/is-styled.js +47 -0
  63. package/dist/esm/rules/use-primitives/transformers/css-to-xcss.js +16 -2
  64. package/dist/esm/rules/use-primitives/utils/is-valid-css-properties-to-transform.js +8 -1
  65. package/dist/esm/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/index.js +25 -5
  66. package/dist/esm/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/to-arguments.js +28 -2
  67. package/dist/esm/rules/utils/create-rule.js +7 -5
  68. package/dist/esm/rules/utils/is-supported-import.js +7 -9
  69. package/dist/types/index.codegen.d.ts +2 -0
  70. package/dist/types/presets/all.codegen.d.ts +3 -1
  71. package/dist/types/rules/index.codegen.d.ts +2 -0
  72. package/dist/types/rules/no-keyframes-tagged-template-expression/index.d.ts +2 -0
  73. package/dist/types/rules/no-styled-tagged-template-expression/index.d.ts +2 -0
  74. package/dist/types/rules/no-styled-tagged-template-expression/is-styled.d.ts +7 -0
  75. package/dist/types/rules/use-primitives/config/index.d.ts +1 -1
  76. package/dist/types/rules/use-primitives/transformers/css-to-xcss.d.ts +6 -0
  77. package/dist/types/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/index.d.ts +3 -1
  78. package/dist/types/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/types.d.ts +3 -0
  79. package/dist/types/rules/utils/is-supported-import.d.ts +5 -5
  80. package/dist/types-ts4.5/index.codegen.d.ts +2 -0
  81. package/dist/types-ts4.5/presets/all.codegen.d.ts +3 -1
  82. package/dist/types-ts4.5/rules/index.codegen.d.ts +2 -0
  83. package/dist/types-ts4.5/rules/no-keyframes-tagged-template-expression/index.d.ts +2 -0
  84. package/dist/types-ts4.5/rules/no-styled-tagged-template-expression/index.d.ts +2 -0
  85. package/dist/types-ts4.5/rules/no-styled-tagged-template-expression/is-styled.d.ts +7 -0
  86. package/dist/types-ts4.5/rules/use-primitives/config/index.d.ts +1 -1
  87. package/dist/types-ts4.5/rules/use-primitives/transformers/css-to-xcss.d.ts +6 -0
  88. package/dist/types-ts4.5/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/index.d.ts +3 -1
  89. package/dist/types-ts4.5/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/types.d.ts +3 -0
  90. package/dist/types-ts4.5/rules/utils/is-supported-import.d.ts +5 -5
  91. package/package.json +1 -1
  92. package/dist/es2019/rules/no-css-tagged-template-expression/create-no-tagged-template-expression-rule/index.js +0 -62
  93. /package/dist/cjs/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/generate.js +0 -0
  94. /package/dist/cjs/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/get-tagged-template-expression-offset.js +0 -0
  95. /package/dist/cjs/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/types.js +0 -0
  96. /package/dist/es2019/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/generate.js +0 -0
  97. /package/dist/es2019/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/get-tagged-template-expression-offset.js +0 -0
  98. /package/dist/es2019/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/types.js +0 -0
  99. /package/dist/esm/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/generate.js +0 -0
  100. /package/dist/esm/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/get-tagged-template-expression-offset.js +0 -0
  101. /package/dist/esm/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/types.js +0 -0
  102. /package/dist/types/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/generate.d.ts +0 -0
  103. /package/dist/types/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/get-tagged-template-expression-offset.d.ts +0 -0
  104. /package/dist/types/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/to-arguments.d.ts +0 -0
  105. /package/dist/types-ts4.5/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/generate.d.ts +0 -0
  106. /package/dist/types-ts4.5/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/get-tagged-template-expression-offset.d.ts +0 -0
  107. /package/dist/types-ts4.5/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/to-arguments.d.ts +0 -0
@@ -1,4 +1,4 @@
1
- type Pattern = 'compiled-css-function' | 'compiled-styled-object' | 'css-template-literal' | 'css-property-with-tokens' | 'css-property-multiple-values' | 'multiple-properties';
1
+ type Pattern = 'compiled-css-function' | 'compiled-styled-object' | 'css-template-literal' | 'css-property-with-tokens' | 'css-property-multiple-values' | 'multiple-properties' | 'dimension-properties';
2
2
  export interface RuleConfig {
3
3
  patterns: Pattern[];
4
4
  }
@@ -5,6 +5,12 @@ export declare const styledObjectToXcssTokens: (styles: ObjectExpression & Parti
5
5
  export declare const spaceTokenMap: {
6
6
  [key: string]: string;
7
7
  };
8
+ export declare const dimensionsMap: {
9
+ [key: string]: string;
10
+ };
11
+ export declare const supportedDimensionAttributesMap: {
12
+ [key: string]: typeof spaceTokenMap;
13
+ };
8
14
  export declare const supportedStylesMap: {
9
15
  [key: string]: typeof spaceTokenMap;
10
16
  };
@@ -1,5 +1,7 @@
1
+ import type { JSONSchema4 } from '@typescript-eslint/utils/dist/json-schema';
1
2
  import type { Rule } from 'eslint';
2
- import { SupportedNameChecker } from '../../utils/is-supported-import';
3
+ import { SupportedNameChecker } from '../is-supported-import';
3
4
  type RuleModule = Rule.RuleModule;
5
+ export declare const noTaggedTemplateExpressionRuleSchema: JSONSchema4;
4
6
  export declare const createNoTaggedTemplateExpressionRule: (isUsage: SupportedNameChecker, messageId: string) => RuleModule['create'];
5
7
  export {};
@@ -23,3 +23,6 @@ export type DeclarationBlock = {
23
23
  blocks: Block[];
24
24
  };
25
25
  export type Argument = Expression | DeclarationBlock;
26
+ export type RuleConfig = {
27
+ importSources?: string[];
28
+ };
@@ -6,20 +6,20 @@ export declare const CSS_IN_JS_IMPORTS: {
6
6
  readonly compiled: "@compiled/react";
7
7
  readonly emotionReact: "@emotion/react";
8
8
  readonly emotionCore: "@emotion/core";
9
+ readonly emotionStyled: "@emotion/styled";
9
10
  readonly styledComponents: "styled-components";
10
11
  readonly atlaskitCss: "@atlaskit/css";
11
12
  readonly atlaskitPrimitives: "@atlaskit/primitives";
12
13
  };
13
14
  export type ImportSource = string;
14
15
  export type SupportedNameChecker = (nodeToCheck: Callee, referencesInScope: Reference[], importSources: ImportSource[]) => boolean;
16
+ /**
17
+ * By default all known import sources are checked against.
18
+ */
15
19
  export declare const DEFAULT_IMPORT_SOURCES: ImportSource[];
16
20
  /**
17
21
  * Given the ESLint rule context, extract and parse the value of the importSources rule option.
18
- * The importSources option is used to define additional libraries for which an ESLint rule
19
- * should apply to.
20
- *
21
- * Note that `@compiled/react` and `@atlaskit/css` are always included in importSources, regardless
22
- * of what importSources is configured to by the user.
22
+ * The importSources option is used to override which libraries an ESLint rule applies to.
23
23
  *
24
24
  * @param context The rule context.
25
25
  * @returns An array of strings representing what CSS-in-JS packages that should be checked, based
@@ -17,9 +17,11 @@ export declare const configs: {
17
17
  '@atlaskit/design-system/no-exported-css': string;
18
18
  '@atlaskit/design-system/no-exported-keyframes': string;
19
19
  '@atlaskit/design-system/no-invalid-css-map': string;
20
+ '@atlaskit/design-system/no-keyframes-tagged-template-expression': string;
20
21
  '@atlaskit/design-system/no-margin': string;
21
22
  '@atlaskit/design-system/no-nested-styles': string;
22
23
  '@atlaskit/design-system/no-physical-properties': string;
24
+ '@atlaskit/design-system/no-styled-tagged-template-expression': string;
23
25
  '@atlaskit/design-system/no-unsafe-design-token-usage': string;
24
26
  '@atlaskit/design-system/no-unsafe-style-overrides': string;
25
27
  '@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': 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::914085544778f4543f43e3e30d0982e0>>
3
+ * @codegen <<SignedSource::5647ce9c10ba880cffece66b5924fd6e>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  declare const _default: {
@@ -20,9 +20,11 @@ declare const _default: {
20
20
  '@atlaskit/design-system/no-exported-css': string;
21
21
  '@atlaskit/design-system/no-exported-keyframes': string;
22
22
  '@atlaskit/design-system/no-invalid-css-map': string;
23
+ '@atlaskit/design-system/no-keyframes-tagged-template-expression': string;
23
24
  '@atlaskit/design-system/no-margin': string;
24
25
  '@atlaskit/design-system/no-nested-styles': string;
25
26
  '@atlaskit/design-system/no-physical-properties': string;
27
+ '@atlaskit/design-system/no-styled-tagged-template-expression': string;
26
28
  '@atlaskit/design-system/no-unsafe-design-token-usage': string;
27
29
  '@atlaskit/design-system/no-unsafe-style-overrides': string;
28
30
  '@atlaskit/design-system/no-unsupported-drag-and-drop-libraries': string;
@@ -21,9 +21,11 @@ declare const _default: {
21
21
  'no-exported-css': import("eslint").Rule.RuleModule;
22
22
  'no-exported-keyframes': import("eslint").Rule.RuleModule;
23
23
  'no-invalid-css-map': import("eslint").Rule.RuleModule;
24
+ 'no-keyframes-tagged-template-expression': import("eslint").Rule.RuleModule;
24
25
  'no-margin': import("eslint").Rule.RuleModule;
25
26
  'no-nested-styles': import("eslint").Rule.RuleModule;
26
27
  'no-physical-properties': import("eslint").Rule.RuleModule;
28
+ 'no-styled-tagged-template-expression': import("eslint").Rule.RuleModule;
27
29
  'no-unsafe-design-token-usage': import("eslint").Rule.RuleModule;
28
30
  'no-unsafe-style-overrides': import("eslint").Rule.RuleModule;
29
31
  'no-unsupported-drag-and-drop-libraries': import("eslint").Rule.RuleModule;
@@ -0,0 +1,2 @@
1
+ declare const rule: import("eslint").Rule.RuleModule;
2
+ export default rule;
@@ -0,0 +1,2 @@
1
+ declare const rule: import("eslint").Rule.RuleModule;
2
+ export default rule;
@@ -0,0 +1,7 @@
1
+ import type { Scope } from 'eslint';
2
+ import type { CallExpression } from 'estree';
3
+ import { ImportSource } from '../utils/is-supported-import';
4
+ type Callee = CallExpression['callee'];
5
+ type Reference = Scope.Reference;
6
+ export declare const isStyled: (nodeToCheck: Callee, referencesInScope: Reference[], importSources: ImportSource[]) => boolean;
7
+ export {};
@@ -1,4 +1,4 @@
1
- type Pattern = 'compiled-css-function' | 'compiled-styled-object' | 'css-template-literal' | 'css-property-with-tokens' | 'css-property-multiple-values' | 'multiple-properties';
1
+ type Pattern = 'compiled-css-function' | 'compiled-styled-object' | 'css-template-literal' | 'css-property-with-tokens' | 'css-property-multiple-values' | 'multiple-properties' | 'dimension-properties';
2
2
  export interface RuleConfig {
3
3
  patterns: Pattern[];
4
4
  }
@@ -5,6 +5,12 @@ export declare const styledObjectToXcssTokens: (styles: ObjectExpression & Parti
5
5
  export declare const spaceTokenMap: {
6
6
  [key: string]: string;
7
7
  };
8
+ export declare const dimensionsMap: {
9
+ [key: string]: string;
10
+ };
11
+ export declare const supportedDimensionAttributesMap: {
12
+ [key: string]: typeof spaceTokenMap;
13
+ };
8
14
  export declare const supportedStylesMap: {
9
15
  [key: string]: typeof spaceTokenMap;
10
16
  };
@@ -1,5 +1,7 @@
1
+ import type { JSONSchema4 } from '@typescript-eslint/utils/dist/json-schema';
1
2
  import type { Rule } from 'eslint';
2
- import { SupportedNameChecker } from '../../utils/is-supported-import';
3
+ import { SupportedNameChecker } from '../is-supported-import';
3
4
  type RuleModule = Rule.RuleModule;
5
+ export declare const noTaggedTemplateExpressionRuleSchema: JSONSchema4;
4
6
  export declare const createNoTaggedTemplateExpressionRule: (isUsage: SupportedNameChecker, messageId: string) => RuleModule['create'];
5
7
  export {};
@@ -23,3 +23,6 @@ export type DeclarationBlock = {
23
23
  blocks: Block[];
24
24
  };
25
25
  export type Argument = Expression | DeclarationBlock;
26
+ export type RuleConfig = {
27
+ importSources?: string[];
28
+ };
@@ -6,20 +6,20 @@ export declare const CSS_IN_JS_IMPORTS: {
6
6
  readonly compiled: "@compiled/react";
7
7
  readonly emotionReact: "@emotion/react";
8
8
  readonly emotionCore: "@emotion/core";
9
+ readonly emotionStyled: "@emotion/styled";
9
10
  readonly styledComponents: "styled-components";
10
11
  readonly atlaskitCss: "@atlaskit/css";
11
12
  readonly atlaskitPrimitives: "@atlaskit/primitives";
12
13
  };
13
14
  export type ImportSource = string;
14
15
  export type SupportedNameChecker = (nodeToCheck: Callee, referencesInScope: Reference[], importSources: ImportSource[]) => boolean;
16
+ /**
17
+ * By default all known import sources are checked against.
18
+ */
15
19
  export declare const DEFAULT_IMPORT_SOURCES: ImportSource[];
16
20
  /**
17
21
  * Given the ESLint rule context, extract and parse the value of the importSources rule option.
18
- * The importSources option is used to define additional libraries for which an ESLint rule
19
- * should apply to.
20
- *
21
- * Note that `@compiled/react` and `@atlaskit/css` are always included in importSources, regardless
22
- * of what importSources is configured to by the user.
22
+ * The importSources option is used to override which libraries an ESLint rule applies to.
23
23
  *
24
24
  * @param context The rule context.
25
25
  * @returns An array of strings representing what CSS-in-JS packages that should be checked, based
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": "8.27.0",
4
+ "version": "8.29.0",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "publishConfig": {
7
7
  "registry": "https://registry.npmjs.org/"
@@ -1,62 +0,0 @@
1
- // Original source from Compiled https://github.com/atlassian-labs/compiled/blob/master/packages/eslint-plugin/src/utils/create-no-tagged-template-expression-rule/index.ts
2
- // eslint-disable-next-line import/no-extraneous-dependencies
3
-
4
- import { CSS_IN_JS_IMPORTS } from '../../utils/is-supported-import';
5
- import { generate } from './generate';
6
- import { getTaggedTemplateExpressionOffset } from './get-tagged-template-expression-offset';
7
- import { toArguments } from './to-arguments';
8
- const IMPORT_SOURCES = [CSS_IN_JS_IMPORTS.compiled, CSS_IN_JS_IMPORTS.emotionReact, CSS_IN_JS_IMPORTS.emotionCore, CSS_IN_JS_IMPORTS.styledComponents];
9
- export const createNoTaggedTemplateExpressionRule = (isUsage, messageId) => context => ({
10
- TaggedTemplateExpression(node) {
11
- const {
12
- references
13
- } = context.getScope();
14
- if (!isUsage(node.tag, references, IMPORT_SOURCES)) {
15
- return;
16
- }
17
- context.report({
18
- messageId,
19
- node,
20
- *fix(fixer) {
21
- const {
22
- quasi
23
- } = node;
24
- const source = context.getSourceCode();
25
-
26
- // TODO Eventually handle comments instead of skipping them
27
- // Skip auto-fixing comments
28
- if (quasi.quasis.map(q => q.value.raw).join('').match(/\/\*[\s\S]*\*\//g)) {
29
- return;
30
- }
31
-
32
- // Replace empty tagged template expression with the equivalent object call expression
33
- if (!quasi.expressions.length && quasi.quasis.length === 1 && !quasi.quasis[0].value.raw.trim()) {
34
- yield fixer.replaceText(quasi, '({})');
35
- return;
36
- }
37
- const args = toArguments(source, quasi);
38
-
39
- // Skip invalid CSS
40
- if (args.length < 1) {
41
- return;
42
- }
43
- const oldCode = source.getText(node);
44
- // Remove quasi:
45
- // styled.div<Props>`
46
- // color: red;
47
- // `
48
- // becomes
49
- // styled.div<Props>
50
- const withoutQuasi = oldCode.replace(source.getText(quasi), '');
51
- const newCode = withoutQuasi +
52
- // Indent the arguments after the tagged template expression range
53
- generate(args, getTaggedTemplateExpressionOffset(node));
54
- if (oldCode === newCode) {
55
- return;
56
- }
57
- yield fixer.insertTextBefore(node, newCode);
58
- yield fixer.remove(node);
59
- }
60
- });
61
- }
62
- });