@atlaskit/eslint-plugin-ui-styling-standard 0.15.2 → 0.16.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.
- package/CHANGELOG.md +17 -0
- package/constellation/consistent-css-prop-usage/usage.mdx +3 -1
- package/constellation/index/migration-guide.mdx +309 -0
- package/constellation/index/overview.mdx +4 -0
- package/constellation/index/props.mdx +9 -5
- package/constellation/no-css-tagged-template-expression/usage.mdx +5 -2
- package/constellation/no-empty-styled-expression/usage.mdx +5 -2
- package/constellation/no-exported-css/usage.mdx +5 -2
- package/constellation/no-exported-keyframes/usage.mdx +5 -2
- package/constellation/no-invalid-css-map/usage.mdx +5 -2
- package/constellation/no-js-xcss/usage.mdx +3 -1
- package/constellation/no-keyframes-tagged-template-expression/usage.mdx +5 -2
- package/constellation/no-styled-tagged-template-expression/usage.mdx +5 -2
- package/constellation/no-suppress-xcss/usage.mdx +6 -3
- package/dist/types/rules/no-unsafe-selectors/constants.d.ts +1 -4
- package/index.js +9 -9
- package/package.json +3 -3
- package/scripts/codegen.tsx +223 -284
- package/src/rules/__tests__/utils/_tester.tsx +24 -24
- package/src/rules/atlaskit-theme/README.md +21 -19
- package/src/rules/atlaskit-theme/__tests__/test.ts +53 -53
- package/src/rules/atlaskit-theme/index.ts +107 -115
- package/src/rules/convert-props-syntax/README.md +32 -22
- package/src/rules/convert-props-syntax/__tests__/invalid.test.tsx +46 -46
- package/src/rules/convert-props-syntax/__tests__/rule.test.tsx +175 -175
- package/src/rules/convert-props-syntax/__tests__/type-annotations.test.tsx +52 -52
- package/src/rules/convert-props-syntax/__tests__/unusual-properties.test.tsx +33 -33
- package/src/rules/convert-props-syntax/index.tsx +356 -386
- package/src/rules/enforce-style-prop/README.md +21 -18
- package/src/rules/enforce-style-prop/__tests__/rule.test.tsx +90 -96
- package/src/rules/enforce-style-prop/index.tsx +144 -160
- package/src/rules/external-rules.tsx +163 -164
- package/src/rules/local-cx-xcss/README.md +10 -6
- package/src/rules/local-cx-xcss/__tests__/rule.test.tsx +26 -26
- package/src/rules/local-cx-xcss/index.tsx +46 -56
- package/src/rules/no-array-arguments/README.md +2 -1
- package/src/rules/no-array-arguments/__tests__/rule.test.tsx +37 -46
- package/src/rules/no-array-arguments/index.tsx +68 -69
- package/src/rules/no-classname-prop/README.md +7 -4
- package/src/rules/no-classname-prop/__tests__/rule.test.tsx +22 -22
- package/src/rules/no-classname-prop/index.tsx +25 -25
- package/src/rules/no-container-queries/README.md +11 -9
- package/src/rules/no-container-queries/__tests__/rule.test.tsx +47 -50
- package/src/rules/no-container-queries/index.tsx +75 -81
- package/src/rules/no-dynamic-styles/README.md +16 -19
- package/src/rules/no-dynamic-styles/__tests__/rule.test.tsx +58 -67
- package/src/rules/no-dynamic-styles/index.tsx +45 -48
- package/src/rules/no-exported-styles/README.md +17 -12
- package/src/rules/no-exported-styles/__tests__/rule.test.tsx +102 -111
- package/src/rules/no-exported-styles/index.tsx +36 -36
- package/src/rules/no-global-styles/README.md +15 -14
- package/src/rules/no-global-styles/__tests__/no-css-modules.test.tsx +28 -28
- package/src/rules/no-global-styles/__tests__/no-global-styles.test.tsx +37 -37
- package/src/rules/no-global-styles/index.tsx +59 -62
- package/src/rules/no-important-styles/README.md +5 -3
- package/src/rules/no-important-styles/__tests__/rule.test.tsx +66 -66
- package/src/rules/no-important-styles/index.tsx +49 -49
- package/src/rules/no-imported-style-values/README.md +23 -15
- package/src/rules/no-imported-style-values/__tests__/rule.test.tsx +123 -123
- package/src/rules/no-imported-style-values/index.tsx +116 -120
- package/src/rules/no-nested-selectors/README.md +15 -13
- package/src/rules/no-nested-selectors/__tests__/rule.test.tsx +141 -128
- package/src/rules/no-styled/README.md +14 -9
- package/src/rules/no-styled/__tests__/rule.test.tsx +31 -31
- package/src/rules/no-styled/index.tsx +34 -41
- package/src/rules/no-unsafe-selectors/README.md +103 -93
- package/src/rules/no-unsafe-selectors/__tests__/no-grouped-at-rules.test.tsx +21 -24
- package/src/rules/no-unsafe-selectors/__tests__/no-increased-specificity.test.tsx +44 -44
- package/src/rules/no-unsafe-selectors/__tests__/no-keyframes-at-rules.test.tsx +21 -21
- package/src/rules/no-unsafe-selectors/__tests__/no-legacy-pseudo-element-syntax.test.tsx +57 -57
- package/src/rules/no-unsafe-selectors/__tests__/no-restricted-at-rules.test.tsx +58 -58
- package/src/rules/no-unsafe-selectors/__tests__/no-restricted-pseudos.test.tsx +85 -85
- package/src/rules/no-unsafe-selectors/__tests__/no-selectors-object.test.tsx +12 -12
- package/src/rules/no-unsafe-selectors/__tests__/no-unparsable-selectors.test.tsx +23 -23
- package/src/rules/no-unsafe-selectors/__tests__/rule.test.tsx +133 -114
- package/src/rules/no-unsafe-selectors/constants.tsx +69 -77
- package/src/rules/no-unsafe-selectors/source-position-utils.tsx +38 -38
- package/src/rules/no-unsafe-selectors/walk-css-map.tsx +178 -184
- package/src/rules/no-unsafe-values/README.md +34 -40
- package/src/rules/no-unsafe-values/__tests__/no-array-values.test.tsx +13 -13
- package/src/rules/no-unsafe-values/__tests__/no-conditional-values.test.tsx +18 -18
- package/src/rules/no-unsafe-values/__tests__/no-dynamic-keys.test.tsx +104 -104
- package/src/rules/no-unsafe-values/__tests__/no-function-calls.test.tsx +128 -128
- package/src/rules/no-unsafe-values/__tests__/no-identifier-arguments.test.tsx +23 -23
- package/src/rules/no-unsafe-values/__tests__/no-object-access.test.tsx +38 -38
- package/src/rules/no-unsafe-values/__tests__/no-object-references.test.tsx +18 -18
- package/src/rules/no-unsafe-values/__tests__/no-spread-elements.test.tsx +18 -18
- package/src/rules/no-unsafe-values/__tests__/no-unsafe-values.test.tsx +28 -28
- package/src/rules/no-unsafe-values/__tests__/no-variables.test.tsx +47 -47
- package/src/rules/no-unsafe-values/index.tsx +76 -78
- package/src/rules/no-unsafe-values/messages.tsx +12 -12
- package/src/rules/no-unsafe-values/utils.tsx +370 -382
- package/src/rules/use-compiled/README.md +11 -8
- package/src/rules/use-compiled/__tests__/can-auto-fix.test.tsx +32 -32
- package/src/rules/use-compiled/__tests__/css.test.tsx +53 -53
- package/src/rules/use-compiled/__tests__/imports.test.tsx +90 -95
- package/src/rules/use-compiled/__tests__/keyframes.test.tsx +47 -47
- package/src/rules/use-compiled/__tests__/pragma.test.tsx +64 -64
- package/src/rules/use-compiled/__tests__/styled.test.tsx +53 -53
- package/src/rules/use-compiled/__tests__/use-compiled.test.tsx +10 -10
- package/src/rules/use-compiled/index.tsx +203 -226
- package/src/rules/use-compiled/is-safe.tsx +113 -117
- package/src/rules/use-compiled/utils.tsx +14 -18
- package/src/rules/utils/create-rule-with-typed-config.tsx +62 -63
- package/src/rules/utils/create-rule.tsx +3 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-ui-styling-standard
|
|
2
2
|
|
|
3
|
+
## 0.16.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#110975](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/110975)
|
|
8
|
+
[`47a912f14bb6f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/47a912f14bb6f) -
|
|
9
|
+
Fixed a bug in `walkStyleProperties` that could result in `styled(BaseComponent)({})` styles to
|
|
10
|
+
not be linted.
|
|
11
|
+
|
|
12
|
+
## 0.16.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- [#109850](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/109850)
|
|
17
|
+
[`9a18d4ad09473`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9a18d4ad09473) -
|
|
18
|
+
Added migration guide to styling standard documentation.
|
|
19
|
+
|
|
3
20
|
## 0.15.2
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -2,4 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Ensures consistency with all `css` and `xcss` prop usages.
|
|
4
4
|
|
|
5
|
-
This rule is maintained by another package and configured here; refer to
|
|
5
|
+
This rule is maintained by another package and configured here; refer to
|
|
6
|
+
https://atlassian.design/components/eslint-plugin-design-system/consistent-css-prop-usage/usage for
|
|
7
|
+
more details.
|
|
@@ -0,0 +1,309 @@
|
|
|
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,5 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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.
|
|
3
7
|
|
|
4
8
|
```diff
|
|
5
9
|
module.exports = {
|
|
@@ -9,9 +13,9 @@ module.exports = {
|
|
|
9
13
|
};
|
|
10
14
|
```
|
|
11
15
|
|
|
12
|
-
We don't recommended maintaining your own configuration.
|
|
13
|
-
|
|
14
|
-
|
|
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.
|
|
15
19
|
|
|
16
20
|
```diff
|
|
17
21
|
module.exports = {
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# @atlaskit/design-system/no-css-tagged-template-expression
|
|
2
2
|
|
|
3
|
-
Disallows any `css` tagged template expressions that originate from a CSS-in-JS library, including
|
|
3
|
+
Disallows any `css` tagged template expressions that originate from a CSS-in-JS library, including
|
|
4
|
+
`@atlaskit/css`, `@compiled/react`, Emotion, and `styled-components`.
|
|
4
5
|
|
|
5
|
-
This rule is maintained by another package and configured here; refer to
|
|
6
|
+
This rule is maintained by another package and configured here; refer to
|
|
7
|
+
https://atlassian.design/components/eslint-plugin-design-system/no-css-tagged-template-expression/usage
|
|
8
|
+
for more details.
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# @atlaskit/design-system/no-empty-styled-expression
|
|
2
2
|
|
|
3
|
-
Forbids any styled expression to be used when passing empty arguments to styled.div() (or other JSX
|
|
3
|
+
Forbids any styled expression to be used when passing empty arguments to styled.div() (or other JSX
|
|
4
|
+
elements).
|
|
4
5
|
|
|
5
|
-
This rule is maintained by another package and configured here; refer to
|
|
6
|
+
This rule is maintained by another package and configured here; refer to
|
|
7
|
+
https://atlassian.design/components/eslint-plugin-design-system/no-empty-styled-expression/usage for
|
|
8
|
+
more details.
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# @atlaskit/design-system/no-exported-css
|
|
2
2
|
|
|
3
|
-
Forbid exporting `css` function calls. Exporting `css` function calls can result in unexpected
|
|
3
|
+
Forbid exporting `css` function calls. Exporting `css` function calls can result in unexpected
|
|
4
|
+
behaviour at runtime, and is not statically analysable.
|
|
4
5
|
|
|
5
|
-
This rule is maintained by another package and configured here; refer to
|
|
6
|
+
This rule is maintained by another package and configured here; refer to
|
|
7
|
+
https://atlassian.design/components/eslint-plugin-design-system/no-exported-css/usage for more
|
|
8
|
+
details.
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# @atlaskit/design-system/no-exported-keyframes
|
|
2
2
|
|
|
3
|
-
Forbid exporting `keyframes` function calls. Exporting `css` function calls can result in unexpected
|
|
3
|
+
Forbid exporting `keyframes` function calls. Exporting `css` function calls can result in unexpected
|
|
4
|
+
behaviour at runtime, and is not statically analysable.
|
|
4
5
|
|
|
5
|
-
This rule is maintained by another package and configured here; refer to
|
|
6
|
+
This rule is maintained by another package and configured here; refer to
|
|
7
|
+
https://atlassian.design/components/eslint-plugin-design-system/no-exported-keyframes/usage for more
|
|
8
|
+
details.
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# @atlaskit/design-system/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
|
|
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.
|
|
4
5
|
|
|
5
|
-
This rule is maintained by another package and configured here; refer to
|
|
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.
|
|
@@ -2,4 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Disallows using xcss prop inside JavaScript files.
|
|
4
4
|
|
|
5
|
-
This rule is maintained by another package and configured here; refer to
|
|
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,5 +1,8 @@
|
|
|
1
1
|
# @atlaskit/design-system/no-keyframes-tagged-template-expression
|
|
2
2
|
|
|
3
|
-
Disallows any `keyframes` tagged template expressions that originate from a CSS-in-JS library,
|
|
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
|
-
This rule is maintained by another package and configured here; refer to
|
|
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,5 +1,8 @@
|
|
|
1
1
|
# @atlaskit/design-system/no-styled-tagged-template-expression
|
|
2
2
|
|
|
3
|
-
Disallows any `styled` tagged template expressions that originate from from a CSS-in-JS library,
|
|
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`.
|
|
4
5
|
|
|
5
|
-
This rule is maintained by another package and configured here; refer to
|
|
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,12 +1,15 @@
|
|
|
1
1
|
# @compiled/no-suppress-xcss
|
|
2
2
|
|
|
3
|
-
Disallows supressing type violations when using the xcss prop. Supressing type violations will cause
|
|
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.
|
|
4
5
|
|
|
5
|
-
Components that use xcss prop have explicitly declared what styles they should and should not
|
|
6
|
+
Components that use xcss prop have explicitly declared what styles they should and should not
|
|
7
|
+
accept, consumers must adhere to this API.
|
|
6
8
|
|
|
7
9
|
## Incorrect
|
|
8
10
|
|
|
9
|
-
Do not suppress type violations; if the value doesn't match the type, fix the value or expect
|
|
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.
|
|
10
13
|
|
|
11
14
|
```js
|
|
12
15
|
// @ts-expect-error
|
|
@@ -4,10 +4,7 @@ import type { CSSPseudos } from '@compiled/react';
|
|
|
4
4
|
* https://stackoverflow.com/a/71236280
|
|
5
5
|
*/
|
|
6
6
|
type Validate<T extends true> = T;
|
|
7
|
-
type HasAllUnique<Tuple, Union, Seen = never> = Tuple extends readonly [
|
|
8
|
-
infer Head,
|
|
9
|
-
...infer Tail
|
|
10
|
-
] ? Head extends Seen ? {
|
|
7
|
+
type HasAllUnique<Tuple, Union, Seen = never> = Tuple extends readonly [infer Head, ...infer Tail] ? Head extends Seen ? {
|
|
11
8
|
ERROR: ['The following key appears more than once in the tuple:', Head];
|
|
12
9
|
} : HasAllUnique<Tail, Exclude<Union, Head>, Head | Seen> : [Union] extends [never] ? true : {
|
|
13
10
|
ERROR: ['Some keys are missing from the tuple:', Union];
|
package/index.js
CHANGED
|
@@ -6,19 +6,19 @@ const path = require('path');
|
|
|
6
6
|
const paths = require('tsconfig-paths');
|
|
7
7
|
|
|
8
8
|
if (!require.extensions['.ts']) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
// ts-node can only handle being registered once, see https://github.com/TypeStrong/ts-node/issues/409
|
|
10
|
+
require('ts-node').register({
|
|
11
|
+
project: path.join(__dirname, 'tsconfig.json'),
|
|
12
|
+
});
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
try {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
// We programatically register tsconfig paths here so it picks up the tsconfig here
|
|
17
|
+
// instead of in root CWD.
|
|
18
|
+
paths.register(paths.loadConfig(__dirname));
|
|
19
19
|
} catch (e) {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
// eslint-disable-next-line no-console
|
|
21
|
+
console.log(e);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
module.exports = require('./src/index');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/eslint-plugin-ui-styling-standard",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"author": "Atlassian Pty Ltd",
|
|
5
5
|
"description": "The eslint plugin to enforce and educate on Atlassian's UI Styling Standard",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
".": "./src/index.tsx"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@atlaskit/eslint-utils": "^1.
|
|
42
|
+
"@atlaskit/eslint-utils": "^1.6.0",
|
|
43
43
|
"@babel/runtime": "^7.0.0",
|
|
44
44
|
"@typescript-eslint/utils": "^5.48.1",
|
|
45
45
|
"ajv": "^6.12.6",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@af/formatting": "*",
|
|
56
56
|
"@atlaskit/ds-lib": "^2.3.0",
|
|
57
|
-
"@atlaskit/eslint-plugin-design-system": "^10.
|
|
57
|
+
"@atlaskit/eslint-plugin-design-system": "^10.7.0",
|
|
58
58
|
"@atlassian/codegen": "*",
|
|
59
59
|
"@compiled/eslint-plugin": "^0.13.6",
|
|
60
60
|
"@types/eslint": "^8.56.6",
|