@atlaskit/eslint-plugin-ui-styling-standard 0.18.0 → 0.18.1

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 (137) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +1 -1
  3. package/afm-cc/tsconfig.json +0 -28
  4. package/afm-jira/tsconfig.json +0 -27
  5. package/build/tsconfig.json +0 -18
  6. package/constellation/atlaskit-theme/usage.mdx +0 -132
  7. package/constellation/consistent-css-prop-usage/usage.mdx +0 -7
  8. package/constellation/convert-props-syntax/usage.mdx +0 -130
  9. package/constellation/enforce-style-prop/usage.mdx +0 -47
  10. package/constellation/index/migration-guide.mdx +0 -309
  11. package/constellation/index/overview.mdx +0 -250
  12. package/constellation/index/props.mdx +0 -30
  13. package/constellation/local-cx-xcss/usage.mdx +0 -53
  14. package/constellation/no-array-arguments/usage.mdx +0 -49
  15. package/constellation/no-classname-prop/usage.mdx +0 -49
  16. package/constellation/no-container-queries/usage.mdx +0 -101
  17. package/constellation/no-css-tagged-template-expression/usage.mdx +0 -8
  18. package/constellation/no-dynamic-styles/usage.mdx +0 -130
  19. package/constellation/no-empty-styled-expression/usage.mdx +0 -8
  20. package/constellation/no-exported-css/usage.mdx +0 -8
  21. package/constellation/no-exported-keyframes/usage.mdx +0 -8
  22. package/constellation/no-exported-styles/usage.mdx +0 -87
  23. package/constellation/no-global-styles/usage.mdx +0 -60
  24. package/constellation/no-important-styles/usage.mdx +0 -33
  25. package/constellation/no-imported-style-values/usage.mdx +0 -157
  26. package/constellation/no-invalid-css-map/usage.mdx +0 -8
  27. package/constellation/no-js-xcss/usage.mdx +0 -7
  28. package/constellation/no-keyframes-tagged-template-expression/usage.mdx +0 -8
  29. package/constellation/no-nested-selectors/usage.mdx +0 -95
  30. package/constellation/no-styled/usage.mdx +0 -92
  31. package/constellation/no-styled-tagged-template-expression/usage.mdx +0 -8
  32. package/constellation/no-suppress-xcss/usage.mdx +0 -28
  33. package/constellation/no-unsafe-selectors/usage.mdx +0 -370
  34. package/constellation/no-unsafe-values/usage.mdx +0 -318
  35. package/constellation/use-compiled/usage.mdx +0 -54
  36. package/index.js +0 -24
  37. package/scripts/codegen.tsx +0 -373
  38. package/src/index.codegen.tsx +0 -14
  39. package/src/index.tsx +0 -1
  40. package/src/presets/all.codegen.tsx +0 -79
  41. package/src/presets/recommended.codegen.tsx +0 -79
  42. package/src/rules/TEMPLATE.md +0 -29
  43. package/src/rules/__tests__/utils/_tester.tsx +0 -40
  44. package/src/rules/atlaskit-theme/README.md +0 -130
  45. package/src/rules/atlaskit-theme/__tests__/test.ts +0 -133
  46. package/src/rules/atlaskit-theme/index.ts +0 -134
  47. package/src/rules/convert-props-syntax/README.md +0 -128
  48. package/src/rules/convert-props-syntax/__tests__/invalid.test.tsx +0 -76
  49. package/src/rules/convert-props-syntax/__tests__/rule.test.tsx +0 -584
  50. package/src/rules/convert-props-syntax/__tests__/type-annotations.test.tsx +0 -140
  51. package/src/rules/convert-props-syntax/__tests__/unusual-properties.test.tsx +0 -69
  52. package/src/rules/convert-props-syntax/index.tsx +0 -414
  53. package/src/rules/enforce-style-prop/README.md +0 -45
  54. package/src/rules/enforce-style-prop/__tests__/rule.test.tsx +0 -243
  55. package/src/rules/enforce-style-prop/index.tsx +0 -172
  56. package/src/rules/external-rules.tsx +0 -177
  57. package/src/rules/index.codegen.tsx +0 -42
  58. package/src/rules/local-cx-xcss/README.md +0 -51
  59. package/src/rules/local-cx-xcss/__tests__/rule.test.tsx +0 -102
  60. package/src/rules/local-cx-xcss/index.tsx +0 -62
  61. package/src/rules/no-array-arguments/README.md +0 -47
  62. package/src/rules/no-array-arguments/__tests__/rule.test.tsx +0 -107
  63. package/src/rules/no-array-arguments/index.tsx +0 -86
  64. package/src/rules/no-classname-prop/README.md +0 -47
  65. package/src/rules/no-classname-prop/__tests__/rule.test.tsx +0 -39
  66. package/src/rules/no-classname-prop/index.tsx +0 -34
  67. package/src/rules/no-container-queries/README.md +0 -99
  68. package/src/rules/no-container-queries/__tests__/rule.test.tsx +0 -139
  69. package/src/rules/no-container-queries/index.tsx +0 -94
  70. package/src/rules/no-dynamic-styles/README.md +0 -128
  71. package/src/rules/no-dynamic-styles/__tests__/rule.test.tsx +0 -135
  72. package/src/rules/no-dynamic-styles/index.tsx +0 -60
  73. package/src/rules/no-exported-styles/README.md +0 -85
  74. package/src/rules/no-exported-styles/__tests__/rule.test.tsx +0 -216
  75. package/src/rules/no-exported-styles/index.tsx +0 -52
  76. package/src/rules/no-global-styles/README.md +0 -58
  77. package/src/rules/no-global-styles/__tests__/no-css-modules.test.tsx +0 -33
  78. package/src/rules/no-global-styles/__tests__/no-global-styles.test.tsx +0 -46
  79. package/src/rules/no-global-styles/index.tsx +0 -82
  80. package/src/rules/no-important-styles/README.md +0 -31
  81. package/src/rules/no-important-styles/__tests__/rule.test.tsx +0 -165
  82. package/src/rules/no-important-styles/index.tsx +0 -70
  83. package/src/rules/no-imported-style-values/README.md +0 -155
  84. package/src/rules/no-imported-style-values/__tests__/rule.test.tsx +0 -491
  85. package/src/rules/no-imported-style-values/index.tsx +0 -188
  86. package/src/rules/no-nested-selectors/README.md +0 -93
  87. package/src/rules/no-nested-selectors/__tests__/rule.test.tsx +0 -335
  88. package/src/rules/no-nested-selectors/index.tsx +0 -99
  89. package/src/rules/no-styled/README.md +0 -90
  90. package/src/rules/no-styled/__tests__/rule.test.tsx +0 -73
  91. package/src/rules/no-styled/index.tsx +0 -45
  92. package/src/rules/no-unsafe-selectors/README.md +0 -368
  93. package/src/rules/no-unsafe-selectors/__tests__/no-ambiguous-pseudos.test.tsx +0 -368
  94. package/src/rules/no-unsafe-selectors/__tests__/no-grouped-at-rules.test.tsx +0 -57
  95. package/src/rules/no-unsafe-selectors/__tests__/no-increased-specificity.test.tsx +0 -73
  96. package/src/rules/no-unsafe-selectors/__tests__/no-keyframes-at-rules.test.tsx +0 -40
  97. package/src/rules/no-unsafe-selectors/__tests__/no-legacy-pseudo-element-syntax.test.tsx +0 -101
  98. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-at-rules.test.tsx +0 -131
  99. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-pseudos.test.tsx +0 -132
  100. package/src/rules/no-unsafe-selectors/__tests__/no-selectors-object.test.tsx +0 -25
  101. package/src/rules/no-unsafe-selectors/__tests__/no-unparsable-selectors.test.tsx +0 -35
  102. package/src/rules/no-unsafe-selectors/__tests__/rule.test.tsx +0 -257
  103. package/src/rules/no-unsafe-selectors/constants.tsx +0 -91
  104. package/src/rules/no-unsafe-selectors/index.tsx +0 -198
  105. package/src/rules/no-unsafe-selectors/lint-selector.tsx +0 -155
  106. package/src/rules/no-unsafe-selectors/source-position-utils.tsx +0 -55
  107. package/src/rules/no-unsafe-selectors/walk-css-map.tsx +0 -226
  108. package/src/rules/no-unsafe-values/README.md +0 -316
  109. package/src/rules/no-unsafe-values/__tests__/no-array-values.test.tsx +0 -27
  110. package/src/rules/no-unsafe-values/__tests__/no-conditional-values.test.tsx +0 -37
  111. package/src/rules/no-unsafe-values/__tests__/no-dynamic-keys.test.tsx +0 -229
  112. package/src/rules/no-unsafe-values/__tests__/no-function-calls.test.tsx +0 -267
  113. package/src/rules/no-unsafe-values/__tests__/no-identifier-arguments.test.tsx +0 -52
  114. package/src/rules/no-unsafe-values/__tests__/no-object-access.test.tsx +0 -106
  115. package/src/rules/no-unsafe-values/__tests__/no-object-references.test.tsx +0 -44
  116. package/src/rules/no-unsafe-values/__tests__/no-spread-elements.test.tsx +0 -48
  117. package/src/rules/no-unsafe-values/__tests__/no-unsafe-values.test.tsx +0 -75
  118. package/src/rules/no-unsafe-values/__tests__/no-variables.test.tsx +0 -121
  119. package/src/rules/no-unsafe-values/index.tsx +0 -94
  120. package/src/rules/no-unsafe-values/messages.tsx +0 -86
  121. package/src/rules/no-unsafe-values/utils.tsx +0 -387
  122. package/src/rules/use-compiled/README.md +0 -52
  123. package/src/rules/use-compiled/__tests__/can-auto-fix.test.tsx +0 -73
  124. package/src/rules/use-compiled/__tests__/css.test.tsx +0 -126
  125. package/src/rules/use-compiled/__tests__/imports.test.tsx +0 -158
  126. package/src/rules/use-compiled/__tests__/keyframes.test.tsx +0 -140
  127. package/src/rules/use-compiled/__tests__/pragma.test.tsx +0 -108
  128. package/src/rules/use-compiled/__tests__/styled.test.tsx +0 -114
  129. package/src/rules/use-compiled/__tests__/use-compiled.test.tsx +0 -15
  130. package/src/rules/use-compiled/index.tsx +0 -252
  131. package/src/rules/use-compiled/is-safe.tsx +0 -159
  132. package/src/rules/use-compiled/utils.tsx +0 -33
  133. package/src/rules/utils/create-rule-with-typed-config.tsx +0 -86
  134. package/src/rules/utils/create-rule.tsx +0 -13
  135. package/tsconfig.app.json +0 -47
  136. package/tsconfig.dev.json +0 -45
  137. package/tsconfig.json +0 -25
