@atlaskit/eslint-plugin-ui-styling-standard 0.17.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 (152) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/presets/all.codegen.js +3 -2
  3. package/dist/cjs/presets/recommended.codegen.js +3 -2
  4. package/dist/cjs/rules/external-rules.js +3 -1
  5. package/dist/es2019/presets/all.codegen.js +3 -2
  6. package/dist/es2019/presets/recommended.codegen.js +3 -2
  7. package/dist/es2019/rules/external-rules.js +3 -1
  8. package/dist/esm/presets/all.codegen.js +3 -2
  9. package/dist/esm/presets/recommended.codegen.js +3 -2
  10. package/dist/esm/rules/external-rules.js +3 -1
  11. package/dist/types/index.codegen.d.ts +2 -0
  12. package/dist/types/presets/all.codegen.d.ts +2 -1
  13. package/dist/types/presets/recommended.codegen.d.ts +2 -1
  14. package/dist/types-ts4.5/index.codegen.d.ts +2 -0
  15. package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -1
  16. package/dist/types-ts4.5/presets/recommended.codegen.d.ts +2 -1
  17. package/package.json +2 -2
  18. package/afm-cc/tsconfig.json +0 -28
  19. package/afm-jira/tsconfig.json +0 -28
  20. package/build/tsconfig.json +0 -18
  21. package/constellation/atlaskit-theme/usage.mdx +0 -132
  22. package/constellation/consistent-css-prop-usage/usage.mdx +0 -7
  23. package/constellation/convert-props-syntax/usage.mdx +0 -130
  24. package/constellation/enforce-style-prop/usage.mdx +0 -47
  25. package/constellation/index/migration-guide.mdx +0 -309
  26. package/constellation/index/overview.mdx +0 -250
  27. package/constellation/index/props.mdx +0 -30
  28. package/constellation/local-cx-xcss/usage.mdx +0 -53
  29. package/constellation/no-array-arguments/usage.mdx +0 -49
  30. package/constellation/no-classname-prop/usage.mdx +0 -49
  31. package/constellation/no-container-queries/usage.mdx +0 -101
  32. package/constellation/no-css-tagged-template-expression/usage.mdx +0 -8
  33. package/constellation/no-dynamic-styles/usage.mdx +0 -130
  34. package/constellation/no-empty-styled-expression/usage.mdx +0 -8
  35. package/constellation/no-exported-css/usage.mdx +0 -8
  36. package/constellation/no-exported-keyframes/usage.mdx +0 -8
  37. package/constellation/no-exported-styles/usage.mdx +0 -87
  38. package/constellation/no-global-styles/usage.mdx +0 -60
  39. package/constellation/no-important-styles/usage.mdx +0 -33
  40. package/constellation/no-imported-style-values/usage.mdx +0 -157
  41. package/constellation/no-invalid-css-map/usage.mdx +0 -8
  42. package/constellation/no-js-xcss/usage.mdx +0 -7
  43. package/constellation/no-keyframes-tagged-template-expression/usage.mdx +0 -8
  44. package/constellation/no-nested-selectors/usage.mdx +0 -95
  45. package/constellation/no-styled/usage.mdx +0 -92
  46. package/constellation/no-styled-tagged-template-expression/usage.mdx +0 -8
  47. package/constellation/no-suppress-xcss/usage.mdx +0 -28
  48. package/constellation/no-unsafe-selectors/usage.mdx +0 -370
  49. package/constellation/no-unsafe-values/usage.mdx +0 -318
  50. package/constellation/use-compiled/usage.mdx +0 -54
  51. package/index.js +0 -24
  52. package/scripts/codegen.tsx +0 -373
  53. package/src/index.codegen.tsx +0 -14
  54. package/src/index.tsx +0 -1
  55. package/src/presets/all.codegen.tsx +0 -79
  56. package/src/presets/recommended.codegen.tsx +0 -79
  57. package/src/rules/TEMPLATE.md +0 -29
  58. package/src/rules/__tests__/utils/_tester.tsx +0 -40
  59. package/src/rules/atlaskit-theme/README.md +0 -130
  60. package/src/rules/atlaskit-theme/__tests__/test.ts +0 -133
  61. package/src/rules/atlaskit-theme/index.ts +0 -134
  62. package/src/rules/convert-props-syntax/README.md +0 -128
  63. package/src/rules/convert-props-syntax/__tests__/invalid.test.tsx +0 -76
  64. package/src/rules/convert-props-syntax/__tests__/rule.test.tsx +0 -584
  65. package/src/rules/convert-props-syntax/__tests__/type-annotations.test.tsx +0 -140
  66. package/src/rules/convert-props-syntax/__tests__/unusual-properties.test.tsx +0 -69
  67. package/src/rules/convert-props-syntax/index.tsx +0 -414
  68. package/src/rules/enforce-style-prop/README.md +0 -45
  69. package/src/rules/enforce-style-prop/__tests__/rule.test.tsx +0 -243
  70. package/src/rules/enforce-style-prop/index.tsx +0 -172
  71. package/src/rules/external-rules.tsx +0 -175
  72. package/src/rules/index.codegen.tsx +0 -42
  73. package/src/rules/local-cx-xcss/README.md +0 -51
  74. package/src/rules/local-cx-xcss/__tests__/rule.test.tsx +0 -102
  75. package/src/rules/local-cx-xcss/index.tsx +0 -62
  76. package/src/rules/no-array-arguments/README.md +0 -47
  77. package/src/rules/no-array-arguments/__tests__/rule.test.tsx +0 -107
  78. package/src/rules/no-array-arguments/index.tsx +0 -86
  79. package/src/rules/no-classname-prop/README.md +0 -47
  80. package/src/rules/no-classname-prop/__tests__/rule.test.tsx +0 -39
  81. package/src/rules/no-classname-prop/index.tsx +0 -34
  82. package/src/rules/no-container-queries/README.md +0 -99
  83. package/src/rules/no-container-queries/__tests__/rule.test.tsx +0 -139
  84. package/src/rules/no-container-queries/index.tsx +0 -94
  85. package/src/rules/no-dynamic-styles/README.md +0 -128
  86. package/src/rules/no-dynamic-styles/__tests__/rule.test.tsx +0 -135
  87. package/src/rules/no-dynamic-styles/index.tsx +0 -60
  88. package/src/rules/no-exported-styles/README.md +0 -85
  89. package/src/rules/no-exported-styles/__tests__/rule.test.tsx +0 -216
  90. package/src/rules/no-exported-styles/index.tsx +0 -52
  91. package/src/rules/no-global-styles/README.md +0 -58
  92. package/src/rules/no-global-styles/__tests__/no-css-modules.test.tsx +0 -33
  93. package/src/rules/no-global-styles/__tests__/no-global-styles.test.tsx +0 -46
  94. package/src/rules/no-global-styles/index.tsx +0 -82
  95. package/src/rules/no-important-styles/README.md +0 -31
  96. package/src/rules/no-important-styles/__tests__/rule.test.tsx +0 -165
  97. package/src/rules/no-important-styles/index.tsx +0 -70
  98. package/src/rules/no-imported-style-values/README.md +0 -155
  99. package/src/rules/no-imported-style-values/__tests__/rule.test.tsx +0 -491
  100. package/src/rules/no-imported-style-values/index.tsx +0 -188
  101. package/src/rules/no-nested-selectors/README.md +0 -93
  102. package/src/rules/no-nested-selectors/__tests__/rule.test.tsx +0 -335
  103. package/src/rules/no-nested-selectors/index.tsx +0 -99
  104. package/src/rules/no-styled/README.md +0 -90
  105. package/src/rules/no-styled/__tests__/rule.test.tsx +0 -73
  106. package/src/rules/no-styled/index.tsx +0 -45
  107. package/src/rules/no-unsafe-selectors/README.md +0 -368
  108. package/src/rules/no-unsafe-selectors/__tests__/no-ambiguous-pseudos.test.tsx +0 -368
  109. package/src/rules/no-unsafe-selectors/__tests__/no-grouped-at-rules.test.tsx +0 -57
  110. package/src/rules/no-unsafe-selectors/__tests__/no-increased-specificity.test.tsx +0 -73
  111. package/src/rules/no-unsafe-selectors/__tests__/no-keyframes-at-rules.test.tsx +0 -40
  112. package/src/rules/no-unsafe-selectors/__tests__/no-legacy-pseudo-element-syntax.test.tsx +0 -101
  113. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-at-rules.test.tsx +0 -131
  114. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-pseudos.test.tsx +0 -132
  115. package/src/rules/no-unsafe-selectors/__tests__/no-selectors-object.test.tsx +0 -25
  116. package/src/rules/no-unsafe-selectors/__tests__/no-unparsable-selectors.test.tsx +0 -35
  117. package/src/rules/no-unsafe-selectors/__tests__/rule.test.tsx +0 -257
  118. package/src/rules/no-unsafe-selectors/constants.tsx +0 -91
  119. package/src/rules/no-unsafe-selectors/index.tsx +0 -198
  120. package/src/rules/no-unsafe-selectors/lint-selector.tsx +0 -155
  121. package/src/rules/no-unsafe-selectors/source-position-utils.tsx +0 -55
  122. package/src/rules/no-unsafe-selectors/walk-css-map.tsx +0 -226
  123. package/src/rules/no-unsafe-values/README.md +0 -316
  124. package/src/rules/no-unsafe-values/__tests__/no-array-values.test.tsx +0 -27
  125. package/src/rules/no-unsafe-values/__tests__/no-conditional-values.test.tsx +0 -37
  126. package/src/rules/no-unsafe-values/__tests__/no-dynamic-keys.test.tsx +0 -229
  127. package/src/rules/no-unsafe-values/__tests__/no-function-calls.test.tsx +0 -267
  128. package/src/rules/no-unsafe-values/__tests__/no-identifier-arguments.test.tsx +0 -52
  129. package/src/rules/no-unsafe-values/__tests__/no-object-access.test.tsx +0 -106
  130. package/src/rules/no-unsafe-values/__tests__/no-object-references.test.tsx +0 -44
  131. package/src/rules/no-unsafe-values/__tests__/no-spread-elements.test.tsx +0 -48
  132. package/src/rules/no-unsafe-values/__tests__/no-unsafe-values.test.tsx +0 -75
  133. package/src/rules/no-unsafe-values/__tests__/no-variables.test.tsx +0 -121
  134. package/src/rules/no-unsafe-values/index.tsx +0 -94
  135. package/src/rules/no-unsafe-values/messages.tsx +0 -86
  136. package/src/rules/no-unsafe-values/utils.tsx +0 -387
  137. package/src/rules/use-compiled/README.md +0 -52
  138. package/src/rules/use-compiled/__tests__/can-auto-fix.test.tsx +0 -73
  139. package/src/rules/use-compiled/__tests__/css.test.tsx +0 -126
  140. package/src/rules/use-compiled/__tests__/imports.test.tsx +0 -158
  141. package/src/rules/use-compiled/__tests__/keyframes.test.tsx +0 -140
  142. package/src/rules/use-compiled/__tests__/pragma.test.tsx +0 -108
  143. package/src/rules/use-compiled/__tests__/styled.test.tsx +0 -114
  144. package/src/rules/use-compiled/__tests__/use-compiled.test.tsx +0 -15
  145. package/src/rules/use-compiled/index.tsx +0 -252
  146. package/src/rules/use-compiled/is-safe.tsx +0 -159
  147. package/src/rules/use-compiled/utils.tsx +0 -33
  148. package/src/rules/utils/create-rule-with-typed-config.tsx +0 -86
  149. package/src/rules/utils/create-rule.tsx +0 -13
  150. package/tsconfig.app.json +0 -47
  151. package/tsconfig.dev.json +0 -45
  152. package/tsconfig.json +0 -25
