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

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 (140) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/rules/no-imported-style-values/index.js +36 -5
  3. package/dist/es2019/rules/no-imported-style-values/index.js +36 -5
  4. package/dist/esm/rules/no-imported-style-values/index.js +36 -5
  5. package/package.json +1 -1
  6. package/afm-cc/tsconfig.json +0 -28
  7. package/afm-jira/tsconfig.json +0 -27
  8. package/build/tsconfig.json +0 -18
  9. package/constellation/atlaskit-theme/usage.mdx +0 -132
  10. package/constellation/consistent-css-prop-usage/usage.mdx +0 -7
  11. package/constellation/convert-props-syntax/usage.mdx +0 -130
  12. package/constellation/enforce-style-prop/usage.mdx +0 -47
  13. package/constellation/index/migration-guide.mdx +0 -309
  14. package/constellation/index/overview.mdx +0 -250
  15. package/constellation/index/props.mdx +0 -30
  16. package/constellation/local-cx-xcss/usage.mdx +0 -53
  17. package/constellation/no-array-arguments/usage.mdx +0 -49
  18. package/constellation/no-classname-prop/usage.mdx +0 -49
  19. package/constellation/no-container-queries/usage.mdx +0 -101
  20. package/constellation/no-css-tagged-template-expression/usage.mdx +0 -8
  21. package/constellation/no-dynamic-styles/usage.mdx +0 -130
  22. package/constellation/no-empty-styled-expression/usage.mdx +0 -8
  23. package/constellation/no-exported-css/usage.mdx +0 -8
  24. package/constellation/no-exported-keyframes/usage.mdx +0 -8
  25. package/constellation/no-exported-styles/usage.mdx +0 -87
  26. package/constellation/no-global-styles/usage.mdx +0 -60
  27. package/constellation/no-important-styles/usage.mdx +0 -33
  28. package/constellation/no-imported-style-values/usage.mdx +0 -157
  29. package/constellation/no-invalid-css-map/usage.mdx +0 -8
  30. package/constellation/no-js-xcss/usage.mdx +0 -7
  31. package/constellation/no-keyframes-tagged-template-expression/usage.mdx +0 -8
  32. package/constellation/no-nested-selectors/usage.mdx +0 -95
  33. package/constellation/no-styled/usage.mdx +0 -92
  34. package/constellation/no-styled-tagged-template-expression/usage.mdx +0 -8
  35. package/constellation/no-suppress-xcss/usage.mdx +0 -28
  36. package/constellation/no-unsafe-selectors/usage.mdx +0 -370
  37. package/constellation/no-unsafe-values/usage.mdx +0 -318
  38. package/constellation/use-compiled/usage.mdx +0 -54
  39. package/index.js +0 -24
  40. package/scripts/codegen.tsx +0 -373
  41. package/src/index.codegen.tsx +0 -14
  42. package/src/index.tsx +0 -1
  43. package/src/presets/all.codegen.tsx +0 -79
  44. package/src/presets/recommended.codegen.tsx +0 -79
  45. package/src/rules/TEMPLATE.md +0 -29
  46. package/src/rules/__tests__/utils/_tester.tsx +0 -40
  47. package/src/rules/atlaskit-theme/README.md +0 -130
  48. package/src/rules/atlaskit-theme/__tests__/test.ts +0 -133
  49. package/src/rules/atlaskit-theme/index.ts +0 -134
  50. package/src/rules/convert-props-syntax/README.md +0 -128
  51. package/src/rules/convert-props-syntax/__tests__/invalid.test.tsx +0 -76
  52. package/src/rules/convert-props-syntax/__tests__/rule.test.tsx +0 -584
  53. package/src/rules/convert-props-syntax/__tests__/type-annotations.test.tsx +0 -140
  54. package/src/rules/convert-props-syntax/__tests__/unusual-properties.test.tsx +0 -69
  55. package/src/rules/convert-props-syntax/index.tsx +0 -414
  56. package/src/rules/enforce-style-prop/README.md +0 -45
  57. package/src/rules/enforce-style-prop/__tests__/rule.test.tsx +0 -243
  58. package/src/rules/enforce-style-prop/index.tsx +0 -172
  59. package/src/rules/external-rules.tsx +0 -177
  60. package/src/rules/index.codegen.tsx +0 -42
  61. package/src/rules/local-cx-xcss/README.md +0 -51
  62. package/src/rules/local-cx-xcss/__tests__/rule.test.tsx +0 -102
  63. package/src/rules/local-cx-xcss/index.tsx +0 -62
  64. package/src/rules/no-array-arguments/README.md +0 -47
  65. package/src/rules/no-array-arguments/__tests__/rule.test.tsx +0 -107
  66. package/src/rules/no-array-arguments/index.tsx +0 -86
  67. package/src/rules/no-classname-prop/README.md +0 -47
  68. package/src/rules/no-classname-prop/__tests__/rule.test.tsx +0 -39
  69. package/src/rules/no-classname-prop/index.tsx +0 -34
  70. package/src/rules/no-container-queries/README.md +0 -99
  71. package/src/rules/no-container-queries/__tests__/rule.test.tsx +0 -139
  72. package/src/rules/no-container-queries/index.tsx +0 -94
  73. package/src/rules/no-dynamic-styles/README.md +0 -128
  74. package/src/rules/no-dynamic-styles/__tests__/rule.test.tsx +0 -135
  75. package/src/rules/no-dynamic-styles/index.tsx +0 -60
  76. package/src/rules/no-exported-styles/README.md +0 -85
  77. package/src/rules/no-exported-styles/__tests__/rule.test.tsx +0 -216
  78. package/src/rules/no-exported-styles/index.tsx +0 -52
  79. package/src/rules/no-global-styles/README.md +0 -58
  80. package/src/rules/no-global-styles/__tests__/no-css-modules.test.tsx +0 -33
  81. package/src/rules/no-global-styles/__tests__/no-global-styles.test.tsx +0 -46
  82. package/src/rules/no-global-styles/index.tsx +0 -82
  83. package/src/rules/no-important-styles/README.md +0 -31
  84. package/src/rules/no-important-styles/__tests__/rule.test.tsx +0 -165
  85. package/src/rules/no-important-styles/index.tsx +0 -70
  86. package/src/rules/no-imported-style-values/README.md +0 -155
  87. package/src/rules/no-imported-style-values/__tests__/rule.test.tsx +0 -491
  88. package/src/rules/no-imported-style-values/index.tsx +0 -188
  89. package/src/rules/no-nested-selectors/README.md +0 -93
  90. package/src/rules/no-nested-selectors/__tests__/rule.test.tsx +0 -335
  91. package/src/rules/no-nested-selectors/index.tsx +0 -99
  92. package/src/rules/no-styled/README.md +0 -90
  93. package/src/rules/no-styled/__tests__/rule.test.tsx +0 -73
  94. package/src/rules/no-styled/index.tsx +0 -45
  95. package/src/rules/no-unsafe-selectors/README.md +0 -368
  96. package/src/rules/no-unsafe-selectors/__tests__/no-ambiguous-pseudos.test.tsx +0 -368
  97. package/src/rules/no-unsafe-selectors/__tests__/no-grouped-at-rules.test.tsx +0 -57
  98. package/src/rules/no-unsafe-selectors/__tests__/no-increased-specificity.test.tsx +0 -73
  99. package/src/rules/no-unsafe-selectors/__tests__/no-keyframes-at-rules.test.tsx +0 -40
  100. package/src/rules/no-unsafe-selectors/__tests__/no-legacy-pseudo-element-syntax.test.tsx +0 -101
  101. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-at-rules.test.tsx +0 -131
  102. package/src/rules/no-unsafe-selectors/__tests__/no-restricted-pseudos.test.tsx +0 -132
  103. package/src/rules/no-unsafe-selectors/__tests__/no-selectors-object.test.tsx +0 -25
  104. package/src/rules/no-unsafe-selectors/__tests__/no-unparsable-selectors.test.tsx +0 -35
  105. package/src/rules/no-unsafe-selectors/__tests__/rule.test.tsx +0 -257
  106. package/src/rules/no-unsafe-selectors/constants.tsx +0 -91
  107. package/src/rules/no-unsafe-selectors/index.tsx +0 -198
  108. package/src/rules/no-unsafe-selectors/lint-selector.tsx +0 -155
  109. package/src/rules/no-unsafe-selectors/source-position-utils.tsx +0 -55
  110. package/src/rules/no-unsafe-selectors/walk-css-map.tsx +0 -226
  111. package/src/rules/no-unsafe-values/README.md +0 -316
  112. package/src/rules/no-unsafe-values/__tests__/no-array-values.test.tsx +0 -27
  113. package/src/rules/no-unsafe-values/__tests__/no-conditional-values.test.tsx +0 -37
  114. package/src/rules/no-unsafe-values/__tests__/no-dynamic-keys.test.tsx +0 -229
  115. package/src/rules/no-unsafe-values/__tests__/no-function-calls.test.tsx +0 -267
  116. package/src/rules/no-unsafe-values/__tests__/no-identifier-arguments.test.tsx +0 -52
  117. package/src/rules/no-unsafe-values/__tests__/no-object-access.test.tsx +0 -106
  118. package/src/rules/no-unsafe-values/__tests__/no-object-references.test.tsx +0 -44
  119. package/src/rules/no-unsafe-values/__tests__/no-spread-elements.test.tsx +0 -48
  120. package/src/rules/no-unsafe-values/__tests__/no-unsafe-values.test.tsx +0 -75
  121. package/src/rules/no-unsafe-values/__tests__/no-variables.test.tsx +0 -121
  122. package/src/rules/no-unsafe-values/index.tsx +0 -94
  123. package/src/rules/no-unsafe-values/messages.tsx +0 -86
  124. package/src/rules/no-unsafe-values/utils.tsx +0 -387
  125. package/src/rules/use-compiled/README.md +0 -52
  126. package/src/rules/use-compiled/__tests__/can-auto-fix.test.tsx +0 -73
  127. package/src/rules/use-compiled/__tests__/css.test.tsx +0 -126
  128. package/src/rules/use-compiled/__tests__/imports.test.tsx +0 -158
  129. package/src/rules/use-compiled/__tests__/keyframes.test.tsx +0 -140
  130. package/src/rules/use-compiled/__tests__/pragma.test.tsx +0 -108
  131. package/src/rules/use-compiled/__tests__/styled.test.tsx +0 -114
  132. package/src/rules/use-compiled/__tests__/use-compiled.test.tsx +0 -15
  133. package/src/rules/use-compiled/index.tsx +0 -252
  134. package/src/rules/use-compiled/is-safe.tsx +0 -159
  135. package/src/rules/use-compiled/utils.tsx +0 -33
  136. package/src/rules/utils/create-rule-with-typed-config.tsx +0 -86
  137. package/src/rules/utils/create-rule.tsx +0 -13
  138. package/tsconfig.app.json +0 -47
  139. package/tsconfig.dev.json +0 -45
  140. package/tsconfig.json +0 -25
