@atlaskit/eslint-plugin-ui-styling-standard 0.16.3 → 0.16.5
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/atlaskit-theme/usage.mdx +74 -55
- package/constellation/convert-props-syntax/usage.mdx +29 -24
- package/constellation/enforce-style-prop/usage.mdx +32 -26
- package/constellation/local-cx-xcss/usage.mdx +27 -15
- package/constellation/no-array-arguments/usage.mdx +12 -9
- package/constellation/no-classname-prop/usage.mdx +13 -5
- package/constellation/no-container-queries/usage.mdx +65 -16
- package/constellation/no-dynamic-styles/usage.mdx +16 -11
- package/constellation/no-exported-styles/usage.mdx +25 -30
- package/constellation/no-global-styles/usage.mdx +4 -3
- package/constellation/no-important-styles/usage.mdx +5 -3
- package/constellation/no-imported-style-values/usage.mdx +30 -27
- package/constellation/no-nested-selectors/usage.mdx +51 -18
- package/constellation/no-styled/usage.mdx +17 -14
- package/constellation/no-unsafe-selectors/usage.mdx +184 -58
- package/constellation/no-unsafe-values/usage.mdx +150 -48
- package/constellation/use-compiled/usage.mdx +8 -8
- package/dist/cjs/rules/no-imported-style-values/index.js +50 -2
- package/dist/es2019/rules/no-imported-style-values/index.js +49 -2
- package/dist/esm/rules/no-imported-style-values/index.js +50 -2
- package/package.json +1 -1
- package/src/rules/atlaskit-theme/README.md +74 -55
- package/src/rules/convert-props-syntax/README.md +29 -24
- package/src/rules/enforce-style-prop/README.md +32 -26
- package/src/rules/local-cx-xcss/README.md +27 -15
- package/src/rules/no-array-arguments/README.md +12 -9
- package/src/rules/no-classname-prop/README.md +13 -5
- package/src/rules/no-container-queries/README.md +65 -16
- package/src/rules/no-dynamic-styles/README.md +16 -11
- package/src/rules/no-exported-styles/README.md +25 -30
- package/src/rules/no-global-styles/README.md +4 -3
- package/src/rules/no-important-styles/README.md +5 -3
- package/src/rules/no-imported-style-values/README.md +30 -27
- package/src/rules/no-imported-style-values/__tests__/rule.test.tsx +208 -0
- package/src/rules/no-imported-style-values/index.tsx +51 -4
- package/src/rules/no-nested-selectors/README.md +51 -18
- package/src/rules/no-styled/README.md +17 -14
- package/src/rules/no-unsafe-selectors/README.md +184 -58
- package/src/rules/no-unsafe-values/README.md +150 -48
- package/src/rules/use-compiled/README.md +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/eslint-plugin-ui-styling-standard
|
|
2
2
|
|
|
3
|
+
## 0.16.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#111807](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/111807)
|
|
8
|
+
[`a0bd2ff79dc32`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a0bd2ff79dc32) -
|
|
9
|
+
Fixes `no-imported-style-values` to allow imported identifiers when used in the LHS of conditional
|
|
10
|
+
expressions in the `css` prop. This enables dynamic application of styles using feature flags.
|
|
11
|
+
|
|
12
|
+
## 0.16.4
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#111304](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/111304)
|
|
17
|
+
[`df63ad1ddca6a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/df63ad1ddca6a) -
|
|
18
|
+
Updated rule docs for better clarity and consistency
|
|
19
|
+
|
|
3
20
|
## 0.16.3
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -1,113 +1,132 @@
|
|
|
1
1
|
# atlaskit-theme
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Blocks legacy `@atlaskit/theme` mixins that `@compiled/react` cannot compile. This includes the
|
|
4
|
+
`typography`, `elevation` and `skeletonShimmer` mixins.
|
|
5
5
|
|
|
6
6
|
## Examples
|
|
7
7
|
|
|
8
8
|
### Typography
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Don't use `typography` mixins.
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Use [typography tokens](https://atlassian.design/foundations/typography-beta/applying-typography) or
|
|
13
|
+
the [Heading](https://atlassian.design/components/heading) and
|
|
14
|
+
[Text](https://atlassian.design/components/primitives/text) components.
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
import { styled } from '@compiled/react';
|
|
16
|
-
import { typography } from '@atlaskit/theme';
|
|
17
|
-
|
|
18
|
-
export const HeadingComponent = styled.h2`
|
|
19
|
-
${typography.h200()};
|
|
20
|
-
`;
|
|
21
|
-
```
|
|
16
|
+
#### Incorrect
|
|
22
17
|
|
|
23
18
|
```tsx
|
|
24
|
-
import {
|
|
19
|
+
import { css } from '@compiled/react';
|
|
25
20
|
import { typography } from '@atlaskit/theme';
|
|
26
21
|
|
|
27
|
-
|
|
22
|
+
const titleStyles = css(typography.h700());
|
|
28
23
|
```
|
|
29
24
|
|
|
30
|
-
|
|
25
|
+
#### Correct
|
|
31
26
|
|
|
32
27
|
```tsx
|
|
33
|
-
import {
|
|
28
|
+
import { css } from '@compiled/react';
|
|
29
|
+
import { token } from '@atlaskit/tokens';
|
|
34
30
|
|
|
35
|
-
const
|
|
36
|
-
|
|
31
|
+
const titleStyles = css({
|
|
32
|
+
font: token('font.heading.large'),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const paragraphStyles = css({
|
|
36
|
+
font: token('font.body.large'),
|
|
37
37
|
});
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
```tsx
|
|
41
|
+
import { css } from '@compiled/react';
|
|
41
42
|
import Heading from '@atlaskit/heading';
|
|
43
|
+
import { Stack, Text } from '@atlaskit/primitives';
|
|
42
44
|
import { token } from '@atlaskit/tokens';
|
|
43
|
-
import { styled } from '@compiled/react';
|
|
44
45
|
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
<Heading level="h200" as="h3">
|
|
51
|
-
<TitleComponent {...props} />
|
|
52
|
-
</Heading>
|
|
46
|
+
const Component = () => (
|
|
47
|
+
<Stack>
|
|
48
|
+
<Heading size="large">Title</Heading>
|
|
49
|
+
<Text size="large">Lorem ipsum</Text>
|
|
50
|
+
</Stack>
|
|
53
51
|
);
|
|
54
52
|
```
|
|
55
53
|
|
|
56
54
|
### Elevation
|
|
57
55
|
|
|
58
|
-
|
|
56
|
+
Don't use `elevation` mixins.
|
|
57
|
+
|
|
58
|
+
Use [elevation tokens](https://atlassian.design/foundations/elevation) instead.
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
#### Incorrect
|
|
61
61
|
|
|
62
62
|
```tsx
|
|
63
|
-
import {
|
|
63
|
+
import { css } from '@compiled/react';
|
|
64
64
|
import { elevation } from '@atlaskit/theme';
|
|
65
65
|
|
|
66
|
-
|
|
67
|
-
${elevation.e100()};
|
|
68
|
-
`;
|
|
66
|
+
const cardStyles = css(elevation.e100());
|
|
69
67
|
```
|
|
70
68
|
|
|
71
|
-
|
|
69
|
+
#### Correct
|
|
72
70
|
|
|
73
71
|
```tsx
|
|
74
72
|
import { styled } from '@compiled/react';
|
|
75
73
|
import { token } from '@atlaskit/tokens';
|
|
76
74
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
'0 1px 1px rgba(9,30,66,0.25),0 0 1px 1px rgba(9,30,66,0.13)',
|
|
81
|
-
),
|
|
75
|
+
const cardStyles = css({
|
|
76
|
+
backgroundColor: token('elevation.surface.raised'),
|
|
77
|
+
boxShadow: token('elevation.shadow.raised'),
|
|
82
78
|
});
|
|
83
79
|
```
|
|
84
80
|
|
|
85
81
|
### Skeleton Shimmer
|
|
86
82
|
|
|
87
|
-
|
|
88
|
-
[link](https://staging.atlassian.design/components/skeleton/examples)).
|
|
83
|
+
Don't use the `skeletonShimmer` mixin.
|
|
89
84
|
|
|
90
|
-
|
|
85
|
+
Preview our [Skeleton](https://staging.atlassian.design/components/skeleton/examples) component
|
|
86
|
+
(internal Atlassians only).
|
|
91
87
|
|
|
92
|
-
|
|
88
|
+
Otherwise:
|
|
89
|
+
|
|
90
|
+
- Use the `color.skeleton` and `color.skeleton.subtle` tokens to make your own component.
|
|
91
|
+
- Use `@atlassian/jira-skeletons` when working on Jira (internal Atlassians only).
|
|
92
|
+
|
|
93
|
+
#### Incorrect
|
|
93
94
|
|
|
94
95
|
```tsx
|
|
95
|
-
import {
|
|
96
|
+
import { css } from '@compiled/react';
|
|
96
97
|
import { skeletonShimmer } from '@atlaskit/theme/constants';
|
|
97
98
|
|
|
98
|
-
|
|
99
|
-
${skeletonShimmer};
|
|
100
|
-
`;
|
|
99
|
+
const skeletonStyles = css(skeletonShimmer());
|
|
101
100
|
```
|
|
102
101
|
|
|
103
|
-
|
|
102
|
+
#### Correct
|
|
103
|
+
|
|
104
|
+
```tsx
|
|
105
|
+
import Skeleton from '@atlaskit/skeleton';
|
|
106
|
+
|
|
107
|
+
<Skeleton width="200px" height="16px" isShimmering />;
|
|
108
|
+
```
|
|
104
109
|
|
|
105
110
|
```tsx
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
111
|
+
import { css, keyframes } from '@compiled/react';
|
|
112
|
+
|
|
113
|
+
const shimmer = keyframes({
|
|
114
|
+
from: { backgroundColor: token('color.skeleton') },
|
|
115
|
+
to: { backgroundColor: token('color.skeleton.subtle') },
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const skeletonStyles = css({
|
|
119
|
+
backgroundColor: token('color.skeleton'),
|
|
120
|
+
animationName: shimmer,
|
|
121
|
+
animationDuration: '1.5s',
|
|
122
|
+
animationIterationCount: 'infinite',
|
|
123
|
+
animationTimingFunction: 'linear',
|
|
124
|
+
animationDirection: 'alternate',
|
|
125
|
+
});
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
import { ListSkeleton } from '@atlassian/jira-skeletons';
|
|
130
|
+
|
|
131
|
+
<ListSkeleton numOfRows={3} />;
|
|
113
132
|
```
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
# convert-props-syntax
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
`no-styled-tagged-template-expression`, as output from the latter may use props syntax that results
|
|
6
|
-
in a type error.
|
|
3
|
+
Blocks dynamic styling syntax that is unsupported by `styled-components@<4` and `@emotion/styled`,
|
|
4
|
+
and provides an autofix for converting to a supported syntax.
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
Use this rule alongside `no-styled-tagged-template-expression`, which can output the unsupported
|
|
7
|
+
dynamic styling syntax.
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
This rule applies only to `styled` usages from `styled-components` and `@emotion/styled`.
|
|
10
|
+
|
|
11
|
+
## Autofix
|
|
12
|
+
|
|
13
|
+
The autofix will find style object values that are arrow functions,
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
11
16
|
styled.div({
|
|
12
17
|
color: ({ myColor }) => myColor,
|
|
13
18
|
backgroundColor: (props) => props.someColor,
|
|
@@ -17,7 +22,7 @@ styled.div({
|
|
|
17
22
|
However, refactoring the arrow function so that it is the argument to `styled.div` will fix the
|
|
18
23
|
issue:
|
|
19
24
|
|
|
20
|
-
```
|
|
25
|
+
```tsx
|
|
21
26
|
styled.div((props) => ({
|
|
22
27
|
color: props.myColor,
|
|
23
28
|
backgroundColor: props.someColor,
|
|
@@ -40,47 +45,47 @@ manually fix the output, or migrate the code to `@compiled/react`.
|
|
|
40
45
|
Type annotations in the arrow function are not supported; you will need to remediate the lint error
|
|
41
46
|
manually. For example:
|
|
42
47
|
|
|
43
|
-
```
|
|
48
|
+
```tsx
|
|
44
49
|
type Props = {
|
|
45
|
-
|
|
46
|
-
|
|
50
|
+
myColor: string;
|
|
51
|
+
someColor: string;
|
|
47
52
|
};
|
|
48
53
|
|
|
49
54
|
styled.div({
|
|
50
|
-
|
|
51
|
-
|
|
55
|
+
color: ({ myColor }: Props) => myColor,
|
|
56
|
+
backgroundColor: (props: Props) => props.someColor,
|
|
52
57
|
});
|
|
53
58
|
```
|
|
54
59
|
|
|
55
|
-
|
|
60
|
+
could be refactored as
|
|
56
61
|
|
|
57
|
-
```
|
|
62
|
+
```tsx
|
|
58
63
|
type Props = {
|
|
59
|
-
|
|
60
|
-
|
|
64
|
+
myColor: string;
|
|
65
|
+
someColor: string;
|
|
61
66
|
};
|
|
62
67
|
|
|
63
68
|
styled.div((props: Props) => ({
|
|
64
|
-
|
|
65
|
-
|
|
69
|
+
color: props.myColor,
|
|
70
|
+
backgroundColor: props.someColor,
|
|
66
71
|
}));
|
|
67
72
|
```
|
|
68
73
|
|
|
69
|
-
### Special syntax in
|
|
74
|
+
### Special syntax in function parameters
|
|
70
75
|
|
|
71
76
|
Rest elements, default values, and so on in the parameter of an arrow function will need to be
|
|
72
77
|
remediated manually. For example:
|
|
73
78
|
|
|
74
|
-
```
|
|
79
|
+
```tsx
|
|
75
80
|
styled.div({
|
|
76
81
|
color: ({ myColor = '#fff' }) => myColor,
|
|
77
82
|
backgroundColor: ({ myColor = '#aaa' }) => myColor,
|
|
78
83
|
});
|
|
79
84
|
```
|
|
80
85
|
|
|
81
|
-
could
|
|
86
|
+
could be refactored as
|
|
82
87
|
|
|
83
|
-
```
|
|
88
|
+
```tsx
|
|
84
89
|
styled.div((props) => ({
|
|
85
90
|
color: myColor ?? '#fff',
|
|
86
91
|
backgroundColor: myColor ?? '#aaa',
|
|
@@ -91,7 +96,7 @@ styled.div((props) => ({
|
|
|
91
96
|
|
|
92
97
|
### Incorrect
|
|
93
98
|
|
|
94
|
-
```
|
|
99
|
+
```tsx
|
|
95
100
|
import styled from 'styled-components';
|
|
96
101
|
|
|
97
102
|
styled.div({
|
|
@@ -106,7 +111,7 @@ styled.div({
|
|
|
106
111
|
|
|
107
112
|
### Correct
|
|
108
113
|
|
|
109
|
-
```
|
|
114
|
+
```tsx
|
|
110
115
|
import styled from '@emotion/styled';
|
|
111
116
|
|
|
112
117
|
styled.div((props) => ({
|
|
@@ -1,41 +1,47 @@
|
|
|
1
1
|
# enforce-style-prop
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Blocks providing static values through the `style` prop, which should only be used to provide
|
|
4
|
+
dynamic values (values unknown at build time).
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
time, e.g. `<div style={{ width: props.width }}>`. No statics values such as numbers, strings or any
|
|
7
|
-
other statically analysable values should be passed to the `style` attribute. Instead, static CSS
|
|
8
|
-
values should be passed into the `css` prop in JSX components.
|
|
6
|
+
Use the `css` prop for providing static values instead.
|
|
9
7
|
|
|
10
8
|
## Examples
|
|
11
9
|
|
|
12
10
|
### Incorrect
|
|
13
11
|
|
|
14
12
|
```tsx
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
import { token } from '@atlaskit/tokens';
|
|
14
|
+
|
|
15
|
+
const Component = () => (
|
|
16
|
+
<div
|
|
17
|
+
style={{
|
|
18
|
+
margin: 0,
|
|
19
|
+
color: token('color.text.danger'),
|
|
20
|
+
}}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
25
23
|
```
|
|
26
24
|
|
|
27
25
|
### Correct
|
|
28
26
|
|
|
27
|
+
Although `token` is a function call, it is statically resolvable by Compiled and should not be used
|
|
28
|
+
in the `style` prop.
|
|
29
|
+
|
|
29
30
|
```tsx
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
import { css } from '@compiled/react';
|
|
32
|
+
import { token } from '@atlaskit/tokens';
|
|
33
|
+
|
|
34
|
+
type Props = { width: string };
|
|
35
|
+
|
|
36
|
+
const baseStyles = css({ margin: 0, color: token('color.text.danger') });
|
|
37
|
+
|
|
38
|
+
const Component = ({ width }: Props) => (
|
|
39
|
+
<div
|
|
40
|
+
css={baseStyles}
|
|
41
|
+
style={{
|
|
42
|
+
width: props.width,
|
|
43
|
+
'--my-nested-width': props.width,
|
|
44
|
+
}}
|
|
45
|
+
/>
|
|
46
|
+
);
|
|
41
47
|
```
|
|
@@ -1,25 +1,37 @@
|
|
|
1
1
|
# local-cx-xcss
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
styles are applied
|
|
3
|
+
Blocks the `cx()` function from being used outside of the `xcss` prop. This aids tracking which
|
|
4
|
+
styles are applied.
|
|
5
5
|
|
|
6
|
-
|
|
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:
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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`.
|
|
12
23
|
|
|
13
24
|
## Examples
|
|
14
25
|
|
|
15
26
|
### Incorrect
|
|
16
27
|
|
|
17
|
-
```
|
|
18
|
-
import {
|
|
28
|
+
```tsx
|
|
29
|
+
import { cssMap, cx } from '@compiled/react';
|
|
30
|
+
import { token } from '@atlaskit/tokens';
|
|
19
31
|
|
|
20
32
|
const styles = cssMap({
|
|
21
|
-
text: { color: '
|
|
22
|
-
bg: { background: '
|
|
33
|
+
text: { color: token('color.text') },
|
|
34
|
+
bg: { background: token('color.background.neutral') },
|
|
23
35
|
});
|
|
24
36
|
|
|
25
37
|
const joinedStyles = cx(styles.text, styles.bg);
|
|
@@ -29,12 +41,12 @@ const joinedStyles = cx(styles.text, styles.bg);
|
|
|
29
41
|
|
|
30
42
|
### Correct
|
|
31
43
|
|
|
32
|
-
```
|
|
33
|
-
import {
|
|
44
|
+
```tsx
|
|
45
|
+
import { cssMap, cx } from '@compiled/react';
|
|
34
46
|
|
|
35
47
|
const styles = cssMap({
|
|
36
|
-
text: { color: '
|
|
37
|
-
bg: { background: '
|
|
48
|
+
text: { color: token('color.text') },
|
|
49
|
+
bg: { background: token('color.background.neutral') },
|
|
38
50
|
});
|
|
39
51
|
|
|
40
52
|
<Button xcss={cx(styles.text, styles.bg)} />;
|
|
@@ -1,38 +1,42 @@
|
|
|
1
1
|
# no-array-arguments
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Blocks passing array arguments to style declaration functions.
|
|
4
4
|
|
|
5
5
|
## Examples
|
|
6
6
|
|
|
7
7
|
### Incorrect
|
|
8
8
|
|
|
9
|
-
```
|
|
9
|
+
```tsx
|
|
10
10
|
import { css } from '@compiled/react';
|
|
11
|
+
|
|
11
12
|
const styles = css([{ width: 100 }, { height: 100 }]);
|
|
12
13
|
```
|
|
13
14
|
|
|
14
|
-
```
|
|
15
|
+
```tsx
|
|
15
16
|
import { styled } from '@compiled/react';
|
|
17
|
+
|
|
16
18
|
const styles = css([{ width: 100 }, ...items]);
|
|
17
19
|
```
|
|
18
20
|
|
|
19
21
|
### Correct
|
|
20
22
|
|
|
21
|
-
```
|
|
23
|
+
```tsx
|
|
22
24
|
import { css } from '@compiled/react';
|
|
25
|
+
|
|
23
26
|
const styles = css({ width: 100 }, { height: 100 });
|
|
24
27
|
```
|
|
25
28
|
|
|
26
|
-
```
|
|
29
|
+
```tsx
|
|
27
30
|
import { css } from '@compiled/react';
|
|
31
|
+
|
|
28
32
|
const styles = css({ width: 100 }, ...items);
|
|
29
33
|
```
|
|
30
34
|
|
|
31
35
|
## Options
|
|
32
36
|
|
|
33
|
-
### importSources
|
|
37
|
+
### `importSources: string[]`
|
|
34
38
|
|
|
35
|
-
By default, this rule will check
|
|
39
|
+
By default, this rule will check styles using:
|
|
36
40
|
|
|
37
41
|
- `@atlaskit/css`
|
|
38
42
|
- `@atlaskit/primitives`
|
|
@@ -42,5 +46,4 @@ By default, this rule will check `css` usages from:
|
|
|
42
46
|
- `@emotion/styled`
|
|
43
47
|
- `styled-components`
|
|
44
48
|
|
|
45
|
-
|
|
46
|
-
array of package names (strings).
|
|
49
|
+
Override this list with the `importSources` option, which accepts an array of package names.
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
# no-classname-prop
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Blocks the `className` prop, which encourages unsafe global styles and cannot be statically
|
|
4
|
+
resolved.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
via local tooling. Use props for configuration and typical CSS-in-JS for styling or `xcss` for
|
|
7
|
-
bounded overrides.
|
|
6
|
+
Use the `css` prop for styling, with props for configuration and `xcss` for bounded overrides.
|
|
8
7
|
|
|
9
8
|
## Examples
|
|
10
9
|
|
|
@@ -22,14 +21,23 @@ bounded overrides.
|
|
|
22
21
|
|
|
23
22
|
```tsx
|
|
24
23
|
import { css } from '@compiled/react';
|
|
24
|
+
import { token } from '@atlaskit/tokens';
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
const myStyles = css({ padding: token('space.100') });
|
|
27
|
+
|
|
28
|
+
<div css={myStyles} />;
|
|
27
29
|
```
|
|
28
30
|
|
|
29
31
|
```tsx
|
|
30
32
|
<MyComponent isDisabled={isDisabled} />
|
|
31
33
|
```
|
|
32
34
|
|
|
35
|
+
```tsx
|
|
36
|
+
import { Checkbox } from '@atlaskit/checkbox';
|
|
37
|
+
|
|
38
|
+
<Checkbox xcss={{ alignItems: 'center' }} />;
|
|
39
|
+
```
|
|
40
|
+
|
|
33
41
|
## FAQ
|
|
34
42
|
|
|
35
43
|
### What if I'm using `className` to target elements with JavaScript?
|
|
@@ -1,44 +1,94 @@
|
|
|
1
1
|
# no-container-queries
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Blocks `@container` at-rules
|
|
4
|
+
([container queries](https://developer.mozilla.org/en-US/docs/Web/CSS/@container)), which are
|
|
5
|
+
unsafe.
|
|
4
6
|
|
|
5
|
-
Container queries
|
|
6
|
-
and isn’t fully supported across our frontend tech stacks.
|
|
7
|
+
Container queries are unsafe because they:
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
- break the rules of scope
|
|
10
|
+
- aren't deterministic
|
|
11
|
+
- aren't type-safe
|
|
12
|
+
- aren't fully supported across our frontend tech stacks
|
|
13
|
+
|
|
14
|
+
Use [media queries](https://atlassian.design/components/primitives/responsive/breakpoints/examples),
|
|
15
|
+
a
|
|
16
|
+
[WidthObserver](https://atlaskit.atlassian.com/packages/design-system/width-detector/docs/migration-guide),
|
|
17
|
+
or a custom [ResizeObserver](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver)
|
|
18
|
+
instead.
|
|
9
19
|
|
|
10
20
|
## Examples
|
|
11
21
|
|
|
12
22
|
### Incorrect
|
|
13
23
|
|
|
14
|
-
```
|
|
24
|
+
```tsx
|
|
15
25
|
import { css } from '@compiled/react';
|
|
26
|
+
import { token } from '@atlaskit/tokens';
|
|
16
27
|
|
|
17
|
-
const
|
|
28
|
+
const headingStyles = css({
|
|
18
29
|
'@container (width > 400px)': {
|
|
19
|
-
|
|
20
|
-
fontSize: '1.5rem',
|
|
21
|
-
},
|
|
30
|
+
font: token('font.heading.large'),
|
|
22
31
|
},
|
|
23
32
|
});
|
|
24
33
|
```
|
|
25
34
|
|
|
26
35
|
### Correct
|
|
27
36
|
|
|
28
|
-
|
|
37
|
+
#### Media queries
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
29
40
|
import { css } from '@compiled/react';
|
|
41
|
+
import { media } from '@atlaskit/primitives/responsive';
|
|
42
|
+
import { token } from '@atlaskit/tokens';
|
|
43
|
+
|
|
44
|
+
const headingStyles = css({
|
|
45
|
+
[media.above.sm]: {
|
|
46
|
+
font: token('font.heading.large'),
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
#### WidthObserver
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import { useState } from 'react';
|
|
55
|
+
import { css, cssMap } from '@compiled/react';
|
|
56
|
+
import throttle from 'lodash/throttle';
|
|
57
|
+
import { WidthObserver } from '@atlaskit/width-detector';
|
|
58
|
+
import { token } from '@atlaskit/tokens';
|
|
30
59
|
|
|
31
60
|
const containerStyles = css({
|
|
32
|
-
|
|
33
|
-
|
|
61
|
+
// Required for the `WidthObserver`, which is absolutely positioned
|
|
62
|
+
position: 'relative',
|
|
34
63
|
});
|
|
64
|
+
|
|
65
|
+
const headingStyles = cssMap({
|
|
66
|
+
small: {
|
|
67
|
+
font: token('font.heading.small'),
|
|
68
|
+
},
|
|
69
|
+
large: {
|
|
70
|
+
font: token('font.heading.large'),
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const ResponsiveH2 = () => {
|
|
75
|
+
const [width = 0, setWidth] = useState<number | undefined>(undefined);
|
|
76
|
+
const throttledSetWidth = throttle(setWidth, 50);
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<div css={containerStyles}>
|
|
80
|
+
<WidthObserver setWidth={throttledSetWidth} />
|
|
81
|
+
<h2 css={width < 400 ? headingStyles.small : headingStyles.large}>Title</h2>
|
|
82
|
+
</div>
|
|
83
|
+
);
|
|
84
|
+
};
|
|
35
85
|
```
|
|
36
86
|
|
|
37
87
|
## Options
|
|
38
88
|
|
|
39
|
-
### importSources
|
|
89
|
+
### `importSources: string[]`
|
|
40
90
|
|
|
41
|
-
By default, this rule will check
|
|
91
|
+
By default, this rule will check styles using:
|
|
42
92
|
|
|
43
93
|
- `@atlaskit/css`
|
|
44
94
|
- `@atlaskit/primitives`
|
|
@@ -48,5 +98,4 @@ By default, this rule will check `css` usages from:
|
|
|
48
98
|
- `@emotion/styled`
|
|
49
99
|
- `styled-components`
|
|
50
100
|
|
|
51
|
-
|
|
52
|
-
array of package names (strings).
|
|
101
|
+
Override this list with the `importSources` option, which accepts an array of package names.
|