@atlaskit/eslint-plugin-design-system 9.6.0 → 10.0.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 (151) hide show
  1. package/CHANGELOG.md +1004 -411
  2. package/README.md +7 -5
  3. package/constellation/consistent-css-prop-usage/usage.mdx +44 -30
  4. package/constellation/ensure-design-token-usage/usage.mdx +12 -7
  5. package/constellation/ensure-design-token-usage-preview/usage.mdx +2 -1
  6. package/constellation/icon-label/usage.mdx +5 -3
  7. package/constellation/index/usage.mdx +5 -2
  8. package/constellation/no-banned-imports/usage.mdx +3 -1
  9. package/constellation/no-css-tagged-template-expression/usage.mdx +22 -17
  10. package/constellation/no-deprecated-apis/usage.mdx +33 -27
  11. package/constellation/no-deprecated-design-token-usage/usage.mdx +7 -4
  12. package/constellation/no-deprecated-imports/usage.mdx +31 -27
  13. package/constellation/no-direct-use-of-web-platform-drag-and-drop/usage.mdx +19 -10
  14. package/constellation/no-empty-styled-expression/usage.mdx +19 -14
  15. package/constellation/no-exported-css/usage.mdx +15 -10
  16. package/constellation/no-exported-keyframes/usage.mdx +15 -10
  17. package/constellation/no-html-anchor/usage.mdx +40 -0
  18. package/constellation/no-html-button/usage.mdx +52 -0
  19. package/constellation/no-invalid-css-map/usage.mdx +69 -58
  20. package/constellation/no-keyframes-tagged-template-expression/usage.mdx +24 -18
  21. package/constellation/no-margin/usage.mdx +3 -2
  22. package/constellation/no-nested-styles/usage.mdx +16 -16
  23. package/constellation/no-physical-properties/usage.mdx +13 -13
  24. package/constellation/no-styled-tagged-template-expression/usage.mdx +39 -34
  25. package/constellation/no-unsafe-design-token-usage/usage.mdx +8 -7
  26. package/constellation/no-unsafe-style-overrides/usage.mdx +10 -7
  27. package/constellation/no-unsupported-drag-and-drop-libraries/usage.mdx +8 -2
  28. package/constellation/prefer-primitives/usage.mdx +3 -2
  29. package/constellation/use-button-group-label/usage.mdx +4 -2
  30. package/constellation/use-drawer-label/usage.mdx +4 -2
  31. package/constellation/use-heading/usage.mdx +7 -4
  32. package/constellation/use-heading-level-in-spotlight-card/usage.mdx +3 -2
  33. package/constellation/use-href-in-link-item/usage.mdx +2 -1
  34. package/constellation/use-popup-label/usage.mdx +56 -0
  35. package/constellation/use-primitives/usage.mdx +40 -39
  36. package/constellation/use-primitives-text/usage.mdx +7 -3
  37. package/constellation/use-tokens-space/usage.mdx +7 -3
  38. package/constellation/use-tokens-typography/usage.mdx +15 -6
  39. package/constellation/use-visually-hidden/usage.mdx +2 -1
  40. package/dist/cjs/common/token-maps.partial.js +49 -0
  41. package/dist/cjs/index.codegen.js +1 -1
  42. package/dist/cjs/presets/all.codegen.js +4 -2
  43. package/dist/cjs/presets/recommended.codegen.js +2 -1
  44. package/dist/cjs/rules/index.codegen.js +7 -3
  45. package/dist/cjs/rules/no-html-anchor/index.js +39 -0
  46. package/dist/cjs/rules/no-html-anchor/node-types/index.js +19 -0
  47. package/dist/cjs/rules/no-html-anchor/node-types/jsx-element/index.js +28 -0
  48. package/dist/cjs/rules/no-html-anchor/node-types/styled-component/get-styled-component-call.js +47 -0
  49. package/dist/cjs/rules/no-html-anchor/node-types/styled-component/index.js +37 -0
  50. package/dist/cjs/rules/no-html-anchor/node-types/supported.js +66 -0
  51. package/dist/cjs/rules/no-html-anchor/utils/get-jsx-element-by-name.js +53 -0
  52. package/dist/cjs/rules/no-html-button/index.js +39 -0
  53. package/dist/cjs/rules/no-html-button/node-types/index.js +19 -0
  54. package/dist/cjs/rules/no-html-button/node-types/jsx-element/index.js +28 -0
  55. package/dist/cjs/rules/no-html-button/node-types/styled-component/get-styled-component-call.js +47 -0
  56. package/dist/cjs/rules/no-html-button/node-types/styled-component/index.js +37 -0
  57. package/dist/cjs/rules/no-html-button/node-types/supported.js +79 -0
  58. package/dist/cjs/rules/no-html-button/utils/get-jsx-element-by-name.js +53 -0
  59. package/dist/cjs/rules/use-popup-label/index.js +90 -0
  60. package/dist/es2019/common/token-maps.partial.js +42 -0
  61. package/dist/es2019/index.codegen.js +1 -1
  62. package/dist/es2019/presets/all.codegen.js +4 -2
  63. package/dist/es2019/presets/recommended.codegen.js +2 -1
  64. package/dist/es2019/rules/index.codegen.js +7 -3
  65. package/dist/es2019/rules/no-html-anchor/index.js +33 -0
  66. package/dist/es2019/rules/no-html-anchor/node-types/index.js +2 -0
  67. package/dist/es2019/rules/no-html-anchor/node-types/jsx-element/index.js +20 -0
  68. package/dist/es2019/rules/no-html-anchor/node-types/styled-component/get-styled-component-call.js +42 -0
  69. package/dist/es2019/rules/no-html-anchor/node-types/styled-component/index.js +32 -0
  70. package/dist/es2019/rules/no-html-anchor/node-types/supported.js +56 -0
  71. package/dist/es2019/rules/no-html-anchor/utils/get-jsx-element-by-name.js +39 -0
  72. package/dist/es2019/rules/no-html-button/index.js +33 -0
  73. package/dist/es2019/rules/no-html-button/node-types/index.js +2 -0
  74. package/dist/es2019/rules/no-html-button/node-types/jsx-element/index.js +20 -0
  75. package/dist/es2019/rules/no-html-button/node-types/styled-component/get-styled-component-call.js +42 -0
  76. package/dist/es2019/rules/no-html-button/node-types/styled-component/index.js +32 -0
  77. package/dist/es2019/rules/no-html-button/node-types/supported.js +69 -0
  78. package/dist/es2019/rules/no-html-button/utils/get-jsx-element-by-name.js +39 -0
  79. package/dist/es2019/rules/use-popup-label/index.js +80 -0
  80. package/dist/esm/common/token-maps.partial.js +42 -0
  81. package/dist/esm/index.codegen.js +1 -1
  82. package/dist/esm/presets/all.codegen.js +4 -2
  83. package/dist/esm/presets/recommended.codegen.js +2 -1
  84. package/dist/esm/rules/index.codegen.js +7 -3
  85. package/dist/esm/rules/no-html-anchor/index.js +33 -0
  86. package/dist/esm/rules/no-html-anchor/node-types/index.js +2 -0
  87. package/dist/esm/rules/no-html-anchor/node-types/jsx-element/index.js +19 -0
  88. package/dist/esm/rules/no-html-anchor/node-types/styled-component/get-styled-component-call.js +42 -0
  89. package/dist/esm/rules/no-html-anchor/node-types/styled-component/index.js +31 -0
  90. package/dist/esm/rules/no-html-anchor/node-types/supported.js +57 -0
  91. package/dist/esm/rules/no-html-anchor/utils/get-jsx-element-by-name.js +47 -0
  92. package/dist/esm/rules/no-html-button/index.js +33 -0
  93. package/dist/esm/rules/no-html-button/node-types/index.js +2 -0
  94. package/dist/esm/rules/no-html-button/node-types/jsx-element/index.js +19 -0
  95. package/dist/esm/rules/no-html-button/node-types/styled-component/get-styled-component-call.js +42 -0
  96. package/dist/esm/rules/no-html-button/node-types/styled-component/index.js +31 -0
  97. package/dist/esm/rules/no-html-button/node-types/supported.js +70 -0
  98. package/dist/esm/rules/no-html-button/utils/get-jsx-element-by-name.js +47 -0
  99. package/dist/esm/rules/use-popup-label/index.js +84 -0
  100. package/dist/types/common/token-maps.partial.d.ts +65 -0
  101. package/dist/types/index.codegen.d.ts +4 -1
  102. package/dist/types/presets/all.codegen.d.ts +4 -2
  103. package/dist/types/presets/recommended.codegen.d.ts +2 -1
  104. package/dist/types/rules/index.codegen.d.ts +3 -1
  105. package/dist/types/rules/no-html-anchor/index.d.ts +3 -0
  106. package/dist/types/rules/no-html-anchor/node-types/index.d.ts +2 -0
  107. package/dist/types/rules/no-html-anchor/node-types/jsx-element/index.d.ts +8 -0
  108. package/dist/types/rules/no-html-anchor/node-types/styled-component/get-styled-component-call.d.ts +6 -0
  109. package/dist/types/rules/no-html-anchor/node-types/styled-component/index.d.ts +8 -0
  110. package/dist/types/rules/no-html-anchor/node-types/supported.d.ts +7 -0
  111. package/dist/types/rules/no-html-anchor/utils/get-jsx-element-by-name.d.ts +6 -0
  112. package/dist/types/rules/no-html-button/index.d.ts +3 -0
  113. package/dist/types/rules/no-html-button/node-types/index.d.ts +2 -0
  114. package/dist/types/rules/no-html-button/node-types/jsx-element/index.d.ts +8 -0
  115. package/dist/types/rules/no-html-button/node-types/styled-component/get-styled-component-call.d.ts +6 -0
  116. package/dist/types/rules/no-html-button/node-types/styled-component/index.d.ts +8 -0
  117. package/dist/types/rules/no-html-button/node-types/supported.d.ts +7 -0
  118. package/dist/types/rules/no-html-button/utils/get-jsx-element-by-name.d.ts +6 -0
  119. package/dist/types/rules/use-popup-label/index.d.ts +3 -0
  120. package/dist/types/rules/use-tokens-typography/utils.d.ts +0 -33
  121. package/dist/types-ts4.5/common/token-maps.partial.d.ts +65 -0
  122. package/dist/types-ts4.5/index.codegen.d.ts +4 -1
  123. package/dist/types-ts4.5/presets/all.codegen.d.ts +4 -2
  124. package/dist/types-ts4.5/presets/recommended.codegen.d.ts +2 -1
  125. package/dist/types-ts4.5/rules/index.codegen.d.ts +3 -1
  126. package/dist/types-ts4.5/rules/no-html-anchor/node-types/index.d.ts +2 -0
  127. package/dist/types-ts4.5/rules/no-html-anchor/node-types/jsx-element/index.d.ts +8 -0
  128. package/dist/types-ts4.5/rules/no-html-anchor/node-types/styled-component/get-styled-component-call.d.ts +6 -0
  129. package/dist/types-ts4.5/rules/no-html-anchor/node-types/styled-component/index.d.ts +8 -0
  130. package/dist/types-ts4.5/rules/no-html-anchor/node-types/supported.d.ts +7 -0
  131. package/dist/types-ts4.5/rules/no-html-anchor/utils/get-jsx-element-by-name.d.ts +6 -0
  132. package/dist/types-ts4.5/rules/no-html-button/node-types/index.d.ts +2 -0
  133. package/dist/types-ts4.5/rules/no-html-button/node-types/jsx-element/index.d.ts +8 -0
  134. package/dist/types-ts4.5/rules/no-html-button/node-types/styled-component/get-styled-component-call.d.ts +6 -0
  135. package/dist/types-ts4.5/rules/no-html-button/node-types/styled-component/index.d.ts +8 -0
  136. package/dist/types-ts4.5/rules/no-html-button/node-types/supported.d.ts +7 -0
  137. package/dist/types-ts4.5/rules/no-html-button/utils/get-jsx-element-by-name.d.ts +6 -0
  138. package/dist/types-ts4.5/rules/use-popup-label/index.d.ts +3 -0
  139. package/dist/types-ts4.5/rules/use-tokens-typography/utils.d.ts +0 -33
  140. package/package.json +4 -3
  141. package/constellation/no-html-button-element/usage.mdx +0 -26
  142. package/dist/cjs/rules/no-html-button-element/index.js +0 -107
  143. package/dist/cjs/rules/no-html-button-element/utils.js +0 -18
  144. package/dist/es2019/rules/no-html-button-element/index.js +0 -101
  145. package/dist/es2019/rules/no-html-button-element/utils.js +0 -12
  146. package/dist/esm/rules/no-html-button-element/index.js +0 -101
  147. package/dist/esm/rules/no-html-button-element/utils.js +0 -12
  148. package/dist/types/rules/no-html-button-element/utils.d.ts +0 -2
  149. package/dist/types-ts4.5/rules/no-html-button-element/utils.d.ts +0 -2
  150. /package/dist/types-ts4.5/rules/{no-html-button-element → no-html-anchor}/index.d.ts +0 -0
  151. /package/dist/{types/rules/no-html-button-element → types-ts4.5/rules/no-html-button}/index.d.ts +0 -0