@@ -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.
@@ -1,318 +0,0 @@
1
- # no-unsafe-values
2
-
3
- Blocks styles that are difficult or impossible to statically analyze.
4
-
5
- ## Examples
6
-
7
- ### Function calls
8
-
9
- #### Incorrect
10
-
11
- Function calls are blocked as arguments or as values, unless they are specified in
12
- `allowedFunctionCalls` (or in the default list).
13
-
14
- ```tsx
15
- import { css } from '@compiled/react';
16
-
17
- function getStyles() {
18
- return { width: 100 };
19
- }
20
-
21
- const styles = css(getStyles());
22
- ```
23
-
24
- ```tsx
25
- import { css } from '@compiled/react';
26
-
27
- function getWidth() {
28
- return 100;
29
- }
30
-
31
- const styles = css({
32
- width: getWidth(),
33
- });
34
- ```
35
-
36
- #### Correct
37
-
38
- Use inline literals for static values.
39
-
40
- ```tsx
41
- import { css } from '@compiled/react';
42
-
43
- const styles = css({ width: 100 });
44
- ```
45
-
46
- Use the `style` prop for dynamic values.
47
-
48
- ```tsx
49
- const Component = ({ width }) => <div style={{ width }} />;
50
- ```
51
-
52
- Some functions such as `tokens()` are allowed.
53
-
54
- ```tsx
55
- import { css } from '@compiled/react';
56
- import { token } from '@atlaskit/tokens';
57
-
58
- const styles = css({ padding: token('space.100') });
59
- ```
60
-
61
- ### Dynamic keys
62
-
63
- #### Incorrect
64
-
65
- Dynamic keys are blocked, unless they are specified in `allowedDynamicKeys` (or in the default
66
- list).
67
-
68
- ```tsx
69
- import { css } from '@compiled/react';
70
-
71
- const HOVER_SELECTOR = '&:hover';
72
- const MARGIN = 'margin';
73
-
74
- const styles = css({
75
- [HOVER_SELECTOR]: {
76
- [MARGIN]: 0,
77
- },
78
- [`${HOVER_SELECTOR} > p`]: {
79
- width: 100,
80
- },
81
- });
82
- ```
83
-
84
- #### Correct
85
-
86
- Use literal values for pseudo-states and property names.
87
-
88
- Don't use nested selectors, apply styles directly instead.
89
-
90
- ```tsx
91
- import { css } from '@compiled/react';
92
-
93
- const styles = css({
94
- '&:hover': {
95
- margin: 0,
96
- },
97
- });
98
-
99
- const paragraphStyles = css({
100
- width: 100,
101
- });
102
- ```
103
-
104
- ### Variables
105
-
106
- #### Incorrect
107
-
108
- Variables are only allowed as values if they:
109
-
110
- - have a simple, static value
111
- - are defined in the same file
112
-
113
- ```tsx
114
- import { css } from '@compiled/react';
115
- import { HEIGHT } from '../shared';
116
-
117
- const styles = css({
118
- height: HEIGHT,
119
- });
120
- ```
121
-
122
- #### Correct
123
-
124
- Use inlined values.
125
-
126
- ```tsx
127
- import { css } from '@compiled/react';
128
-
129
- const styles = css({
130
- height: '32px',
131
- });
132
- ```
133
-
134
- Alternatively, define variables in the same file.
135
-
136
- ```tsx
137
- import { css } from '@compiled/react';
138
-
139
- const HEIGHT = '32px';
140
-
141
- const styles = css({
142
- height: HEIGHT,
143
- });
144
- ```
145
-
146
- ### Object access
147
-
148
- #### Incorrect
149
-
150
- Don't access object members in values.
151
-
152
- ```tsx
153
- import { css } from '@compiled/react';
154
- import { token } from '@atlaskit/tokens';
155
-
156
- const colors = {
157
- text: token('color.text'),
158
- };
159
-
160
- const styles = css({
161
- color: colors.text,
162
- });
163
- ```
164
-
165
- #### Correct
166
-
167
- Use inlined values.
168
-
169
- ```tsx
170
- import { css } from '@compiled/react';
171
- import { token } from '@atlaskit/tokens';
172
-
173
- const styles = css({
174
- color: token('color.text'),
175
- });
176
- ```
177
-
178
- ### Spread elements
179
-
180
- #### Incorrect
181
-
182
- Don't use the spread operator in styles.
183
-
184
- ```tsx
185
- import { css } from '@compiled/react';
186
- import { token } from '@atlaskit/tokens';
187
-
188
- const subtleTextStyles = {
189
- color: token('color.text.subtle'),
190
- };
191
-
192
- const styles = css({
193
- ...subtleTextStyles,
194
- margin: 0,
195
- });
196
- ```
197
-
198
- #### Correct
199
-
200
- Use the `css` prop to compose styles.
201
-
202
- ```tsx
203
- import { css } from '@compiled/react';
204
- import { token } from '@atlaskit/tokens';
205
-
206
- const subtleTextStyles = {
207
- color: token('color.text.subtle'),
208
- };
209
-
210
- const styles = css({
211
- margin: 0,
212
- });
213
-
214
- const Component = () => <div css={[subtleTextStyles, styles]} />;
215
- ```
216
-
217
- ### Array values
218
-
219
- #### Incorrect
220
-
221
- Don't use array values. This syntax is not supported by Compiled, or most other CSS-in-JS libraries.
222
-
223
- ```tsx
224
- import { css } from '@compiled/react';
225
- import { token } from '@atlaskit/tokens';
226
-
227
- const boldMixin = { fontWeight: token('font.weight.bold') };
228
-
229
- const styles = css({
230
- '&::before': [boldMixin, { color: token('color.text.danger') }],
231
- });
232
- ```
233
-
234
- #### Correct
235
-
236
- Use a single object with inlined styles.
237
-
238
- ```tsx
239
- import { css } from '@compiled/react';
240
- import { token } from '@atlaskit/tokens';
241
-
242
- const styles = css({
243
- '&::before': {
244
- fontWeight: token('font.weight.bold'),
245
- color: token('color.text.danger'),
246
- },
247
- });
248
- ```
249
-
250
- ## Options
251
-
252
- ### `allowedDynamicKeys: [string, string][]`
253
-
254
- Use this to allow specified imports as dynamic keys, in addition to the built-in allow-list.
255
-
256
- Each value should be a two-element array. The first item is the entrypoint, and the second item is a
257
- named export.
258
-
259
- Default imports are not supported.
260
-
261
- ```tsx
262
- // .eslintrc.js
263
-
264
- // ...
265
- rules: {
266
- '@atlaskit/eslint-plugin-ui-styling-standard/no-unsafe-values': [
267
- 'error',
268
- {
269
- allowedDynamicKeys: [
270
- ['@atlaskit/primitives/responsive', 'media'],
271
- ]
272
- },
273
- ],
274
- // ...
275
- },
276
- // ...
277
- ```
278
-
279
- ### `allowedFunctionCalls: [string, string][]`
280
-
281
- Use this to allow specific functions to be called, in addition to the built-in allow-list.
282
-
283
- Each value should be a two-element array. The first item is the entrypoint, and the second item is a
284
- named export.
285
-
286
- Default imports are not currently supported.
287
-
288
- ```tsx
289
- // .eslintrc.js
290
-
291
- // ...
292
- rules: {
293
- '@atlaskit/eslint-plugin-ui-styling-standard/no-unsafe-values': [
294
- 'error',
295
- {
296
- allowedFunctionCalls: [
297
- ['@atlaskit/tokens', 'token'],
298
- ]
299
- },
300
- ],
301
- // ...
302
- },
303
- // ...
304
- ```
305
-
306
- ### `importSources: string[]`
307
-
308
- By default, this rule will check styles using:
309
-
310
- - `@atlaskit/css`
311
- - `@atlaskit/primitives`
312
- - `@compiled/react`
313
- - `@emotion/react`
314
- - `@emotion/core`
315
- - `@emotion/styled`
316
- - `styled-components`
317
-
318
- Override this list with the `importSources` option, which accepts an array of package names.
@@ -1,54 +0,0 @@
1
- # use-compiled
2
-
3
- Blocks CSS-in-JS libraries other than `@compiled/react`, including Emotion and styled-components.
4
-
5
- **WARNING** It may be unsafe to mix usages of `@compiled/react` with other CSS-in-JS libraries on
6
- the same component. When converting to `@compiled/react` verify ALL changes. For this reason, the
7
- autofixer has been disabled by default, but it may be useful to enable to empower a migration.
8
-
9
- ## Examples
10
-
11
- ### Incorrect
12
-
13
- ```tsx
14
- /** @jsx jsx */
15
- import { css } from '@emotion/core';
16
- import { jsx } from '@emotion/react';
17
- import styled from '@emotion/styled';
18
- ```
19
-
20
- ```tsx
21
- import styled, { css } from 'styled-components';
22
- ```
23
-
24
- ### Correct
25
-
26
- We expect usage of `xcss` with `@atlaskit/primitives` when working with Primitives, and `css` with
27
- `@compiled/react` when working with custom or native code.
28
-
29
- ```tsx
30
- /** @jsx jsx */
31
- import { jsx, css, styled } from '@compiled/react';
32
-
33
- const styles = css({ color: 'var(--ds-color-text)' });
34
- export default () => <div css={styles}>…</div>;
35
- ```
36
-
37
- ```tsx
38
- import { xcss, Box } from '@atlaskit/primitives';
39
-
40
- const styles = xcss({ color: 'color.text' });
41
- export default () => <Box xcss={styles}>…</Box>;
42
- ```
43
-
44
- ## Options
45
-
46
- ### `canAutoFix: boolean`
47
-
48
- Determines whether or not the autofixer is enabled.
49
-
50
- Defaults to `false` due to safety concerns when mixing Compiled and other CSS-in-JS libraries on the
51
- same component.
52
-
53
- Even when enabled, the autofixer will only convert usages that are deemed safe. Currently this is
54
- limited to purely static styles where all keys and values are simple literals.