@atlaskit/eslint-plugin-design-system 9.7.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 (144) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +6 -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 +4 -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 +5 -2
  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 +3 -2
  43. package/dist/cjs/presets/recommended.codegen.js +1 -1
  44. package/dist/cjs/rules/index.codegen.js +5 -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/es2019/common/token-maps.partial.js +42 -0
  60. package/dist/es2019/index.codegen.js +1 -1
  61. package/dist/es2019/presets/all.codegen.js +3 -2
  62. package/dist/es2019/presets/recommended.codegen.js +1 -1
  63. package/dist/es2019/rules/index.codegen.js +5 -3
  64. package/dist/es2019/rules/no-html-anchor/index.js +33 -0
  65. package/dist/es2019/rules/no-html-anchor/node-types/index.js +2 -0
  66. package/dist/es2019/rules/no-html-anchor/node-types/jsx-element/index.js +20 -0
  67. package/dist/es2019/rules/no-html-anchor/node-types/styled-component/get-styled-component-call.js +42 -0
  68. package/dist/es2019/rules/no-html-anchor/node-types/styled-component/index.js +32 -0
  69. package/dist/es2019/rules/no-html-anchor/node-types/supported.js +56 -0
  70. package/dist/es2019/rules/no-html-anchor/utils/get-jsx-element-by-name.js +39 -0
  71. package/dist/es2019/rules/no-html-button/index.js +33 -0
  72. package/dist/es2019/rules/no-html-button/node-types/index.js +2 -0
  73. package/dist/es2019/rules/no-html-button/node-types/jsx-element/index.js +20 -0
  74. package/dist/es2019/rules/no-html-button/node-types/styled-component/get-styled-component-call.js +42 -0
  75. package/dist/es2019/rules/no-html-button/node-types/styled-component/index.js +32 -0
  76. package/dist/es2019/rules/no-html-button/node-types/supported.js +69 -0
  77. package/dist/es2019/rules/no-html-button/utils/get-jsx-element-by-name.js +39 -0
  78. package/dist/esm/common/token-maps.partial.js +42 -0
  79. package/dist/esm/index.codegen.js +1 -1
  80. package/dist/esm/presets/all.codegen.js +3 -2
  81. package/dist/esm/presets/recommended.codegen.js +1 -1
  82. package/dist/esm/rules/index.codegen.js +5 -3
  83. package/dist/esm/rules/no-html-anchor/index.js +33 -0
  84. package/dist/esm/rules/no-html-anchor/node-types/index.js +2 -0
  85. package/dist/esm/rules/no-html-anchor/node-types/jsx-element/index.js +19 -0
  86. package/dist/esm/rules/no-html-anchor/node-types/styled-component/get-styled-component-call.js +42 -0
  87. package/dist/esm/rules/no-html-anchor/node-types/styled-component/index.js +31 -0
  88. package/dist/esm/rules/no-html-anchor/node-types/supported.js +57 -0
  89. package/dist/esm/rules/no-html-anchor/utils/get-jsx-element-by-name.js +47 -0
  90. package/dist/esm/rules/no-html-button/index.js +33 -0
  91. package/dist/esm/rules/no-html-button/node-types/index.js +2 -0
  92. package/dist/esm/rules/no-html-button/node-types/jsx-element/index.js +19 -0
  93. package/dist/esm/rules/no-html-button/node-types/styled-component/get-styled-component-call.js +42 -0
  94. package/dist/esm/rules/no-html-button/node-types/styled-component/index.js +31 -0
  95. package/dist/esm/rules/no-html-button/node-types/supported.js +70 -0
  96. package/dist/esm/rules/no-html-button/utils/get-jsx-element-by-name.js +47 -0
  97. package/dist/types/common/token-maps.partial.d.ts +65 -0
  98. package/dist/types/index.codegen.d.ts +2 -1
  99. package/dist/types/presets/all.codegen.d.ts +3 -2
  100. package/dist/types/presets/recommended.codegen.d.ts +1 -1
  101. package/dist/types/rules/index.codegen.d.ts +2 -1
  102. package/dist/types/rules/no-html-anchor/index.d.ts +3 -0
  103. package/dist/types/rules/no-html-anchor/node-types/index.d.ts +2 -0
  104. package/dist/types/rules/no-html-anchor/node-types/jsx-element/index.d.ts +8 -0
  105. package/dist/types/rules/no-html-anchor/node-types/styled-component/get-styled-component-call.d.ts +6 -0
  106. package/dist/types/rules/no-html-anchor/node-types/styled-component/index.d.ts +8 -0
  107. package/dist/types/rules/no-html-anchor/node-types/supported.d.ts +7 -0
  108. package/dist/types/rules/no-html-anchor/utils/get-jsx-element-by-name.d.ts +6 -0
  109. package/dist/types/rules/no-html-button/index.d.ts +3 -0
  110. package/dist/types/rules/no-html-button/node-types/index.d.ts +2 -0
  111. package/dist/types/rules/no-html-button/node-types/jsx-element/index.d.ts +8 -0
  112. package/dist/types/rules/no-html-button/node-types/styled-component/get-styled-component-call.d.ts +6 -0
  113. package/dist/types/rules/no-html-button/node-types/styled-component/index.d.ts +8 -0
  114. package/dist/types/rules/no-html-button/node-types/supported.d.ts +7 -0
  115. package/dist/types/rules/no-html-button/utils/get-jsx-element-by-name.d.ts +6 -0
  116. package/dist/types-ts4.5/common/token-maps.partial.d.ts +65 -0
  117. package/dist/types-ts4.5/index.codegen.d.ts +2 -1
  118. package/dist/types-ts4.5/presets/all.codegen.d.ts +3 -2
  119. package/dist/types-ts4.5/presets/recommended.codegen.d.ts +1 -1
  120. package/dist/types-ts4.5/rules/index.codegen.d.ts +2 -1
  121. package/dist/types-ts4.5/rules/no-html-anchor/node-types/index.d.ts +2 -0
  122. package/dist/types-ts4.5/rules/no-html-anchor/node-types/jsx-element/index.d.ts +8 -0
  123. package/dist/types-ts4.5/rules/no-html-anchor/node-types/styled-component/get-styled-component-call.d.ts +6 -0
  124. package/dist/types-ts4.5/rules/no-html-anchor/node-types/styled-component/index.d.ts +8 -0
  125. package/dist/types-ts4.5/rules/no-html-anchor/node-types/supported.d.ts +7 -0
  126. package/dist/types-ts4.5/rules/no-html-anchor/utils/get-jsx-element-by-name.d.ts +6 -0
  127. package/dist/types-ts4.5/rules/no-html-button/node-types/index.d.ts +2 -0
  128. package/dist/types-ts4.5/rules/no-html-button/node-types/jsx-element/index.d.ts +8 -0
  129. package/dist/types-ts4.5/rules/no-html-button/node-types/styled-component/get-styled-component-call.d.ts +6 -0
  130. package/dist/types-ts4.5/rules/no-html-button/node-types/styled-component/index.d.ts +8 -0
  131. package/dist/types-ts4.5/rules/no-html-button/node-types/supported.d.ts +7 -0
  132. package/dist/types-ts4.5/rules/no-html-button/utils/get-jsx-element-by-name.d.ts +6 -0
  133. package/package.json +3 -2
  134. package/constellation/no-html-button-element/usage.mdx +0 -26
  135. package/dist/cjs/rules/no-html-button-element/index.js +0 -107
  136. package/dist/cjs/rules/no-html-button-element/utils.js +0 -18
  137. package/dist/es2019/rules/no-html-button-element/index.js +0 -101
  138. package/dist/es2019/rules/no-html-button-element/utils.js +0 -12
  139. package/dist/esm/rules/no-html-button-element/index.js +0 -101
  140. package/dist/esm/rules/no-html-button-element/utils.js +0 -12
  141. package/dist/types/rules/no-html-button-element/utils.d.ts +0 -2
  142. package/dist/types-ts4.5/rules/no-html-button-element/utils.d.ts +0 -2
  143. /package/dist/types-ts4.5/rules/{no-html-button-element → no-html-anchor}/index.d.ts +0 -0
  144. /package/dist/{types/rules/no-html-button-element → types-ts4.5/rules/no-html-button}/index.d.ts +0 -0
