@atlaskit/eslint-plugin-design-system 8.27.0 → 8.28.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 (97) hide show
  1. package/CHANGELOG.md +6 -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/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/index.js +26 -6
  40. package/dist/cjs/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/to-arguments.js +28 -2
  41. package/dist/cjs/rules/utils/create-rule.js +7 -5
  42. package/dist/cjs/rules/utils/is-supported-import.js +7 -10
  43. package/dist/es2019/presets/all.codegen.js +3 -1
  44. package/dist/es2019/rules/index.codegen.js +5 -1
  45. package/dist/es2019/rules/no-css-tagged-template-expression/index.js +3 -2
  46. package/dist/es2019/rules/no-keyframes-tagged-template-expression/index.js +21 -0
  47. package/dist/es2019/rules/no-styled-tagged-template-expression/index.js +21 -0
  48. package/dist/es2019/rules/no-styled-tagged-template-expression/is-styled.js +45 -0
  49. package/dist/es2019/rules/utils/create-no-tagged-template-expression-rule/index.js +84 -0
  50. package/dist/es2019/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/to-arguments.js +28 -2
  51. package/dist/es2019/rules/utils/create-rule.js +7 -5
  52. package/dist/es2019/rules/utils/is-supported-import.js +7 -8
  53. package/dist/esm/presets/all.codegen.js +3 -1
  54. package/dist/esm/rules/index.codegen.js +5 -1
  55. package/dist/esm/rules/no-css-tagged-template-expression/index.js +3 -2
  56. package/dist/esm/rules/no-keyframes-tagged-template-expression/index.js +21 -0
  57. package/dist/esm/rules/no-styled-tagged-template-expression/index.js +21 -0
  58. package/dist/esm/rules/no-styled-tagged-template-expression/is-styled.js +47 -0
  59. package/dist/esm/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/index.js +25 -5
  60. package/dist/esm/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/to-arguments.js +28 -2
  61. package/dist/esm/rules/utils/create-rule.js +7 -5
  62. package/dist/esm/rules/utils/is-supported-import.js +7 -9
  63. package/dist/types/index.codegen.d.ts +2 -0
  64. package/dist/types/presets/all.codegen.d.ts +3 -1
  65. package/dist/types/rules/index.codegen.d.ts +2 -0
  66. package/dist/types/rules/no-keyframes-tagged-template-expression/index.d.ts +2 -0
  67. package/dist/types/rules/no-styled-tagged-template-expression/index.d.ts +2 -0
  68. package/dist/types/rules/no-styled-tagged-template-expression/is-styled.d.ts +7 -0
  69. package/dist/types/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/index.d.ts +3 -1
  70. package/dist/types/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/types.d.ts +3 -0
  71. package/dist/types/rules/utils/is-supported-import.d.ts +5 -5
  72. package/dist/types-ts4.5/index.codegen.d.ts +2 -0
  73. package/dist/types-ts4.5/presets/all.codegen.d.ts +3 -1
  74. package/dist/types-ts4.5/rules/index.codegen.d.ts +2 -0
  75. package/dist/types-ts4.5/rules/no-keyframes-tagged-template-expression/index.d.ts +2 -0
  76. package/dist/types-ts4.5/rules/no-styled-tagged-template-expression/index.d.ts +2 -0
  77. package/dist/types-ts4.5/rules/no-styled-tagged-template-expression/is-styled.d.ts +7 -0
  78. package/dist/types-ts4.5/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/index.d.ts +3 -1
  79. package/dist/types-ts4.5/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/types.d.ts +3 -0
  80. package/dist/types-ts4.5/rules/utils/is-supported-import.d.ts +5 -5
  81. package/package.json +1 -1
  82. package/dist/es2019/rules/no-css-tagged-template-expression/create-no-tagged-template-expression-rule/index.js +0 -62
  83. /package/dist/cjs/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/generate.js +0 -0
  84. /package/dist/cjs/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/get-tagged-template-expression-offset.js +0 -0
  85. /package/dist/cjs/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/types.js +0 -0
  86. /package/dist/es2019/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/generate.js +0 -0
  87. /package/dist/es2019/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/get-tagged-template-expression-offset.js +0 -0
  88. /package/dist/es2019/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/types.js +0 -0
  89. /package/dist/esm/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/generate.js +0 -0
  90. /package/dist/esm/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/get-tagged-template-expression-offset.js +0 -0
  91. /package/dist/esm/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/types.js +0 -0
  92. /package/dist/types/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/generate.d.ts +0 -0
  93. /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
  94. /package/dist/types/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/to-arguments.d.ts +0 -0
  95. /package/dist/types-ts4.5/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/generate.d.ts +0 -0
  96. /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
  97. /package/dist/types-ts4.5/rules/{no-css-tagged-template-expression → utils}/create-no-tagged-template-expression-rule/to-arguments.d.ts +0 -0
@@ -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.28.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
- });