@@ -0,0 +1,65 @@
1
+ /**
2
+ * THIS SECTION WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
3
+ * @codegen <<SignedSource::30c84f908843af1f250860b6f3deeea0>>
4
+ * @codegenId spacing
5
+ * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen-token-maps
6
+ * @codegenDependency ../../../tokens/src/artifacts/tokens-raw/atlassian-spacing.tsx <<SignedSource::55622b91aca9b3afac4bce440f222b71>>
7
+ */
8
+ export declare const positiveSpaceMap: {
9
+ '0px': string;
10
+ '2px': string;
11
+ '4px': string;
12
+ '6px': string;
13
+ '8px': string;
14
+ '12px': string;
15
+ '16px': string;
16
+ '20px': string;
17
+ '24px': string;
18
+ '32px': string;
19
+ '40px': string;
20
+ '48px': string;
21
+ '64px': string;
22
+ '80px': string;
23
+ };
24
+ export type Space = keyof typeof positiveSpaceMap;
25
+ export declare const negativeSpaceMap: {
26
+ '-2px': string;
27
+ '-4px': string;
28
+ '-6px': string;
29
+ '-8px': string;
30
+ '-12px': string;
31
+ '-16px': string;
32
+ '-20px': string;
33
+ '-24px': string;
34
+ '-32px': string;
35
+ };
36
+ export type NegativeSpace = keyof typeof negativeSpaceMap;
37
+ export declare const allSpaceMap: {
38
+ '-2px': string;
39
+ '-4px': string;
40
+ '-6px': string;
41
+ '-8px': string;
42
+ '-12px': string;
43
+ '-16px': string;
44
+ '-20px': string;
45
+ '-24px': string;
46
+ '-32px': string;
47
+ '0px': string;
48
+ '2px': string;
49
+ '4px': string;
50
+ '6px': string;
51
+ '8px': string;
52
+ '12px': string;
53
+ '16px': string;
54
+ '20px': string;
55
+ '24px': string;
56
+ '32px': string;
57
+ '40px': string;
58
+ '48px': string;
59
+ '64px': string;
60
+ '80px': string;
61
+ };
62
+ export type AllSpace = keyof typeof allSpaceMap;
63
+ /**
64
+ * @codegenEnd
65
+ */
@@ -16,7 +16,8 @@ export declare const configs: {
16
16
  '@atlaskit/design-system/no-empty-styled-expression': string;
17
17
  '@atlaskit/design-system/no-exported-css': string;
18
18
  '@atlaskit/design-system/no-exported-keyframes': string;
19
- '@atlaskit/design-system/no-html-button-element': string;
19
+ '@atlaskit/design-system/no-html-anchor': string;
20
+ '@atlaskit/design-system/no-html-button': string;
20
21
  '@atlaskit/design-system/no-invalid-css-map': string;
21
22
  '@atlaskit/design-system/no-keyframes-tagged-template-expression': string;
22
23
  '@atlaskit/design-system/no-margin': string;
@@ -32,6 +33,7 @@ export declare const configs: {
32
33
  '@atlaskit/design-system/use-heading': string;
33
34
  '@atlaskit/design-system/use-heading-level-in-spotlight-card': string;
34
35
  '@atlaskit/design-system/use-href-in-link-item': string;
36
+ '@atlaskit/design-system/use-popup-label': string;
35
37
  '@atlaskit/design-system/use-primitives': string;
36
38
  '@atlaskit/design-system/use-primitives-text': string;
37
39
  '@atlaskit/design-system/use-tokens-space': string;
@@ -62,6 +64,7 @@ export declare const configs: {
62
64
  '@atlaskit/design-system/use-drawer-label': string;
63
65
  '@atlaskit/design-system/use-heading-level-in-spotlight-card': string;
64
66
  '@atlaskit/design-system/use-href-in-link-item': string;
67
+ '@atlaskit/design-system/use-popup-label': string;
65
68
  '@atlaskit/design-system/use-visually-hidden': string;
66
69
  };
67
70
  };
@@ -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::1ab11547db880eba1206f334a9b2150f>>
3
+ * @codegen <<SignedSource::0be7639a95bf4c9bbfe00154d8193477>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  declare const _default: {
@@ -19,7 +19,8 @@ declare const _default: {
19
19
  '@atlaskit/design-system/no-empty-styled-expression': string;
20
20
  '@atlaskit/design-system/no-exported-css': string;
21
21
  '@atlaskit/design-system/no-exported-keyframes': string;
22
- '@atlaskit/design-system/no-html-button-element': string;
22
+ '@atlaskit/design-system/no-html-anchor': string;
23
+ '@atlaskit/design-system/no-html-button': string;
23
24
  '@atlaskit/design-system/no-invalid-css-map': string;
24
25
  '@atlaskit/design-system/no-keyframes-tagged-template-expression': string;
25
26
  '@atlaskit/design-system/no-margin': string;
@@ -35,6 +36,7 @@ declare const _default: {
35
36
  '@atlaskit/design-system/use-heading': string;
36
37
  '@atlaskit/design-system/use-heading-level-in-spotlight-card': string;
37
38
  '@atlaskit/design-system/use-href-in-link-item': string;
39
+ '@atlaskit/design-system/use-popup-label': string;
38
40
  '@atlaskit/design-system/use-primitives': string;
39
41
  '@atlaskit/design-system/use-primitives-text': string;
40
42
  '@atlaskit/design-system/use-tokens-space': 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::05b4fe8f97edc4f7e46ded52b4917037>>
3
+ * @codegen <<SignedSource::73a3666b244b58cc221eebcda071161d>>
4
4
  * @codegenCommand yarn workspace @atlaskit/eslint-plugin-design-system codegen
5
5
  */
6
6
  declare const _default: {
@@ -26,6 +26,7 @@ declare const _default: {
26
26
  '@atlaskit/design-system/use-drawer-label': string;
27
27
  '@atlaskit/design-system/use-heading-level-in-spotlight-card': string;
28
28
  '@atlaskit/design-system/use-href-in-link-item': string;
29
+ '@atlaskit/design-system/use-popup-label': string;
29
30
  '@atlaskit/design-system/use-visually-hidden': string;
30
31
  };
31
32
  };
@@ -20,7 +20,8 @@ declare const _default: {
20
20
  'no-empty-styled-expression': import("eslint").Rule.RuleModule;
21
21
  'no-exported-css': import("eslint").Rule.RuleModule;
22
22
  'no-exported-keyframes': import("eslint").Rule.RuleModule;
23
- 'no-html-button-element': import("eslint").Rule.RuleModule;
23
+ 'no-html-anchor': import("eslint").Rule.RuleModule;
24
+ 'no-html-button': import("eslint").Rule.RuleModule;
24
25
  'no-invalid-css-map': import("eslint").Rule.RuleModule;
25
26
  'no-keyframes-tagged-template-expression': import("eslint").Rule.RuleModule;
26
27
  'no-margin': import("eslint").Rule.RuleModule;
@@ -36,6 +37,7 @@ declare const _default: {
36
37
  'use-heading': import("eslint").Rule.RuleModule;
37
38
  'use-heading-level-in-spotlight-card': import("eslint").Rule.RuleModule;
38
39
  'use-href-in-link-item': import("eslint").Rule.RuleModule;
40
+ 'use-popup-label': import("eslint").Rule.RuleModule;
39
41
  'use-primitives': import("eslint").Rule.RuleModule;
40
42
  'use-primitives-text': import("eslint").Rule.RuleModule;
41
43
  'use-tokens-space': import("eslint").Rule.RuleModule;
@@ -0,0 +1,2 @@
1
+ export { StyledComponent } from './styled-component';
2
+ export { JSXElement } from './jsx-element';
@@ -0,0 +1,8 @@
1
+ import type { Rule } from 'eslint';
2
+ interface MetaData {
3
+ context: Rule.RuleContext;
4
+ }
5
+ export declare const JSXElement: {
6
+ lint(node: Rule.Node, { context }: MetaData): void;
7
+ };
8
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { Rule } from 'eslint';
2
+ import { type VariableDeclarator } from 'eslint-codemod-utils';
3
+ /**
4
+ * Returns a styled component
5
+ */
6
+ export declare const getStyledComponentCall: (node: Rule.Node) => (VariableDeclarator & Rule.NodeParentExtension) | undefined;
@@ -0,0 +1,8 @@
1
+ import type { Rule } from 'eslint';
2
+ interface MetaData {
3
+ context: Rule.RuleContext;
4
+ }
5
+ export declare const StyledComponent: {
6
+ lint(node: Rule.Node, { context }: MetaData): void;
7
+ };
8
+ export {};
@@ -0,0 +1,7 @@
1
+ import { type EslintNode } from 'eslint-codemod-utils';
2
+ /**
3
+ * Determines if the given JSX element is a supported element to lint with this rule.
4
+ */
5
+ export declare function isSupportedForLint(jsxNode: EslintNode, elementName?: string): jsxNode is Extract<EslintNode, {
6
+ type: 'JSXElement';
7
+ }>;
@@ -0,0 +1,6 @@
1
+ import type { Rule, Scope } from 'eslint';
2
+ import { type JSXOpeningElement } from 'eslint-codemod-utils';
3
+ /**
4
+ * Given a component name finds its JSX usage
5
+ */
6
+ export declare const getJsxElementByName: (componentName: string, scope: Scope.Scope) => (JSXOpeningElement & Rule.NodeParentExtension) | undefined;
@@ -0,0 +1,2 @@
1
+ export { StyledComponent } from './styled-component';
2
+ export { JSXElement } from './jsx-element';
@@ -0,0 +1,8 @@
1
+ import type { Rule } from 'eslint';
2
+ interface MetaData {
3
+ context: Rule.RuleContext;
4
+ }
5
+ export declare const JSXElement: {
6
+ lint(node: Rule.Node, { context }: MetaData): void;
7
+ };
8
+ export {};
@@ -0,0 +1,6 @@
1
+ import type { Rule } from 'eslint';
2
+ import { type VariableDeclarator } from 'eslint-codemod-utils';
3
+ /**
4
+ * Returns a styled component
5
+ */
6
+ export declare const getStyledComponentCall: (node: Rule.Node) => (VariableDeclarator & Rule.NodeParentExtension) | undefined;
@@ -0,0 +1,8 @@
1
+ import type { Rule } from 'eslint';
2
+ interface MetaData {
3
+ context: Rule.RuleContext;
4
+ }
5
+ export declare const StyledComponent: {
6
+ lint(node: Rule.Node, { context }: MetaData): void;
7
+ };
8
+ export {};
@@ -0,0 +1,7 @@
1
+ import { type EslintNode } from 'eslint-codemod-utils';
2
+ /**
3
+ * Determines if the given JSX element is a supported element to lint with this rule.
4
+ */
5
+ export declare function isSupportedForLint(jsxNode: EslintNode, elementName?: string): jsxNode is Extract<EslintNode, {
6
+ type: 'JSXElement';
7
+ }>;
@@ -0,0 +1,6 @@
1
+ import type { Rule, Scope } from 'eslint';
2
+ import { type JSXOpeningElement } from 'eslint-codemod-utils';
3
+ /**
4
+ * Given a component name finds its JSX usage
5
+ */
6
+ export declare const getJsxElementByName: (componentName: string, scope: Scope.Scope) => (JSXOpeningElement & Rule.NodeParentExtension) | undefined;
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ declare const rule: Rule.RuleModule;
3
+ export default rule;
@@ -127,39 +127,6 @@ export declare const fontFamilyTokens: ({
127
127
  name: string;
128
128
  path: string[];
129
129
  cleanName: string;
130
- } | {
131
- attributes: {
132
- group: string;
133
- state: string;
134
- introduced: string;
135
- deprecated: string;
136
- description: string;
137
- responsiveSmallerVariant?: undefined;
138
- };
139
- value: string;
140
- filePath: string;
141
- isSource: boolean;
142
- original: {
143
- attributes: {
144
- group: string;
145
- state: string;
146
- introduced: string;
147
- deprecated: string;
148
- description: string;
149
- responsiveSmallerVariant?: undefined;
150
- };
151
- value: {
152
- fontWeight: string;
153
- fontSize: string;
154
- lineHeight: string;
155
- fontFamily: string;
156
- fontStyle: string;
157
- letterSpacing: string;
158
- };
159
- };
160
- name: string;
161
- path: string[];
162
- cleanName: string;
163
130
  } | {
164
131
  attributes: {
165
132
  group: string;
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": "9.6.0",
4
+ "version": "10.0.0",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
7
7
  "publishConfig": {
@@ -53,6 +53,7 @@
53
53
  "semver": "^7.5.2"
54
54
  },
55
55
  "devDependencies": {
56
+ "@af/formatting": "*",
56
57
  "@atlaskit/ds-lib": "^2.3.0",
57
58
  "@atlaskit/theme": "^12.7.0",
58
59
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
@@ -66,7 +67,6 @@
66
67
  "eslint": "^8.49.0",
67
68
  "jscodeshift": "^0.13.0",
68
69
  "outdent": "^0.5.0",
69
- "prettier": "^2.8.0",
70
70
  "react": "^16.8.0",
71
71
  "ts-jest": "26.5.6",
72
72
  "ts-node": "^10.9.1",
@@ -75,7 +75,8 @@
75
75
  },
76
76
  "scripts": {
77
77
  "ak-postbuild": "cp -r configs dist",
78
- "codegen": "ts-node -r tsconfig-paths/register ./scripts/codegen.tsx"
78
+ "codegen": "ts-node -r tsconfig-paths/register ./scripts/codegen.tsx",
79
+ "codegen-token-maps": "ts-node -r tsconfig-paths/register ./scripts/token-maps/codegen-token-maps.tsx"
79
80
  },
80
81
  "techstack": {
81
82
  "@atlassian/frontend": {
@@ -1,26 +0,0 @@
1
- # no-html-button-element
2
-
3
- HTML `<button>` elements should not be used. They can be replaced using the Button component or the Pressable primitive, which are ready made solutions made by the Atlassian Design System Team. This benefits analytics as they are fitted with tracking by default and provide safe access to design tokens for styling.
4
-
5
- ## Examples
6
-
7
- This rule marks code as violations when it can be replaced with either a Button component or a Pressable primitive.
8
-
9
- ### Incorrect
10
-
11
- ```js
12
- <button>Click me</button>
13
- ^^^^^^^^^^^^^^^^^^^^^^^^^
14
- ```
15
-
16
- ### Correct
17
-
18
- ```js
19
- <Button>Click me</Button>
20
- ^^^^^^^^^^^^^^^^^^^^^^^^^
21
- ```
22
-
23
- ```js
24
- <Pressable>Click me</Pressable>
25
- ^^^^^^^^^^^^^^^^^^^^^^^^^
26
- ```
@@ -1,107 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- var _eslintCodemodUtils = require("eslint-codemod-utils");
8
- var _createRule = require("../utils/create-rule");
9
- var _utils = require("./utils");
10
- // eslint-disable-next-line import/no-extraneous-dependencies
11
-
12
- var buttonDocsUrl = 'https://atlassian.design/components/button';
13
- var pressableDocsUrl = 'https://atlassian.design/components/primitives/pressable/';
14
- var rule = (0, _createRule.createLintRule)({
15
- meta: {
16
- name: 'no-html-button-element',
17
- type: 'suggestion',
18
- hasSuggestions: false,
19
- docs: {
20
- description: 'Prevent direct usage of HTML button elements and enforce usage of Button and Pressable.',
21
- recommended: false,
22
- severity: 'warn'
23
- },
24
- messages: {
25
- noHtmlButtonElement: "This \"{{element}}\" should be replaced with a Button component. If beyond the capabilities of the Button component, use the Pressable primitive. See ".concat(buttonDocsUrl, " and ").concat(pressableDocsUrl, " for guidance.")
26
- }
27
- },
28
- create: function create(context) {
29
- return {
30
- // Look for <button> HTML elements
31
- // Look for styled calls/templates - styled.button(...)
32
- JSXOpeningElement: function JSXOpeningElement(node) {
33
- if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'JSXOpeningElement')) {
34
- return;
35
- }
36
- if (!(0, _eslintCodemodUtils.isNodeOfType)(node.name, 'JSXIdentifier')) {
37
- return;
38
- }
39
- var suggest = (0, _utils.shouldSuggest)(node === null || node === void 0 ? void 0 : node.parent);
40
- if (suggest) {
41
- context.report({
42
- node: node,
43
- messageId: 'noHtmlButtonElement',
44
- data: {
45
- element: node.name.name
46
- }
47
- });
48
- }
49
- },
50
- // styled.button`` | styled2.button`` | styled.button()
51
- 'MemberExpression[object.name="styled"],MemberExpression[object.name="styled2"]': function MemberExpressionObjectNameStyledMemberExpressionObjectNameStyled2(node) {
52
- if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'MemberExpression')) {
53
- return;
54
- }
55
-
56
- // styled.button``
57
- if ((0, _eslintCodemodUtils.isNodeOfType)(node.property, 'Identifier')) {
58
- if (node.property.name === 'button') {
59
- var styledIdentifier = node.object.name;
60
- var elementName = node.property.name;
61
-
62
- // Including the `styled.` portion in the message to help makers understand it's not just the `button` element that should be replaced
63
- var reportName = "".concat(styledIdentifier, ".").concat(elementName); // styled.button
64
-
65
- context.report({
66
- node: node,
67
- messageId: 'noHtmlButtonElement',
68
- data: {
69
- element: reportName
70
- }
71
- });
72
- }
73
- }
74
- },
75
- // styled(X)``
76
- 'CallExpression[callee.name="styled"]': function CallExpressionCalleeNameStyled(node) {
77
- if (!(0, _eslintCodemodUtils.isNodeOfType)(node, 'CallExpression')) {
78
- return;
79
- }
80
-
81
- // styled('button')`` - We only care about 'button', ignore extending other components
82
- if ((0, _eslintCodemodUtils.isNodeOfType)(node.arguments[0], 'Literal')) {
83
- var argValue = node.arguments[0].raw;
84
- if (typeof argValue === 'string') {
85
- var suggest = argValue.replaceAll("'", '') === 'button';
86
- if (suggest) {
87
- var styledIdentifier = node.callee.name;
88
- var elementName = argValue;
89
-
90
- // Including the `styled()` portion in the message to help makers understand it's not just the `button` element that should be replaced
91
- var reportName = "".concat(styledIdentifier, "(").concat(elementName, ")"); // styled('button')
92
-
93
- context.report({
94
- node: node,
95
- messageId: 'noHtmlButtonElement',
96
- data: {
97
- element: reportName
98
- }
99
- });
100
- }
101
- }
102
- }
103
- }
104
- };
105
- }
106
- });
107
- var _default = exports.default = rule;
@@ -1,18 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.shouldSuggest = void 0;
7
- var isButtonHtmlElement = function isButtonHtmlElement(node) {
8
- return node.openingElement.name.name === 'button';
9
- };
10
- var shouldSuggest = exports.shouldSuggest = function shouldSuggest(node) {
11
- if (!node) {
12
- return false;
13
- }
14
- if (!isButtonHtmlElement(node)) {
15
- return false;
16
- }
17
- return true;
18
- };
@@ -1,101 +0,0 @@
1
- // eslint-disable-next-line import/no-extraneous-dependencies
2
-
3
- import { isNodeOfType } from 'eslint-codemod-utils';
4
- import { createLintRule } from '../utils/create-rule';
5
- import { shouldSuggest } from './utils';
6
- const buttonDocsUrl = 'https://atlassian.design/components/button';
7
- const pressableDocsUrl = 'https://atlassian.design/components/primitives/pressable/';
8
- const rule = createLintRule({
9
- meta: {
10
- name: 'no-html-button-element',
11
- type: 'suggestion',
12
- hasSuggestions: false,
13
- docs: {
14
- description: 'Prevent direct usage of HTML button elements and enforce usage of Button and Pressable.',
15
- recommended: false,
16
- severity: 'warn'
17
- },
18
- messages: {
19
- noHtmlButtonElement: `This "{{element}}" should be replaced with a Button component. If beyond the capabilities of the Button component, use the Pressable primitive. See ${buttonDocsUrl} and ${pressableDocsUrl} for guidance.`
20
- }
21
- },
22
- create(context) {
23
- return {
24
- // Look for <button> HTML elements
25
- // Look for styled calls/templates - styled.button(...)
26
- JSXOpeningElement(node) {
27
- if (!isNodeOfType(node, 'JSXOpeningElement')) {
28
- return;
29
- }
30
- if (!isNodeOfType(node.name, 'JSXIdentifier')) {
31
- return;
32
- }
33
- const suggest = shouldSuggest(node === null || node === void 0 ? void 0 : node.parent);
34
- if (suggest) {
35
- context.report({
36
- node: node,
37
- messageId: 'noHtmlButtonElement',
38
- data: {
39
- element: node.name.name
40
- }
41
- });
42
- }
43
- },
44
- // styled.button`` | styled2.button`` | styled.button()
45
- 'MemberExpression[object.name="styled"],MemberExpression[object.name="styled2"]': node => {
46
- if (!isNodeOfType(node, 'MemberExpression')) {
47
- return;
48
- }
49
-
50
- // styled.button``
51
- if (isNodeOfType(node.property, 'Identifier')) {
52
- if (node.property.name === 'button') {
53
- const styledIdentifier = node.object.name;
54
- const elementName = node.property.name;
55
-
56
- // Including the `styled.` portion in the message to help makers understand it's not just the `button` element that should be replaced
57
- const reportName = `${styledIdentifier}.${elementName}`; // styled.button
58
-
59
- context.report({
60
- node: node,
61
- messageId: 'noHtmlButtonElement',
62
- data: {
63
- element: reportName
64
- }
65
- });
66
- }
67
- }
68
- },
69
- // styled(X)``
70
- 'CallExpression[callee.name="styled"]': node => {
71
- if (!isNodeOfType(node, 'CallExpression')) {
72
- return;
73
- }
74
-
75
- // styled('button')`` - We only care about 'button', ignore extending other components
76
- if (isNodeOfType(node.arguments[0], 'Literal')) {
77
- const argValue = node.arguments[0].raw;
78
- if (typeof argValue === 'string') {
79
- const suggest = argValue.replaceAll(`'`, '') === 'button';
80
- if (suggest) {
81
- const styledIdentifier = node.callee.name;
82
- const elementName = argValue;
83
-
84
- // Including the `styled()` portion in the message to help makers understand it's not just the `button` element that should be replaced
85
- const reportName = `${styledIdentifier}(${elementName})`; // styled('button')
86
-
87
- context.report({
88
- node: node,
89
- messageId: 'noHtmlButtonElement',
90
- data: {
91
- element: reportName
92
- }
93
- });
94
- }
95
- }
96
- }
97
- }
98
- };
99
- }
100
- });
101
- export default rule;
@@ -1,12 +0,0 @@
1
- const isButtonHtmlElement = node => {
2
- return node.openingElement.name.name === 'button';
3
- };
4
- export const shouldSuggest = node => {
5
- if (!node) {
6
- return false;
7
- }
8
- if (!isButtonHtmlElement(node)) {
9
- return false;
10
- }
11
- return true;
12
- };