@@ -1,8 +0,0 @@
1
- # @atlaskit/design-system/no-invalid-css-map
2
-
3
- Ensure that all usages of the cssMap API are valid, and enforces the format of the object that is
4
- passed to cssMap. This is intended to be used alongside TypeScript's type-checking.
5
-
6
- This rule is maintained by another package and configured here; refer to
7
- https://atlassian.design/components/eslint-plugin-design-system/no-invalid-css-map/usage for more
8
- details.
@@ -1,7 +0,0 @@
1
- # @compiled/no-js-xcss
2
-
3
- Disallows using xcss prop inside JavaScript files.
4
-
5
- This rule is maintained by another package and configured here; refer to
6
- https://github.com/atlassian-labs/compiled/tree/master/packages/eslint-plugin/src/rules/no-js-xcss
7
- for more details.
@@ -1,8 +0,0 @@
1
- # @atlaskit/design-system/no-keyframes-tagged-template-expression
2
-
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`.
5
-
6
- This rule is maintained by another package and configured here; refer to
7
- https://atlassian.design/components/eslint-plugin-design-system/no-keyframes-tagged-template-expression/usage
8
- for more details.
@@ -1,95 +0,0 @@
1
- # no-nested-selectors
2
-
3
- Blocks nested selectors in style declarations.
4
-
5
- Use styles which do not require context from other elements.
6
-
7
- ## Examples
8
-
9
- ### Incorrect
10
-
11
- ```tsx
12
- import { css } from '@compiled/react';
13
- import { token } from '@atlaskit/tokens';
14
-
15
- const styles = css({
16
- h2: {
17
- font: token('font.heading.large'),
18
- },
19
- });
20
-
21
- const Component = () => (
22
- <div css={styles}>
23
- <h2>Heading</h2>
24
- </div>
25
- );
26
- ```
27
-
28
- ```tsx
29
- import { styled } from '@compiled/react';
30
- import { token } from '@atlaskit/tokens';
31
-
32
- const Table = styled.table({
33
- border: `1px solid ${token('color.border')}`,
34
- td: {
35
- padding: token('space.100'),
36
- },
37
- });
38
- ```
39
-
40
- ```tsx
41
- import { styled } from '@compiled/react';
42
- import { token } from '@atlaskit/tokens';
43
-
44
- const Component = styled.div({
45
- '.myclass': {
46
- padding: token('space.100'),
47
- },
48
- });
49
- ```
50
-
51
- ### Correct
52
-
53
- ```tsx
54
- import { css } from '@compiled/react';
55
- import { token } from '@atlaskit/tokens';
56
-
57
- const headingStyles = css({
58
- font: token('font.heading.large'),
59
- });
60
-
61
- const Component = () => (
62
- <div>
63
- <h2 css={headingStyles}>Heading</h2>
64
- </div>
65
- );
66
- ```
67
-
68
- ```tsx
69
- import { css } from '@compiled/react';
70
- import { token } from '@atlaskit/tokens';
71
-
72
- const tableStyles = css({
73
- border: `1px solid ${token('color.border')}`,
74
- });
75
-
76
- const tdStyles = css({
77
- padding: token('space.100'),
78
- });
79
- ```
80
-
81
- ## Options
82
-
83
- ### `importSources: string[]`
84
-
85
- By default, this rule will check styles using:
86
-
87
- - `@atlaskit/css`
88
- - `@atlaskit/primitives`
89
- - `@compiled/react`
90
- - `@emotion/react`
91
- - `@emotion/core`
92
- - `@emotion/styled`
93
- - `styled-components`
94
-
95
- Override this list with the `importSources` option, which accepts an array of package names.
@@ -1,92 +0,0 @@
1
- # no-styled
2
-
3
- Blocks the `styled` API, which creates unnecessary indirection.
4
-
5
- This indirection:
6
-
7
- - obfuscates which tag is being rendered
8
- - adds linting complexity
9
- - promotes exported styles
10
- - can complicate refactoring
11
-
12
- Use the `css` API instead. It has better performance and clarity.
13
-
14
- ## Examples
15
-
16
- ### Incorrect
17
-
18
- ```tsx
19
- import styled from 'styled-components';
20
-
21
- const Component = styled.div`
22
- color: red;
23
- `;
24
- export default styled.div({ color: 'red' });
25
- ```
26
-
27
- ```tsx
28
- import styled2 from '@emotion/styled';
29
-
30
- export const Component = styled2('div')`…`;
31
- ```
32
-
33
- ```tsx
34
- import styled from 'styled-components';
35
- import { styled as styled3 } from '@compiled/react';
36
-
37
- const Component = styled.div`color: red;`
38
- export const ComponentTwo = styled3(Component)({ … });
39
- ```
40
-
41
- ```tsx
42
- import styled from 'styled-components';
43
-
44
- export default styled.div.attrs((props) => ({ 'data-testid': props.testId }))({
45
- color: 'red',
46
- });
47
- ```
48
-
49
- ```tsx
50
- import styled from 'styled-components';
51
-
52
- export default styled.div.attrs((props) => ({ 'data-testid': props.testId }))`
53
- color: red;
54
- `;
55
- ```
56
-
57
- ### Correct
58
-
59
- ```tsx
60
- import { css, jsx } from '@emotion/react';
61
- import { token } from '@atlaskit/tokens';
62
-
63
- const styles = css({ color: token('color.text.subtlest') });
64
-
65
- const Component = ({ children }) => {
66
- return <div css={styles}>{children}</div>;
67
- };
68
- ```
69
-
70
- ```tsx
71
- import { Box, xcss } from '@atlaskit/primitives';
72
-
73
- const styles = xcss({
74
- color: 'color.text.subtlest',
75
- });
76
-
77
- const Component = ({ children }) => {
78
- return <Box xcss={styles}>{children}</Box>;
79
- };
80
- ```
81
-
82
- ## FAQ
83
-
84
- ### How will I extend like `styled(Button)`?
85
-
86
- Don't modify the styles of components you don't own, unless they provide an explicit bounded
87
- interface for doing so — such as the `xcss` prop.
88
-
89
- Use props (excluding `className` which is prohibited) to modify component styles instead.
90
-
91
- The Atlassian Design System, for example, no longer supports `styled(Button)` because it is unsafe
92
- for us to evolve the system with.
@@ -1,8 +0,0 @@
1
- # @atlaskit/design-system/no-styled-tagged-template-expression
2
-
3
- Disallows any `styled` tagged template expressions that originate from from a CSS-in-JS library,
4
- including `@atlaskit/css`, `@compiled/react`, Emotion, and `styled-components`.
5
-
6
- This rule is maintained by another package and configured here; refer to
7
- https://atlassian.design/components/eslint-plugin-design-system/no-styled-tagged-template-expression/usage
8
- for more details.
@@ -1,28 +0,0 @@
1
- # @compiled/no-suppress-xcss
2
-
3
- Disallows supressing type violations when using the xcss prop. Supressing type violations will cause
4
- incidents and unexpected behaviour when code changes in the future.
5
-
6
- Components that use xcss prop have explicitly declared what styles they should and should not
7
- accept, consumers must adhere to this API.
8
-
9
- ## Incorrect
10
-
11
- Do not suppress type violations; if the value doesn't match the type, fix the value or expect
12
- breaking changes in the future.
13
-
14
- ```js
15
- // @ts-expect-error
16
- <Button xcss={{ fill: '#fff' }} />
17
-
18
- // @ts-ignore
19
- <Button xcss={{ fill: 'var(--ds-text)' }} />
20
- ```
21
-
22
- ## Correct
23
-
24
- You should never have a type error.
25
-
26
- ```js
27
- <Button xcss={{ color: 'var(--ds-text)' }} />
28
- ```
@@ -1,370 +0,0 @@
1
- # no-unsafe-selectors
2
-
3
- Blocks unsafe CSS selectors.
4
-
5
- Use alongside
6
- [no-nested-selectors](https://atlassian.design/components/eslint-plugin-ui-styling-standard/no-nested-selectors/usage)
7
- which blocks nested CSS selectors.
8
-
9
- Blocking unsafe selectors enables static analysis and also prevents regressions and incidents when
10
- migrating styles at scale.
11
-
12
- ## Examples
13
-
14
- ### Keyframes
15
-
16
- #### Incorrect
17
-
18
- Don't use `@keyframes` at-rules in styles.
19
-
20
- ```tsx
21
- import { css } from '@compiled/react';
22
-
23
- css({
24
- '@keyframes fadeIn': {
25
- from: {
26
- opacity: 0,
27
- },
28
- to: {
29
- opacity: 1,
30
- },
31
- },
32
- animation: '1s ease-in fadeIn',
33
- });
34
- ```
35
-
36
- #### Correct
37
-
38
- Use the `keyframes` API.
39
-
40
- ```tsx
41
- import { css, keyframes } from '@compiled/react';
42
-
43
- const fadeIn = keyframes({
44
- from: {
45
- opacity: 0,
46
- },
47
- to: {
48
- opacity: 1,
49
- },
50
- });
51
-
52
- css({
53
- animation: `1s ease-in ${fadeIn}`,
54
- });
55
- ```
56
-
57
- ### Legacy pseudo-element syntax
58
-
59
- #### Incorrect
60
-
61
- Don't use the legacy single colon syntax for pseudo-elements.
62
-
63
- This issue is autofixable.
64
-
65
- ```tsx
66
- import { css } from '@compiled/react';
67
-
68
- css({
69
- '&:after': {
70
- content: '""',
71
- },
72
- });
73
- ```
74
-
75
- #### Correct
76
-
77
- Use the double colon syntax for pseudo-elements.
78
-
79
- ```tsx
80
- import { css } from '@compiled/react';
81
-
82
- css({
83
- '&::after': {
84
- content: '""',
85
- },
86
- });
87
- ```
88
-
89
- ### Increased specificity selectors
90
-
91
- #### Incorrect
92
-
93
- Don't use the nesting selector to increase specificity of styles.
94
-
95
- ```tsx
96
- import { css } from '@compiled/react';
97
- import { token } from '@atlaskit/tokens';
98
-
99
- css({
100
- '&&': {
101
- color: token('color.text'),
102
- },
103
- });
104
- ```
105
-
106
- #### Correct
107
-
108
- Use styles that do not require increased specificity.
109
-
110
- ```tsx
111
- import { css } from '@compiled/react';
112
- import { token } from '@atlaskit/tokens';
113
-
114
- css({
115
- color: token('color.text'),
116
- });
117
- ```
118
-
119
- ### At-rules
120
-
121
- #### Incorrect
122
-
123
- Don't use at-rules in styles (see **Correct** below for exceptions).
124
-
125
- ```tsx
126
- import { css } from '@compiled/react';
127
-
128
- css({
129
- '@scope (.article-body) to (figure)': {
130
- img: {
131
- display: 'block',
132
- },
133
- },
134
- });
135
- ```
136
-
137
- #### Correct
138
-
139
- Use only allowed at-rules:
140
-
141
- - `@media` (through our
142
- [breakpoints](https://atlassian.design/components/primitives/responsive/breakpoints/examples))
143
- - `@property`
144
- - `@supports`
145
-
146
- ```tsx
147
- import { css } from '@compiled/react';
148
- import { media } from '@atlaskit/primitives/responsive';
149
-
150
- css({
151
- [media.above.sm]: {
152
- display: 'block',
153
- },
154
- });
155
- ```
156
-
157
- ### Restricted pseudo-selectors
158
-
159
- #### Incorrect
160
-
161
- Don't use pseudo-classes which take arguments or implicitly rely on external context.
162
-
163
- ```tsx
164
- import { css } from '@compiled/react';
165
- import { token } from '@atlaskit/tokens';
166
-
167
- css({
168
- '&:hover': {
169
- backgroundColor: token('color.background.neutral.hovered'),
170
- },
171
- '&:not(:hover)': {
172
- backgroundColor: token('color.background.neutral'),
173
- }
174
- '&:first-child': {
175
- fontWeight: token('font.weight.bold'),
176
- },
177
- });
178
- ```
179
-
180
- #### Correct
181
-
182
- ```tsx
183
- import { css } from '@compiled/react';
184
- import { token } from '@atlaskit/tokens';
185
-
186
- type Props = { isFirstChild: boolean };
187
-
188
- const baseStyles = css({
189
- backgroundColor: token('color.background.neutral'),
190
- '&:hover': {
191
- backgroundColor: token('color.background.neutral.hovered'),
192
- },
193
- });
194
-
195
- const firstChildStyles = css({
196
- fontWeight: token('font.weight.bold'),
197
- });
198
-
199
- const Component = ({ isFirstChild }: Props) => (
200
- <div css={[baseStyles, isFirstChild && firstChildStyles]} />
201
- );
202
- ```
203
-
204
- ### Ambiguous pseudo-selectors
205
-
206
- #### Incorrect
207
-
208
- Don't use pseudo-selectors without a leading selector, as they are ambiguous and interpreted
209
- differently between contexts.
210
-
211
- For example some contexts will treat `:hover` as `&:hover` while others will treat it as `& :hover`
212
- (which targets descendants).
213
-
214
- This issue is autofixable. By default a nesting selector `&` is added unless the
215
- `shouldAlwaysInsertNestingSelectorForAmbiguousPseudos` option is disabled.
216
-
217
- ```tsx
218
- import { css } from '@compiled/react';
219
-
220
- css({
221
- /**
222
- * This pseudo-class has no leading selector and is ambiguous.
223
- */
224
- ':hover': {},
225
-
226
- /**
227
- * In some contexts the above is treated as implicitly containing a nesting selector.
228
- */
229
- '&:hover': {},
230
-
231
- /**
232
- * In other contexts it is treated as a descendant selector.
233
- *
234
- * (The selectors below are equivalent.)
235
- */
236
- '*:hover': {},
237
- '& :hover': {},
238
- '& *:hover': {},
239
- });
240
- ```
241
-
242
- #### Correct
243
-
244
- Use explicit selectors. Do not rely on implicit or undefined behavior for pseudo-selectors.
245
-
246
- ```tsx
247
-
248
- ```
249
-
250
- ### Grouped at-rules
251
-
252
- #### Incorrect
253
-
254
- Don't group at-rules with the `cssMap` API.
255
-
256
- ````tsx
257
- import { cssMap } from '@compiled/react';
258
-
259
- ```tsx
260
- cssMap({
261
- success: {
262
- '@media': {
263
- '(min-width: 900px)': {},
264
- '(min-width: 1200px)': {},
265
- },
266
- },
267
- });
268
- ````
269
-
270
- #### Correct
271
-
272
- Write flattened at-rules instead.
273
-
274
- ```tsx
275
- cssMap({
276
- success: {
277
- selectors: {
278
- '&:not(:active)': {
279
- backgroundColor: 'white',
280
- },
281
- },
282
- },
283
- });
284
- ```
285
-
286
- ### Correct
287
-
288
- ```tsx
289
- const fadeIn = keyframes({
290
- from: {
291
- opacity: 0,
292
- },
293
- to: {
294
- opacity: 1,
295
- },
296
- });
297
-
298
- css({
299
- animationName: fadeIn,
300
- });
301
- ```
302
-
303
- ```tsx
304
- css({
305
- '::after': {
306
- content: '""',
307
- width: 100,
308
- height: 100,
309
- backgroundColor: 'red',
310
- },
311
- });
312
- ```
313
-
314
- ```tsx
315
- css({
316
- '&:first-of-type': {
317
- width: 100,
318
- },
319
- });
320
- ```
321
-
322
- ```tsx
323
- css({
324
- '&:hover': {},
325
- });
326
- ```
327
-
328
- ```tsx
329
- cssMap({
330
- success: {
331
- '@media (min-width: 900px)': {},
332
- '@media (min-width: 1200px)': {},
333
- },
334
- });
335
- ```
336
-
337
- ```tsx
338
- cssMap({
339
- success: {
340
- backgroundColor: 'white',
341
- '&:active': {
342
- backgroundColor: 'green',
343
- },
344
- },
345
- });
346
- ```
347
-
348
- ## Options
349
-
350
- ### `importSources: string[]`
351
-
352
- By default, this rule will check styles using:
353
-
354
- - `@atlaskit/css`
355
- - `@atlaskit/primitives`
356
- - `@compiled/react`
357
- - `@emotion/react`
358
- - `@emotion/core`
359
- - `@emotion/styled`
360
- - `styled-components`
361
-
362
- Override this list with the `importSources` option, which accepts an array of package names.
363
-
364
- ### `shouldAlwaysInsertNestingSelectorForAmbiguousPseudos: boolean`
365
-
366
- By default this rule will always fix ambiguous pseudo-selectors by inserting a leading `&` (nesting
367
- selector).
368
-
369
- Set `shouldAlwaysInsertNestingSelectorForAmbiguousPseudos` to `false` to disable this auto-fix. When
370
- disabled, a suggestion will be provided instead of an auto-fix.