@@ -4,7 +4,11 @@ Block the usage of web platform drag and drop functionality directly. Use Pragma
4
4
 
5
5
  ## Rationale
6
6
 
7
- The web platform has powerful drag and drop functionality built in. However, it is hard to be successful with web platform drag and drop due to bugs, inconsistencies and usage friction. Rather than leveraging the web platform API directly, the rule enforces the usage of [Pragmatic drag and drop](https://atlassian.design/components/pragmatic-drag-and-drop), which allows people to easily and successfully leverage web platform drag and drop.
7
+ The web platform has powerful drag and drop functionality built in. However, it is hard to be
8
+ successful with web platform drag and drop due to bugs, inconsistencies and usage friction. Rather
9
+ than leveraging the web platform API directly, the rule enforces the usage of
10
+ [Pragmatic drag and drop](https://atlassian.design/components/pragmatic-drag-and-drop), which allows
11
+ people to easily and successfully leverage web platform drag and drop.
8
12
 
9
13
  ## Examples
10
14
 
@@ -12,7 +16,8 @@ This rule marks direct usage of web platform drag events as violations.
12
16
 
13
17
  ### Incorrect
14
18
 
15
- Adding drag related event listeners on intrinsic `react` elements (eg `div`, `span`, `strong` and so on).
19
+ Adding drag related event listeners on intrinsic `react` elements (eg `div`, `span`, `strong` and so
20
+ on).
16
21
 
17
22
  ```tsx
18
23
  <div onDragStart={fn}>{children}</div>
@@ -71,7 +76,8 @@ window.addEventListener('dragend', fn);
71
76
  ^^^^^^^^^
72
77
  ```
73
78
 
74
- Binding drag related events using `bind()` from [bind-event-listener](https://github.com/alexreardon/bind-event-listener)
79
+ Binding drag related events using `bind()` from
80
+ [bind-event-listener](https://github.com/alexreardon/bind-event-listener)
75
81
 
76
82
  ```ts
77
83
  import {bind} from 'bind-event-listener';
@@ -92,7 +98,8 @@ bind(element, { type: 'dragend', listener: fn });
92
98
  ^^^^^^^^^
93
99
  ```
94
100
 
95
- Binding drag related events using `bindAll()` from [bind-event-listener](https://github.com/alexreardon/bind-event-listener)
101
+ Binding drag related events using `bindAll()` from
102
+ [bind-event-listener](https://github.com/alexreardon/bind-event-listener)
96
103
 
97
104
  ```ts
98
105
  import {bindAll} from 'bind-event-listener';
@@ -123,15 +130,17 @@ Leveraging Pragmatic drag and drop for web platform drag and drop.
123
130
  import { monitor } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
124
131
 
125
132
  monitor({
126
- onGenerateDragPreview: fn,
127
- onDragStart: fn,
128
- onDropTargetChange: fn,
129
- onDrag: fn,
130
- onDrop: fn,
133
+ onGenerateDragPreview: fn,
134
+ onDragStart: fn,
135
+ onDropTargetChange: fn,
136
+ onDrag: fn,
137
+ onDrop: fn,
131
138
  });
132
139
  ```
133
140
 
134
- > See the [Pragmatic drag and drop documentation](https://atlassian.design/components/pragmatic-drag-and-drop) for more information about it's usage.
141
+ > See the
142
+ > [Pragmatic drag and drop documentation](https://atlassian.design/components/pragmatic-drag-and-drop)
143
+ > for more information about it's usage.
135
144
 
136
145
  Using blocked JSX attributes on custom `react` components
137
146
 
@@ -1,8 +1,12 @@
1
1
  # no-empty-styled-expression
2
2
 
3
- Disallows/discourages passing empty arguments to any `styled` expression when using a CSS-in-JS library, including `@atlaskit/css`, `@compiled/react`, Emotion, and `styled-components`.
3
+ Disallows/discourages passing empty arguments to any `styled` expression when using a CSS-in-JS
4
+ library, including `@atlaskit/css`, `@compiled/react`, Emotion, and `styled-components`.
4
5
 
5
- If Compiled is used in the file, passing an empty object or no object at all causes Compiled to build extra `div/span` elements, as opposed to simply using a `div`. This leads to reduced performance and is greatly discouraged. If a wrapper is necessary, opt to use a `div` or wrap it in the empty React fragment `<> <YourComponentHere></YourComponentHere> </>`.
6
+ If Compiled is used in the file, passing an empty object or no object at all causes Compiled to
7
+ build extra `div/span` elements, as opposed to simply using a `div`. This leads to reduced
8
+ performance and is greatly discouraged. If a wrapper is necessary, opt to use a `div` or wrap it in
9
+ the empty React fragment `<> <YourComponentHere></YourComponentHere> </>`.
6
10
 
7
11
  ## Examples
8
12
 
@@ -20,10 +24,10 @@ const EmptyStyledExpressionArgument = styled.div([]);
20
24
 
21
25
  ```tsx
22
26
  const Wrapper = styled.div({
23
- backgroundColor: 'red',
24
- MyComponent: {
25
- backgroundColor: 'green',
26
- },
27
+ backgroundColor: 'red',
28
+ MyComponent: {
29
+ backgroundColor: 'green',
30
+ },
27
31
  });
28
32
  ```
29
33
 
@@ -57,15 +61,16 @@ const Wrapper = styled.div({
57
61
 
58
62
  By default, this rule will check `styled` usages from:
59
63
 
60
- - `@atlaskit/css`
61
- - `@atlaskit/primitives`
62
- - `@compiled/react`
63
- - `@emotion/react`
64
- - `@emotion/core`
65
- - `@emotion/styled`
66
- - `styled-components`
64
+ - `@atlaskit/css`
65
+ - `@atlaskit/primitives`
66
+ - `@compiled/react`
67
+ - `@emotion/react`
68
+ - `@emotion/core`
69
+ - `@emotion/styled`
70
+ - `styled-components`
67
71
 
68
- To change this list of libraries, you can define a custom set of `importSources`, which accepts an array of package names (strings).
72
+ To change this list of libraries, you can define a custom set of `importSources`, which accepts an
73
+ array of package names (strings).
69
74
 
70
75
  ```tsx
71
76
  // [{ importSources: ['other-lib'] }]
@@ -1,8 +1,12 @@
1
1
  # no-exported-css
2
2
 
3
- Disallows `css` export declarations that originate from a CSS-in-JS library, including `@atlaskit/css`, `@compiled/react`, Emotion, and `styled-components`.
3
+ Disallows `css` export declarations that originate from a CSS-in-JS library, including
4
+ `@atlaskit/css`, `@compiled/react`, Emotion, and `styled-components`.
4
5
 
5
- In Compiled (`@atlaskit/css` and `@compiled/react`), exporting `css` declarations may result in unexpected errors when imported, because its value will be `null` at runtime. Additionally, co-locating `css` definitions with their usage is considered best practice in order to improve code readability and build performance.
6
+ In Compiled (`@atlaskit/css` and `@compiled/react`), exporting `css` declarations may result in
7
+ unexpected errors when imported, because its value will be `null` at runtime. Additionally,
8
+ co-locating `css` definitions with their usage is considered best practice in order to improve code
9
+ readability and build performance.
6
10
 
7
11
  ## Examples
8
12
 
@@ -30,15 +34,16 @@ const styles = css({});
30
34
 
31
35
  By default, this rule will check `css` usages from:
32
36
 
33
- - `@atlaskit/css`
34
- - `@atlaskit/primitives`
35
- - `@compiled/react`
36
- - `@emotion/react`
37
- - `@emotion/core`
38
- - `@emotion/styled`
39
- - `styled-components`
37
+ - `@atlaskit/css`
38
+ - `@atlaskit/primitives`
39
+ - `@compiled/react`
40
+ - `@emotion/react`
41
+ - `@emotion/core`
42
+ - `@emotion/styled`
43
+ - `styled-components`
40
44
 
41
- To change this list of libraries, you can define a custom set of `importSources`, which accepts an array of package names (strings).
45
+ To change this list of libraries, you can define a custom set of `importSources`, which accepts an
46
+ array of package names (strings).
42
47
 
43
48
  ```tsx
44
49
  // [{ importSources: ['other-lib'] }]
@@ -1,8 +1,12 @@
1
1
  # no-exported-keyframes
2
2
 
3
- Disallows `keyframes` export declarations that originate from a CSS-in-JS library, including `@atlaskit/css`, `@compiled/react`, Emotion, and `styled-components`.
3
+ Disallows `keyframes` export declarations that originate from a CSS-in-JS library, including
4
+ `@atlaskit/css`, `@compiled/react`, Emotion, and `styled-components`.
4
5
 
5
- In Compiled (`@atlaskit/css` and `@compiled/react`), exporting `keyframes` declarations may result in unexpected errors when imported, because its value will be `null` at runtime. Additionally, co-locating `keyframes` definitions with their usage is considered best practice in order to improve code readability and build performance.
6
+ In Compiled (`@atlaskit/css` and `@compiled/react`), exporting `keyframes` declarations may result
7
+ in unexpected errors when imported, because its value will be `null` at runtime. Additionally,
8
+ co-locating `keyframes` definitions with their usage is considered best practice in order to improve
9
+ code readability and build performance.
6
10
 
7
11
  ## Examples
8
12
 
@@ -30,15 +34,16 @@ const animation = keyframes({});
30
34
 
31
35
  By default, this rule will check `keyframes` usages from:
32
36
 
33
- - `@atlaskit/css`
34
- - `@atlaskit/primitives`
35
- - `@compiled/react`
36
- - `@emotion/react`
37
- - `@emotion/core`
38
- - `@emotion/styled`
39
- - `styled-components`
37
+ - `@atlaskit/css`
38
+ - `@atlaskit/primitives`
39
+ - `@compiled/react`
40
+ - `@emotion/react`
41
+ - `@emotion/core`
42
+ - `@emotion/styled`
43
+ - `styled-components`
40
44
 
41
- To change this list of libraries, you can define a custom set of `importSources`, which accepts an array of package names (strings).
45
+ To change this list of libraries, you can define a custom set of `importSources`, which accepts an
46
+ array of package names (strings).
42
47
 
43
48
  ```tsx
44
49
  // [{ importSources: ['other-lib'] }]
@@ -0,0 +1,40 @@
1
+ # no-html-anchor
2
+
3
+ Don't use native HTML anchors. The Atlassian Design System provides ready-made link components that
4
+ include event tracking, automatic router configuration, ensure accessible implementations, and
5
+ provide access to ADS styling features like design tokens.
6
+
7
+ Use Atlassian Design System components such as the [Link](/components/link/) or
8
+ [LinkButton](/components/button/link-button/) components when suitable. There may also be other
9
+ components better-suited depending on the use case. If these components aren't suitable, use the
10
+ [Anchor primitive](/components/primitives/anchor/) which helps you build custom links with Atlassian
11
+ Design System styling.
12
+
13
+ ## Examples
14
+
15
+ This rule marks code as violations when it finds native HTML anchor elements.
16
+
17
+ ### Incorrect
18
+
19
+ ```jsx
20
+ <a href="/">
21
+ ^ Using a native HTML `<a>`
22
+ Hello, World!
23
+ </a>
24
+ ```
25
+
26
+ ### Correct
27
+
28
+ ```jsx
29
+ import Anchor from '@atlaskit/primitives/anchor';
30
+
31
+ <Anchor href="/">Hello, World!</Anchor>;
32
+
33
+ import Link from '@atlaskit/link';
34
+
35
+ <Link href="/">Hello, World!</Link>;
36
+
37
+ import { LinkButton } from '@atlaskit/button/new';
38
+
39
+ <LinkButton href="/">Hello, World!</LinkButton>;
40
+ ```
@@ -0,0 +1,52 @@
1
+ # no-html-button
2
+
3
+ Don't use native HTML buttons. The Atlassian Design System provides ready-made button components
4
+ that include event tracking, ensure accessible implementations, and provide access to ADS styling
5
+ features like design tokens.
6
+
7
+ Use Atlassian Design System components such as the [Button component](/components/button/) when
8
+ suitable. There may also be other components better-suited depending on the use case. If these
9
+ components aren't suitable, use the [Pressable primitive](/components/primitives/pressable/) which
10
+ helps you build custom buttons with Atlassian Design System styling.
11
+
12
+ ## Examples
13
+
14
+ This rule marks code as violations when it finds native HTML button elements.
15
+
16
+ ### Incorrect
17
+
18
+ ```jsx
19
+ <button>
20
+ ^^^^^^ Using a native HTML `<button>`
21
+ Hello, World!
22
+ </button>
23
+
24
+ <div role="button" tabIndex="0">
25
+ ^^^^^^^^^^^^^ Using `role="button"` to create buttons
26
+ Hello, World!
27
+ </div>
28
+
29
+ <input type="button" value="Button" />
30
+ ^^^^^^^^^^^^^ Using a `<input>` as a button
31
+
32
+ <input type="submit" value="Submit" />
33
+ ^^^^^^^^^^^^^ Using a `<input>` as a button
34
+
35
+ <input type="reset" value="Reset" />
36
+ ^^^^^^^^^^^^ Using a `<input>` as a button
37
+
38
+ <input type="image" alt="Submit" src="/submit-button.png" />
39
+ ^^^^^^^^^^^^ Using a `<input>` as a button
40
+ ```
41
+
42
+ ### Correct
43
+
44
+ ```jsx
45
+ import Pressable from '@atlaskit/primitives/pressable';
46
+
47
+ <Pressable>Hello, World!</Pressable>;
48
+
49
+ import Button from '@atlaskit/button/new';
50
+
51
+ <Button>Hello, World!</Button>;
52
+ ```
@@ -1,10 +1,14 @@
1
1
  # no-invalid-css-map
2
2
 
3
- Ensure that all usages of the `cssMap` API are valid, and enforces the format of the object that is passed to `cssMap`.
3
+ Ensure that all usages of the `cssMap` API are valid, and enforces the format of the object that is
4
+ passed to `cssMap`.
4
5
 
5
- Please refer to the [Compiled documentation](https://compiledcssinjs.com/docs/api-cssmap) for more details and some examples.
6
+ Please refer to the [Compiled documentation](https://compiledcssinjs.com/docs/api-cssmap) for more
7
+ details and some examples.
6
8
 
7
- Note that this version of the `no-invalid-css-map` rule differs from `@compiled/eslint-plugin/no-invalid-css-map` in that this will apply to both `@compiled/react` and `@atlaskit/css`.
9
+ Note that this version of the `no-invalid-css-map` rule differs from
10
+ `@compiled/eslint-plugin/no-invalid-css-map` in that this will apply to both `@compiled/react` and
11
+ `@atlaskit/css`.
8
12
 
9
13
  This is intended to be used in conjunction with type checking (through TypeScript).
10
14
 
@@ -20,11 +24,11 @@ import { cssMap } from '@compiled/react';
20
24
  // (not within a function, class, etc.)
21
25
 
22
26
  const Foo = () => {
23
- const bar = cssMap({
24
- danger: {
25
- color: 'red',
26
- },
27
- });
27
+ const bar = cssMap({
28
+ danger: {
29
+ color: 'red',
30
+ },
31
+ });
28
32
  };
29
33
  ```
30
34
 
@@ -38,11 +42,11 @@ import { importedVariable, importedFunction } from 'another-package';
38
42
  const myVariable = importedFunction();
39
43
 
40
44
  const styles = cssMap({
41
- danger: {
42
- // Both invalid because they rely on an imported function.
43
- color: myVariable,
44
- padding: importedFunction(),
45
- },
45
+ danger: {
46
+ // Both invalid because they rely on an imported function.
47
+ color: myVariable,
48
+ padding: importedFunction(),
49
+ },
46
50
  });
47
51
  ```
48
52
 
@@ -54,9 +58,9 @@ import { cssMap } from '@compiled/react';
54
58
  // Any usages of cssMap must be in the same file.
55
59
 
56
60
  export const foo = cssMap({
57
- danger: {
58
- color: 'red',
59
- },
61
+ danger: {
62
+ color: 'red',
63
+ },
60
64
  });
61
65
  ```
62
66
 
@@ -69,29 +73,29 @@ import { token } from '@atlaskit/tokens';
69
73
  // values in cssMap.
70
74
 
71
75
  const styles = cssMap({
72
- // Object method
73
- get danger() {
74
- return { color: '#123456' };
75
- },
76
+ // Object method
77
+ get danger() {
78
+ return { color: '#123456' };
79
+ },
76
80
  });
77
81
 
78
82
  const styles2 = cssMap({
79
- // Arrow function
80
- danger: () => {
81
- color: '#123456';
82
- },
83
+ // Arrow function
84
+ danger: () => {
85
+ color: '#123456';
86
+ },
83
87
  });
84
88
 
85
89
  function customFunction(...args) {
86
- return arguments.join('');
90
+ return arguments.join('');
87
91
  }
88
92
 
89
93
  const styles3 = cssMap({
90
- danger: {
91
- // Locally defined function
92
- color: customFunction('red', 'blue'),
93
- backgroundColor: 'red',
94
- },
94
+ danger: {
95
+ // Locally defined function
96
+ color: customFunction('red', 'blue'),
97
+ backgroundColor: 'red',
98
+ },
95
99
  });
96
100
  ```
97
101
 
@@ -102,16 +106,16 @@ import { cssMap } from '@compiled/react';
102
106
  // Spread elements ("...") cannot be used in cssMap.
103
107
 
104
108
  const base = {
105
- success: {
106
- color: 'green',
107
- },
109
+ success: {
110
+ color: 'green',
111
+ },
108
112
  };
109
113
 
110
114
  const bar = cssMap({
111
- ...base,
112
- danger: {
113
- color: 'red',
114
- },
115
+ ...base,
116
+ danger: {
117
+ color: 'red',
118
+ },
115
119
  });
116
120
  ```
117
121
 
@@ -125,14 +129,14 @@ import { cssMap } from '@compiled/react';
125
129
  // in cssMap.
126
130
 
127
131
  const styles = cssMap({
128
- danger: {
129
- color: 'red',
130
- backgroundColor: 'red',
131
- },
132
- success: {
133
- color: 'green',
134
- backgroundColor: 'green',
135
- },
132
+ danger: {
133
+ color: 'red',
134
+ backgroundColor: 'red',
135
+ },
136
+ success: {
137
+ color: 'green',
138
+ backgroundColor: 'green',
139
+ },
136
140
  });
137
141
  ```
138
142
 
@@ -146,9 +150,9 @@ import { cssMap } from '@compiled/react';
146
150
  const bap = 'blue';
147
151
 
148
152
  const styles = cssMap({
149
- danger: {
150
- color: bap,
151
- },
153
+ danger: {
154
+ color: bap,
155
+ },
152
156
  });
153
157
  ```
154
158
 
@@ -156,7 +160,8 @@ const styles = cssMap({
156
160
 
157
161
  #### `allowedFunctionCalls`: [string, string][]
158
162
 
159
- Normally, this ESLint rule forbids all function calls from being used inside the `cssMap(...)` function call. For example, this would be invalid using default settings:
163
+ Normally, this ESLint rule forbids all function calls from being used inside the `cssMap(...)`
164
+ function call. For example, this would be invalid using default settings:
160
165
 
161
166
  ```tsx
162
167
  import React from 'react';
@@ -164,17 +169,20 @@ import { cssMap } from '@compiled/react';
164
169
  import { token } from '@atlaskit/tokens';
165
170
 
166
171
  const styles = cssMap({
167
- danger: {
168
- color: token('my-color'),
169
- backgroundColor: 'red',
170
- },
171
- success: {
172
- color: 'green',
173
- },
172
+ danger: {
173
+ color: token('my-color'),
174
+ backgroundColor: 'red',
175
+ },
176
+ success: {
177
+ color: 'green',
178
+ },
174
179
  });
175
180
  ```
176
181
 
177
- If you would like to whitelist certain functions (e.g. `token` from `@atlaskit/tokens`), you can include the names of the functions as part of the `allowedFunctionCalls` argument. Each function should be represented as a two-element array, with the first element being the package the function is from, and the second element being the name of the function.
182
+ If you would like to whitelist certain functions (e.g. `token` from `@atlaskit/tokens`), you can
183
+ include the names of the functions as part of the `allowedFunctionCalls` argument. Each function
184
+ should be represented as a two-element array, with the first element being the package the function
185
+ is from, and the second element being the name of the function.
178
186
 
179
187
  For example, with the below configuration, the above code example would be okay.
180
188
 
@@ -196,4 +204,7 @@ For example, with the below configuration, the above code example would be okay.
196
204
  // ...
197
205
  ```
198
206
 
199
- Please note that this ESLint rule only supports whitelisting imports in the form `import { myFunctionOrVariable } from 'my-package'`; we do not currently support whitelisting default imports, so `import myFunctionOrVariable from 'my-package'` would always be invalid when used in `cssMap`.
207
+ Please note that this ESLint rule only supports whitelisting imports in the form
208
+ `import { myFunctionOrVariable } from 'my-package'`; we do not currently support whitelisting
209
+ default imports, so `import myFunctionOrVariable from 'my-package'` would always be invalid when
210
+ used in `cssMap`.
@@ -1,10 +1,15 @@
1
1
  # no-keyframes-tagged-template-expression
2
2
 
3
- Disallows any `keyframes` tagged template expressions that originate from a CSS-in-JS library, including `@atlaskit/css`, `@compiled/react`, Emotion, and `styled-components`.
3
+ Disallows any `keyframes` tagged template expressions that originate from a CSS-in-JS library,
4
+ including `@atlaskit/css`, `@compiled/react`, Emotion, and `styled-components`.
4
5
 
5
- Tagged template expressions are difficult to parse correctly (which can lead to more frequent build failures or invalid CSS generation), have limited type safety, and lack syntax highlighting. These problems can be avoided by using the preferred call expression syntax instead.
6
+ Tagged template expressions are difficult to parse correctly (which can lead to more frequent build
7
+ failures or invalid CSS generation), have limited type safety, and lack syntax highlighting. These
8
+ problems can be avoided by using the preferred call expression syntax instead.
6
9
 
7
- Thank you to the [Compiled team for their rule](https://github.com/atlassian-labs/compiled/tree/master/packages/eslint-plugin/src/rules/no-keyframes-tagged-template-expression) from which this was ported.
10
+ Thank you to the
11
+ [Compiled team for their rule](https://github.com/atlassian-labs/compiled/tree/master/packages/eslint-plugin/src/rules/no-keyframes-tagged-template-expression)
12
+ from which this was ported.
8
13
 
9
14
  The `--fix` option on the command line automatically fixes problems reported by this rule.
10
15
 
@@ -35,12 +40,12 @@ import { keyframes } from '@compiled/react';
35
40
  keyframes({ to: { opacity: 0 } });
36
41
 
37
42
  const fadeOut = keyframes({
38
- from: {
39
- opacity: 1,
40
- },
41
- to: {
42
- opacity: 0,
43
- },
43
+ from: {
44
+ opacity: 1,
45
+ },
46
+ to: {
47
+ opacity: 0,
48
+ },
44
49
  });
45
50
  ```
46
51
 
@@ -50,15 +55,16 @@ const fadeOut = keyframes({
50
55
 
51
56
  By default, this rule will check `keyframes` usages from:
52
57
 
53
- - `@atlaskit/css`
54
- - `@atlaskit/primitives`
55
- - `@compiled/react`
56
- - `@emotion/react`
57
- - `@emotion/core`
58
- - `@emotion/styled`
59
- - `styled-components`
58
+ - `@atlaskit/css`
59
+ - `@atlaskit/primitives`
60
+ - `@compiled/react`
61
+ - `@emotion/react`
62
+ - `@emotion/core`
63
+ - `@emotion/styled`
64
+ - `styled-components`
60
65
 
61
- To change this list of libraries, you can define a custom set of `importSources`, which accepts an array of package names (strings).
66
+ To change this list of libraries, you can define a custom set of `importSources`, which accepts an
67
+ array of package names (strings).
62
68
 
63
69
  ```tsx
64
70
  // [{ importSources: ['other-lib'] }]
@@ -71,4 +77,4 @@ export const animation = keyframes``;
71
77
 
72
78
  ## Limitations
73
79
 
74
- - Comments are not fixable
80
+ - Comments are not fixable
@@ -1,7 +1,8 @@
1
1
  # no-margin
2
2
 
3
- Using margins to define spacing results in components that can't be readily reused in other contexts breaking the composition model.
4
- Instead defining spacing in parents with flex and grid using the `gap` property will result in more resilient experiences.
3
+ Using margins to define spacing results in components that can't be readily reused in other contexts
4
+ breaking the composition model. Instead defining spacing in parents with flex and grid using the
5
+ `gap` property will result in more resilient experiences.
5
6
 
6
7
  ## Examples
7
8
 
@@ -1,27 +1,27 @@
1
1
  # no-nested-styles
2
2
 
3
- Disallows using nested styles. Nested styles can change unexpectedly when child markup changes and result in duplicates when extracting to CSS.
3
+ Disallows using nested styles. Nested styles can change unexpectedly when child markup changes and
4
+ result in duplicates when extracting to CSS.
4
5
 
5
6
  ## Examples
6
7
 
7
- This rule checks for nested styles inside `css` objects.
8
- This rule has no options.
8
+ This rule checks for nested styles inside `css` objects. This rule has no options.
9
9
 
10
10
  ### Incorrect
11
11
 
12
12
  ```js
13
13
  css({
14
- div: {
15
- color: 'red',
16
- },
14
+ div: {
15
+ color: 'red',
16
+ },
17
17
  });
18
18
  ```
19
19
 
20
20
  ```js
21
21
  css({
22
- '@media (min-width: 480px)': {
23
- color: 'red',
24
- },
22
+ '@media (min-width: 480px)': {
23
+ color: 'red',
24
+ },
25
25
  });
26
26
  ```
27
27
 
@@ -29,10 +29,10 @@ css({
29
29
 
30
30
  ```js
31
31
  css({
32
- color: 'red',
33
- ':hover': {
34
- color: 'black',
35
- },
32
+ color: 'red',
33
+ ':hover': {
34
+ color: 'black',
35
+ },
36
36
  });
37
37
  ```
38
38
 
@@ -40,8 +40,8 @@ css({
40
40
  import { media } from '@atlaskit/primitives';
41
41
 
42
42
  css({
43
- [media.above.xs]: {
44
- color: 'red',
45
- },
43
+ [media.above.xs]: {
44
+ color: 'red',
45
+ },
46
46
  });
47
47
  ```