@@ -1,309 +0,0 @@
1
- ---
2
- order: 3
3
- ---
4
-
5
- import SectionMessage from '@atlaskit/section-message';
6
- import Tabs, { Tab, TabList, TabPanel } from '@atlaskit/tabs';
7
-
8
- ## Patterns
9
-
10
- All styles should be written using [Compiled](https://compiledcssinjs.com/) or
11
- [Primitives](/components/primitives) and conform to the following patterns.
12
-
13
- ### Static styles
14
-
15
- For styles that are not affected by props or state, use the `css()` or `xcss()` API.
16
-
17
- #### Compiled
18
-
19
- When using Compiled, write static styles with `css()` and apply them with the `css` prop.
20
-
21
- ```tsx
22
- import { css } from '@compiled/react';
23
- import { token } from '@atlaskit/tokens';
24
-
25
- const cardStyles = css({
26
- backgroundColor: token('elevation.surface.raised'),
27
- boxShadow: token('elevation.shadow.raised'),
28
- padding: token('space.100'),
29
- });
30
-
31
- const Card = () => <div css={cardStyles} />;
32
- ```
33
-
34
- #### Primitives
35
-
36
- When using Primitives, write static styles with `xcss()` and apply them with the `xcss` prop.
37
-
38
- ```tsx
39
- import { Box, xcss } from '@atlaskit/primitives';
40
-
41
- const cardStyles = xcss({
42
- backgroundColor: 'elevation.surface.raised',
43
- boxShadow: 'elevation.shadow.raised',
44
- padding: 'space.100',
45
- });
46
-
47
- const Card = () => <Box xcss={cardStyles} />;
48
- ```
49
-
50
- ### Toggled styles
51
-
52
- For styles that are toggled on and off, write them as [static styles](#static-styles) and then
53
- conditionally apply them.
54
-
55
- #### Compiled
56
-
57
- When using Compiled, conditionally apply styles with the `css` prop.
58
-
59
- ```tsx
60
- import { css } from '@compiled/react';
61
- import { token } from '@atlaskit/tokens';
62
-
63
- const baseStyles = css({
64
- backgroundColor: token('color.background.neutral'),
65
- border: `1px solid ${token('color.border')}`,
66
- });
67
-
68
- const selectedStyles = css({
69
- backgroundColor: token('color.background.selected'),
70
- borderColor: token('color.border.selected'),
71
- });
72
-
73
- const Selectable = ({ isSelected = false }: { isSelected?: boolean }) => (
74
- // The `selectedStyles` are conditionally applied
75
- <div css={[baseStyles, isSelected && selectedStyles]} />
76
- );
77
- ```
78
-
79
- #### Primitives
80
-
81
- When using Primitives, conditionally apply styles with the `xcss` prop.
82
-
83
- ```tsx
84
- import { Box, xcss } from '@atlaskit/primitives';
85
-
86
- const baseStyles = xcss({
87
- backgroundColor: 'color.background.neutral',
88
- borderWidth: '1px',
89
- borderStyle: 'solid',
90
- borderColor: 'color.border',
91
- });
92
-
93
- const selectedStyles = xcss({
94
- backgroundColor: 'color.background.selected',
95
- borderColor: 'color.border.selected',
96
- });
97
-
98
- const Selectable = ({ isSelected = false }: { isSelected?: boolean }) => (
99
- // The `selectedStyles` are conditionally applied
100
- <Box xcss={[baseStyles, isSelected && selectedStyles]} />
101
- );
102
- ```
103
-
104
- ### Variant styles
105
-
106
- For styles that compose a set of known variants, use `cssMap` or an object of `xcss()` styles and
107
- then dynamically access them.
108
-
109
- #### Compiled
110
-
111
- When using Compiled, write variants with `cssMap` and apply them with the `css` prop.
112
-
113
- ```tsx
114
- import { css, cssMap } from '@compiled/react';
115
- import { token } from '@atlaskit/tokens';
116
-
117
- type Status = 'success' | 'warning' | 'danger';
118
-
119
- const baseStyles = css({
120
- font: token('font.body.large'),
121
- padding: token('space.100'),
122
- });
123
-
124
- const statusStyles = cssMap({
125
- success: {
126
- color: token('color.text.success'),
127
- backgroundColor: token('color.background.success'),
128
- },
129
- warning: {
130
- color: token('color.text.warning'),
131
- backgroundColor: token('color.background.warning'),
132
- },
133
- danger: {
134
- color: token('color.text.danger'),
135
- backgroundColor: token('color.background.danger'),
136
- },
137
- });
138
-
139
- const StatusMessage = ({ message, status }: { message: string; status: Status }) => (
140
- // The `statusStyles` are dynamically accessed
141
- <div css={[baseStyles, statusStyles[status]]} />
142
- );
143
- ```
144
-
145
- #### Primitives
146
-
147
- When using Primitives, write variants using an object with `xcss()` values and apply them with the
148
- `xcss` prop.
149
-
150
- ```tsx
151
- import { Box, xcss } from '@atlaskit/primitives';
152
-
153
- type Status = 'success' | 'warning' | 'danger';
154
-
155
- const baseStyles = xcss({
156
- font: 'font.body.large',
157
- padding: 'space.100',
158
- });
159
-
160
- const statusStyles = {
161
- success: xcss({
162
- color: 'color.text.success',
163
- backgroundColor: 'color.background.success',
164
- }),
165
- warning: xcss({
166
- color: 'color.text.warning',
167
- backgroundColor: 'color.background.warning',
168
- }),
169
- danger: xcss({
170
- color: 'color.text.danger',
171
- backgroundColor: 'color.background.danger',
172
- }),
173
- };
174
-
175
- const StatusMessage = ({ message, status }: { message: string; status: Status }) => (
176
- // The `statusStyles` are dynamically accessed
177
- <Box xcss={[baseStyles, statusStyles[status]]} />
178
- );
179
- ```
180
-
181
- ### Dynamic styles
182
-
183
- <SectionMessage appearance="warning" title="Use with caution">
184
- Only a tiny percentage (~1%) of styles need to be written this way. If you are using it
185
- frequently, you are likely doing something wrong!
186
- </SectionMessage>
187
-
188
- For styles that cannot be expressed statically, use the `style` prop.
189
-
190
- This might be needed when:
191
-
192
- - Styles are derived from user input
193
- - Integrating with a 3rd party library that provides a `style` object
194
-
195
- #### Compiled
196
-
197
- ```tsx
198
- import { css } from '@compiled/react';
199
- import { token } from '@atlaskit/tokens';
200
-
201
- const baseStyles = css({
202
- height: '100%',
203
- minWidth: '200px',
204
- backgroundColor: token('color.background.neutral'),
205
- });
206
-
207
- const Resizable = ({ width }: { width: string }) => <div css={baseStyles} style={{ width }} />;
208
- ```
209
-
210
- #### Primitives
211
-
212
- ```tsx
213
- import { Box, xcss } from '@atlaskit/primitives';
214
-
215
- const baseStyles = xcss({
216
- height: '100%',
217
- minWidth: '200px',
218
- backgroundColor: 'color.background.neutral',
219
- });
220
-
221
- const Resizable = ({ width }: { width: string }) => <Box css={baseStyles} style={{ width }} />;
222
- ```
223
-
224
- ## More examples
225
-
226
- ### Migrating from `styled`
227
-
228
- #### Before
229
-
230
- ```tsx
231
- import { styled } from '@compiled/react';
232
-
233
- type Status = 'success' | 'warning' | 'danger';
234
-
235
- type Props = {
236
- width: string;
237
- status: Status;
238
- isSelected: boolean;
239
- };
240
-
241
- const textColors: Record<Status, string> = {
242
- success: token('color.text.success'),
243
- warning: token('color.text.warning'),
244
- danger: token('color.text.danger'),
245
- };
246
-
247
- const Component = styled.div<Props>(
248
- {
249
- padding: token('space.100'),
250
- width: (props) => props.width,
251
- },
252
- ({ status }: { status: Status }) => ({
253
- color: textColors[status],
254
- }),
255
- ({ isSelected }) => (isSelected ? { border: `1px solid ${token('color.border.selected')}` } : {}),
256
- );
257
- ```
258
-
259
- #### After
260
-
261
- We apply a combination of the patterns above:
262
-
263
- - The padding is a [static style](#static-styles) so uses `css()` that is always applied.
264
- - The selected border is a [toggled style](#toggled-styles) so uses `css()` that is conditionally
265
- applied.
266
- - The status color is a [variant style](#variant-styles) so is written using `cssMap()` that is
267
- dynamically accessed.
268
- - The width is a [completely dynamic style](#dynamic-styles) so uses the `style` prop.
269
-
270
- ```tsx
271
- import type { ReactNode } from 'react';
272
- import { css, cssMap } from '@compiled/react';
273
-
274
- type Status = 'success' | 'warning' | 'danger';
275
-
276
- type Props = {
277
- width: string;
278
- status: Status;
279
- isSelected: boolean;
280
- // Props that were implicitly added now need to be made explicit
281
- children: ReactNode;
282
- };
283
-
284
- const baseStyles = css({
285
- padding: token('space.100'),
286
- });
287
-
288
- const selectedStyles = css({
289
- border: `1px solid ${token('color.border.selected')}`,
290
- });
291
-
292
- const statusStyles = cssMap({
293
- success: {
294
- color: token('color.text.success'),
295
- },
296
- warning: {
297
- color: token('color.text.warning'),
298
- },
299
- danger: {
300
- color: token('color.text.danger'),
301
- },
302
- });
303
-
304
- const Component = ({ width, status, isSelected, children }: Props) => (
305
- <div css={[baseStyles, isSelected && selectedStyles, statusStyles[status]]} style={{ width }}>
306
- {children}
307
- </div>
308
- );
309
- ```
@@ -1,250 +0,0 @@
1
- ---
2
- order: 1
3
- ---
4
-
5
- The UI Styling Standard is a set of principles to guide styling UI code across Atlassian's frontend
6
- codebases and ecosystem.
7
-
8
- These are the current ESLint rules that enforce and help comply with the UI Styling Standard today,
9
- but more are planned to support the standard over time.
10
-
11
- ## Rules
12
-
13
- <!-- START_RULE_TABLE_CODEGEN -->
14
- <!-- @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen -->
15
-
16
- | Rule | Description | Recommended | Fixable | Suggestions |
17
- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------- | ------- | ----------- |
18
- | <a href="/components/eslint-plugin-ui-styling-standard/atlaskit-theme/usage">atlaskit-theme</a> | Ban certain usages of `@atlaskit/theme` that `@compiled/react` does not understand | Yes | | |
19
- | <a href="/components/eslint-plugin-ui-styling-standard/convert-props-syntax/usage">convert-props-syntax</a> | Convert props syntax that is unsupported by styled-components@<4 or @emotion/styled to props syntax that is supported. This is useful when used in conjunction with `no-styled-tagged-template-expression`, as output from the latter may use props syntax unsupported by those libraries. | Yes | Yes | |
20
- | <a href="/components/eslint-plugin-ui-styling-standard/enforce-style-prop/usage">enforce-style-prop</a> | Disallows usage of static styles in the `style` attribute in components | Yes | | |
21
- | <a href="/components/eslint-plugin-ui-styling-standard/local-cx-xcss/usage">local-cx-xcss</a> | Ensures the cx() function, which is part of the XCSS API, is only used within the xcss prop. This aids tracking what styles are applied to a jsx element. | Yes | | |
22
- | <a href="/components/eslint-plugin-ui-styling-standard/no-array-arguments/usage">no-array-arguments</a> | Prevents usage of array arguments to style declaration functions | Yes | Yes | |
23
- | <a href="/components/eslint-plugin-ui-styling-standard/no-classname-prop/usage">no-classname-prop</a> | Disallows usage of the `className` prop in JSX | Yes | | |
24
- | <a href="/components/eslint-plugin-ui-styling-standard/no-container-queries/usage">no-container-queries</a> | Prevents usage of @container query within css styling | Yes | | |
25
- | <a href="/components/eslint-plugin-ui-styling-standard/no-dynamic-styles/usage">no-dynamic-styles</a> | Disallows use of dynamic styles in CSS-in-JS calls | Yes | | |
26
- | <a href="/components/eslint-plugin-ui-styling-standard/no-exported-styles/usage">no-exported-styles</a> | Disallows exports of css, keyframes, styled and xcss | Yes | | |
27
- | <a href="/components/eslint-plugin-ui-styling-standard/no-global-styles/usage">no-global-styles</a> | Prevents global styles through CSS-in-JS or CSS module imports | Yes | | |
28
- | <a href="/components/eslint-plugin-ui-styling-standard/no-important-styles/usage">no-important-styles</a> | Disallows important style declarations | Yes | | |
29
- | <a href="/components/eslint-plugin-ui-styling-standard/no-imported-style-values/usage">no-imported-style-values</a> | Disallows imports of style values | Yes | | |
30
- | <a href="/components/eslint-plugin-ui-styling-standard/no-nested-selectors/usage">no-nested-selectors</a> | Prevents usage of nested selectors within css styling | Yes | | |
31
- | <a href="/components/eslint-plugin-ui-styling-standard/no-styled/usage">no-styled</a> | Disallows usage of the `styled` imports | Yes | | |
32
- | <a href="/components/eslint-plugin-ui-styling-standard/no-unsafe-selectors/usage">no-unsafe-selectors</a> | Disallows use of nested styles in `css` functions. | Yes | Yes | Yes |
33
- | <a href="/components/eslint-plugin-ui-styling-standard/no-unsafe-values/usage">no-unsafe-values</a> | Disallows styles that are difficult/impossible to statically anaylze. | Yes | | |
34
- | <a href="/components/eslint-plugin-ui-styling-standard/use-compiled/usage">use-compiled</a> | Ensures usage of `@compiled/react` instead of other CSS-in-JS libraries | Yes | Yes | |
35
- | <a href="/components/eslint-plugin-ui-styling-standard/consistent-css-prop-usage/usage">@atlaskit/design-system/consistent-css-prop-usage</a> | Ensures consistency with `css` and `xcss` prop usages | Yes | Yes | |
36
- | <a href="/components/eslint-plugin-ui-styling-standard/no-css-tagged-template-expression/usage">@atlaskit/design-system/no-css-tagged-template-expression</a> | Disallows any `css` tagged template expressions that originate from Emotion, Styled Components or Compiled | Yes | Yes | |
37
- | <a href="/components/eslint-plugin-ui-styling-standard/no-keyframes-tagged-template-expression/usage">@atlaskit/design-system/no-keyframes-tagged-template-expression</a> | Disallows any `keyframe` tagged template expressions that originate from Emotion, Styled Components or Compiled | Yes | Yes | |
38
- | <a href="/components/eslint-plugin-ui-styling-standard/no-styled-tagged-template-expression/usage">@atlaskit/design-system/no-styled-tagged-template-expression</a> | Disallows any `styled` tagged template expressions that originate from Emotion, Styled Components or Compiled | Yes | Yes | |
39
- | <a href="/components/eslint-plugin-ui-styling-standard/no-suppress-xcss/usage">@compiled/no-suppress-xcss</a> | Disallows supressing type violations when using the xcss prop. | Yes | | |
40
- | <a href="/components/eslint-plugin-ui-styling-standard/no-js-xcss/usage">@compiled/no-js-xcss</a> | Disallows using xcss prop inside JavaScript files. | Yes | | |
41
- | <a href="/components/eslint-plugin-ui-styling-standard/no-empty-styled-expression/usage">@atlaskit/design-system/no-empty-styled-expression</a> | Forbids any styled expression to be used when passing empty arguments to styled.div() (or other JSX elements). | Yes | | |
42
- | <a href="/components/eslint-plugin-ui-styling-standard/no-exported-css/usage">@atlaskit/design-system/no-exported-css</a> | Forbid exporting `css` function calls. Exporting `css` function calls can result in unexpected behaviour at runtime, and is not statically analysable. | Yes | | |
43
- | <a href="/components/eslint-plugin-ui-styling-standard/no-exported-keyframes/usage">@atlaskit/design-system/no-exported-keyframes</a> | Forbid exporting `keyframes` function calls. Exporting `css` function calls can result in unexpected behaviour at runtime, and is not statically analysable. | Yes | | |
44
- | <a href="/components/eslint-plugin-ui-styling-standard/no-invalid-css-map/usage">@atlaskit/design-system/no-invalid-css-map</a> | Checks the validity of a CSS map created through cssMap. This is intended to be used alongside TypeScript's type-checking. | Yes | | |
45
-
46
- <!-- END_RULE_TABLE_CODEGEN -->
47
-
48
- ## Purpose of the UI Styling Standard
49
-
50
- For Atlassians, refer to the
51
- [internal UI Styling Standard policy](https://go.atlassian.com/ui-styling-standard-policy).
52
-
53
- To enforce scoped encapsulation, type safety, and deterministic behavior in styling code that is
54
- present in other programming languages. This is a stepping stone to large performance improvements,
55
- reduced visual regressions, and enables testing and maintainability at scale. This approach improves
56
- readability and developer productivity via automation with tooling, testing, code migrations, and
57
- future advancements like generative AI.
58
-
59
- ### Desired outcomes:
60
-
61
- - We can make large visual changes and migrations safely and in a fraction of the time.
62
- - To have the vast majority of styling code be deterministic, immutable, and bound to its scope,
63
- reducing unknown visual and UX regressions.
64
- - To enable teams to write tooling quicker that's better and more performant to lint, test, and
65
- migrate UI code to improve current and future developer productivity and satisfaction.
66
- - To enable large performance improvements for customers and developers with a zero-runtime styling
67
- solution.
68
- - To reduce the amount of overall custom styling code written while supporting customization without
69
- without the need for hacks and technical debt.
70
- - We aim to see a reduction of the “average styles per component”, reducing the effort to build and
71
- maintain UIs.
72
-
73
- ## Basic principles
74
-
75
- We want the styling ecosystem (CSS, CSS-in-JS, and parts of JSX) at Atlassian and the wider
76
- ecosystem we support to be as mature as the other code we write, such as TypeScript/JavaScript,
77
- Java, Go, etc.
78
-
79
- ### Like other languages, styling code must be:
80
-
81
- - type-safe
82
- - static and locally analyzable
83
- - reusable and composable
84
- - restricted to an encapsulated scope
85
- - deterministic—with styling known in isolation
86
- - discoverable and readable without deep knowledge of the CSS spec
87
-
88
- As the W3C CSS spec and wider industry grows, having our styling code meet these principles will
89
- mean we can programatically evolve that a better future state.
90
-
91
- ## Examples
92
-
93
- Refer to the [eslint rules](#rules) for more in-depth examples.
94
-
95
- ### Incorrect code
96
-
97
- 1. The use of `styled-components` and `@emotion/…` are being deprecated.
98
- 2. Dynamic styles are heavily discouraged.
99
- 3. Nested selectors as well as `props.className` and global styles are heavily discouraged.
100
- 4. Do not import or export styles.
101
- 5. Do not use the `styled.div` or `styled(Component)` syntaxes.
102
- 6. Do not pass-through or spread props, be explicit to verbose.
103
- 7. Don't use `!important`, `&& { … }`, or similar hacks.
104
-
105
- ```tsx
106
- import styled from 'styled-components';
107
- import { css } from '@emotion/react';
108
- import { mixin, innerWrapperStyles, disabledStyles } from './shared/styles';
109
-
110
- const Wrapper = styled.div`
111
- ${mixin}
112
- && {
113
- color: ${(props) => (props.disabled ? 'gray' : 'black')};
114
- width: ${(props) => props.width || 100}px;
115
- }
116
- & > button {
117
- color: ${(props) => (props.disabled ? 'gray' : 'blue')} !important;
118
- }
119
- `;
120
-
121
- export const Component = ({
122
- disabled,
123
- width,
124
- appearance = 'primary',
125
- ...props,
126
- }: {
127
- disabled?: boolean;
128
- width?: number;
129
- appearance?: 'primary' | 'secondary';
130
- }) => (
131
- <Wrapper disabled={props.disabled}>
132
- <div
133
- css={[
134
- innerWrapperStyles,
135
- css({
136
- ...(disabled
137
- ? {
138
- '& + [disabled]': {
139
- ...disabledStyles,
140
- opacity: props.disabled ? '70%' : '100%',
141
- }
142
- : undefined
143
- ),
144
- }),
145
- ]}
146
- {...props}
147
- >
148
- <button
149
- disabled={props.disabled}
150
- className={`btn btn-${props.appearance}`}
151
- >
152
- Click me
153
- </button>
154
- </div>
155
- </Wrapper>
156
- );
157
- ```
158
-
159
- ### Correct code
160
-
161
- Every element should be clear in isolation how it's styled, using locally and statically available
162
- context so both humans and tooling can read this component in a performant and deterministic manner.
163
-
164
- 1. Use `@compiled/react` or [Primitives](/components/primitives/overview) wherever possible!
165
- 2. Instead of dynamic styles:
166
- 1. Use static `css()` calls everywhere.
167
- 2. Compose styles together, turning styles on or off.
168
- 3. When absoluteuly necessary, use `props.style` for dynamic styles.
169
- 3. Instead of nested selectors or global styles:
170
- 1. Style components directly.
171
- 2. Treat everything as local scope, parents shouldn't interact with children wherever feasible.
172
- 4. Instead of passing raw styles around:
173
- 1. Write composable and reusable components which distribute styles with clear context.
174
- 2. Co-locate styles in the same file for human readability and far better tooling feasibility and
175
- performance.
176
- 5. Instead of `styled.…`, use `const styles = css({ … });` (hoisted and static) and
177
- `<div css={styles} />`.
178
- 1. There will be a safe way to make bounded customizations on components through the use of
179
- `<Component xcss={css({ … })}>` in the future.
180
- 6. Instead of `...props`, be explicit with the `aria-` or `data-` props you support, or have more
181
- complex spread handling. This is because `className`, `style`, and other things can be applied
182
- without any knowledge, resulting in regressions in the future.
183
- 7. Instead of `!important`, `&& { … }`, or other specificity hacks, ensure your styles are correctly
184
- scoped to the component.
185
-
186
- ```tsx
187
- import { css } from '@compiled/react';
188
- import { token } from '@atlaskit/tokens';
189
-
190
- const wrapperStyles = css({
191
- padding: token('space.200'), // eg. from mixin
192
- font: token('font.body'), // eg. from mixin
193
- color: token('color.text'),
194
- });
195
- const disabledWrapperStyles = css({
196
- color: token('color.text.disabled'),
197
- });
198
- const innerWrapperStyles = css({
199
- // eg. colocated `innerWrapperStyles` (alternatively could create a reusable `<InnerWrapper>`)
200
- display: 'flex',
201
- gap: token('space.100'),
202
- flexDirection: 'column',
203
- });
204
- const buttonStyles = css({
205
- appearance: 'none', // eg. from global styles
206
- padding: `${token('space.100')} ${token('space.200')}`, // eg. from global styles
207
- color: token('color.link'),
208
- });
209
- const disabledButtonStyles = css({
210
- cursor: 'not-allowed', // eg. from disabledStyles
211
- color: token('color.text.disabled'),
212
- opacity: '70%',
213
- });
214
- const buttonAppearanceStyles = cssMap({
215
- primary: { background: token('color.background.brand.subtlest') },
216
- secondary: { background: token('color.background.success') },
217
- });
218
-
219
- export const Component = ({
220
- disabled = false,
221
- width = 100,
222
- appearance = 'primary',
223
- 'aria-label': ariaLabel,
224
- }: {
225
- disabled?: boolean;
226
- width?: number;
227
- appearance?: 'primary' | 'secondary';
228
- 'aria-label'?: string;
229
- }) => (
230
- <div
231
- css={[wrapperStyles, props.disabled && disabledWrapperStyles]}
232
- style={{ width: `${props.width}px` }}
233
- aria-label={ariaLabel}
234
- >
235
- <div css={innerWrapperStyles}>
236
- {/* Typically, this `<button>` should be an Atlassian Design System `<Button>` */}
237
- <button
238
- disabled={props.disabled}
239
- css={[
240
- buttonStyles,
241
- buttonAppearances[props.appearance],
242
- props.disabled && disabledButtonStyles,
243
- ]}
244
- >
245
- Click me
246
- </button>
247
- </div>
248
- </div>
249
- );
250
- ```
@@ -1,30 +0,0 @@
1
- ---
2
- order: 2
3
- ---
4
-
5
- You must use the recommended config to follow the styling standards at Atlassian, which will ensure
6
- compatability and performance with the design system.
7
-
8
- ```diff
9
- module.exports = {
10
- extends: [
11
- + 'plugin:@atlaskit/ui-styling-standard/recommended',
12
- ],
13
- };
14
- ```
15
-
16
- We don't recommended maintaining your own configuration. If you do not use our config you will need
17
- to specify individual rules and configuration. Add the plugin to your `.eslintrc.js` file and enable
18
- individual rules as you're ready to adopt.
19
-
20
- ```diff
21
- module.exports = {
22
- plugins: [
23
- + '@atlaskit/ui-styling-standard',
24
- ],
25
- rules: [
26
- + '@atlaskit/ui-styling-standard/convert-props-syntax': 'warn',
27
- + '@atlaskit/design-system/local-cx-xcss': 'error',
28
- ],
29
- };
30
- ```
@@ -1,53 +0,0 @@
1
- # local-cx-xcss
2
-
3
- Blocks the `cx()` function from being used outside of the `xcss` prop. This aids tracking which
4
- styles are applied.
5
-
6
- Use the `cx()` function when passing multiple styles to the `xcss` prop. This provides more robust
7
- type checking than the conventional array syntax:
8
-
9
- ```tsx
10
- import { cssMap, cx } from '@compiled/react';
11
- import { token } from '@atlaskit/tokens';
12
- import { Component } from 'some-package';
13
-
14
- const styles = cssMap({
15
- text: { color: token('color.text') },
16
- primary: { color: token('color.text.brand') },
17
- });
18
-
19
- <Component xcss={cx(isPrimary && styles.text, !isPrimary && styles.primary)} />;
20
- ```
21
-
22
- The `cx()` function is only checked when imported from `@compiled/react` or `@atlaskit/css`.
23
-
24
- ## Examples
25
-
26
- ### Incorrect
27
-
28
- ```tsx
29
- import { cssMap, cx } from '@compiled/react';
30
- import { token } from '@atlaskit/tokens';
31
-
32
- const styles = cssMap({
33
- text: { color: token('color.text') },
34
- bg: { background: token('color.background.neutral') },
35
- });
36
-
37
- const joinedStyles = cx(styles.text, styles.bg);
38
-
39
- <Button xcss={joinedStyles} />;
40
- ```
41
-
42
- ### Correct
43
-
44
- ```tsx
45
- import { cssMap, cx } from '@compiled/react';
46
-
47
- const styles = cssMap({
48
- text: { color: token('color.text') },
49
- bg: { background: token('color.background.neutral') },
50
- });
51
-
52
- <Button xcss={cx(styles.text, styles.bg)} />;
53
- ```