@atlaskit/eslint-plugin-ui-styling-standard 0.15.0 → 0.15.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.
- package/CHANGELOG.md +189 -172
- package/constellation/atlaskit-theme/usage.mdx +17 -17
- package/constellation/convert-props-syntax/usage.mdx +14 -14
- package/constellation/enforce-style-prop/usage.mdx +17 -17
- package/constellation/index/overview.mdx +70 -70
- package/constellation/local-cx-xcss/usage.mdx +4 -4
- package/constellation/no-array-arguments/usage.mdx +7 -7
- package/constellation/no-container-queries/usage.mdx +14 -14
- package/constellation/no-dynamic-styles/usage.mdx +19 -19
- package/constellation/no-exported-styles/usage.mdx +15 -15
- package/constellation/no-global-styles/usage.mdx +13 -13
- package/constellation/no-important-styles/usage.mdx +2 -2
- package/constellation/no-imported-style-values/usage.mdx +16 -16
- package/constellation/no-nested-selectors/usage.mdx +18 -18
- package/constellation/no-styled/usage.mdx +6 -6
- package/constellation/no-unsafe-selectors/usage.mdx +90 -90
- package/constellation/no-unsafe-values/usage.mdx +33 -33
- package/dist/cjs/index.codegen.js +1 -1
- package/dist/cjs/presets/all.codegen.js +1 -1
- package/dist/cjs/presets/recommended.codegen.js +1 -1
- package/dist/cjs/rules/index.codegen.js +1 -1
- package/dist/cjs/rules/no-nested-selectors/index.js +68 -49
- package/dist/cjs/rules/no-unsafe-selectors/index.js +4 -1
- package/dist/cjs/rules/no-unsafe-selectors/lint-selector.js +10 -1
- package/dist/es2019/index.codegen.js +1 -1
- package/dist/es2019/presets/all.codegen.js +1 -1
- package/dist/es2019/presets/recommended.codegen.js +1 -1
- package/dist/es2019/rules/index.codegen.js +1 -1
- package/dist/es2019/rules/no-nested-selectors/index.js +63 -45
- package/dist/es2019/rules/no-unsafe-selectors/index.js +4 -1
- package/dist/es2019/rules/no-unsafe-selectors/lint-selector.js +10 -1
- package/dist/esm/index.codegen.js +1 -1
- package/dist/esm/presets/all.codegen.js +1 -1
- package/dist/esm/presets/recommended.codegen.js +1 -1
- package/dist/esm/rules/index.codegen.js +1 -1
- package/dist/esm/rules/no-nested-selectors/index.js +64 -49
- package/dist/esm/rules/no-unsafe-selectors/index.js +4 -1
- package/dist/esm/rules/no-unsafe-selectors/lint-selector.js +10 -1
- package/dist/types/presets/all.codegen.d.ts +1 -1
- package/dist/types/presets/recommended.codegen.d.ts +1 -1
- package/dist/types/rules/no-unsafe-selectors/lint-selector.d.ts +1 -0
- package/dist/types-ts4.5/presets/all.codegen.d.ts +1 -1
- package/dist/types-ts4.5/presets/recommended.codegen.d.ts +1 -1
- package/dist/types-ts4.5/rules/no-unsafe-selectors/lint-selector.d.ts +1 -0
- package/package.json +2 -4
- package/src/index.codegen.tsx +3 -3
- package/src/presets/all.codegen.tsx +70 -73
- package/src/presets/recommended.codegen.tsx +70 -73
- package/src/rules/index.codegen.tsx +18 -18
- package/src/rules/no-nested-selectors/__tests__/rule.test.tsx +93 -56
- package/src/rules/no-nested-selectors/index.tsx +92 -105
- package/src/rules/no-unsafe-selectors/__tests__/no-ambiguous-pseudos.test.tsx +211 -201
- package/src/rules/no-unsafe-selectors/index.tsx +174 -177
- package/src/rules/no-unsafe-selectors/lint-selector.tsx +128 -141
- package/tsconfig.app.json +45 -45
- package/tsconfig.dev.json +43 -43
|
@@ -13,12 +13,12 @@ resolvable.
|
|
|
13
13
|
import { Global } from '@emotion/react';
|
|
14
14
|
|
|
15
15
|
<Global
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
styles={{
|
|
17
|
+
'.some-class': {
|
|
18
|
+
fontSize: 50,
|
|
19
|
+
textAlign: 'center',
|
|
20
|
+
},
|
|
21
|
+
}}
|
|
22
22
|
/>;
|
|
23
23
|
```
|
|
24
24
|
|
|
@@ -26,9 +26,9 @@ import { Global } from '@emotion/react';
|
|
|
26
26
|
import { createGlobalStyle } from 'styled-components';
|
|
27
27
|
|
|
28
28
|
const GlobalStyle = createGlobalStyle({
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
body: {
|
|
30
|
+
margin: 0,
|
|
31
|
+
},
|
|
32
32
|
});
|
|
33
33
|
```
|
|
34
34
|
|
|
@@ -36,15 +36,15 @@ const GlobalStyle = createGlobalStyle({
|
|
|
36
36
|
import { injectGlobal } from 'styled-components';
|
|
37
37
|
|
|
38
38
|
injectGlobal({
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
body: {
|
|
40
|
+
margin: 0,
|
|
41
|
+
},
|
|
42
42
|
});
|
|
43
43
|
```
|
|
44
44
|
|
|
45
45
|
```tsx
|
|
46
46
|
<style>
|
|
47
|
-
|
|
47
|
+
{`
|
|
48
48
|
.some-class {
|
|
49
49
|
color: red;
|
|
50
50
|
}
|
|
@@ -16,7 +16,7 @@ The use of `!important` is a code smell and greatly impacts readability and dete
|
|
|
16
16
|
import { css } from '@compiled/react';
|
|
17
17
|
|
|
18
18
|
const styles = css({
|
|
19
|
-
|
|
19
|
+
color: 'red!important',
|
|
20
20
|
});
|
|
21
21
|
```
|
|
22
22
|
|
|
@@ -26,6 +26,6 @@ const styles = css({
|
|
|
26
26
|
import { css } from '@compiled/react';
|
|
27
27
|
|
|
28
28
|
const styles = css({
|
|
29
|
-
|
|
29
|
+
color: 'red',
|
|
30
30
|
});
|
|
31
31
|
```
|
|
@@ -17,8 +17,8 @@ import { css } from '@compiled/react';
|
|
|
17
17
|
import { colors, getColor } from '@mui/theme';
|
|
18
18
|
|
|
19
19
|
const styles = css({
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
[colorKey]: getColor('red'),
|
|
21
|
+
background: colors['red'],
|
|
22
22
|
});
|
|
23
23
|
```
|
|
24
24
|
|
|
@@ -30,10 +30,10 @@ import { ff } from '@atlaskit/ff';
|
|
|
30
30
|
const sharedObject = { padding: 0 };
|
|
31
31
|
|
|
32
32
|
const styles = css({
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
...cssShared,
|
|
34
|
+
...sharedObject,
|
|
35
|
+
height: `${HEIGHT}px`,
|
|
36
|
+
width: ff('…') ? `${HEIGHT}px` : undefined,
|
|
37
37
|
});
|
|
38
38
|
```
|
|
39
39
|
|
|
@@ -44,7 +44,7 @@ import { css } from '@compiled/react';
|
|
|
44
44
|
import { buttonStyles } from '../shared';
|
|
45
45
|
|
|
46
46
|
const styles = css({
|
|
47
|
-
|
|
47
|
+
color: 'red',
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
export default () => <div css={[styles, buttonStyles]} />;
|
|
@@ -68,8 +68,8 @@ import { css } from '@compiled/react';
|
|
|
68
68
|
import { token } from '@atlaskit/tokens';
|
|
69
69
|
|
|
70
70
|
const styles = css({
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
color: 'red',
|
|
72
|
+
padding: token('space.150'),
|
|
73
73
|
});
|
|
74
74
|
export const Component = ({ children }) => <div css={styles}>{children}></div>;
|
|
75
75
|
```
|
|
@@ -142,13 +142,13 @@ Default imports are not currently supported.
|
|
|
142
142
|
|
|
143
143
|
By default, this rule will check `css` usages from:
|
|
144
144
|
|
|
145
|
-
-
|
|
146
|
-
-
|
|
147
|
-
-
|
|
148
|
-
-
|
|
149
|
-
-
|
|
150
|
-
-
|
|
151
|
-
-
|
|
145
|
+
- `@atlaskit/css`
|
|
146
|
+
- `@atlaskit/primitives`
|
|
147
|
+
- `@compiled/react`
|
|
148
|
+
- `@emotion/react`
|
|
149
|
+
- `@emotion/core`
|
|
150
|
+
- `@emotion/styled`
|
|
151
|
+
- `styled-components`
|
|
152
152
|
|
|
153
153
|
To change this list of libraries, you can define a custom set of `importSources`, which accepts an
|
|
154
154
|
array of package names (strings).
|
|
@@ -10,27 +10,27 @@ any child elements or elements that require context from other elements.
|
|
|
10
10
|
```js
|
|
11
11
|
import { css } from '@compiled/react';
|
|
12
12
|
const styles = css({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
h2: {
|
|
14
|
+
fontSize: '1.5rem',
|
|
15
|
+
},
|
|
16
16
|
});
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
```js
|
|
20
20
|
import { styled } from '@compiled/react';
|
|
21
21
|
const Component = styled.div({
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
'*': {
|
|
23
|
+
padding: 0,
|
|
24
|
+
},
|
|
25
25
|
});
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
```js
|
|
29
29
|
import { styled } from '@compiled/react';
|
|
30
30
|
const Component = styled.div({
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
'.myclass': {
|
|
32
|
+
padding: 0,
|
|
33
|
+
},
|
|
34
34
|
});
|
|
35
35
|
```
|
|
36
36
|
|
|
@@ -39,8 +39,8 @@ const Component = styled.div({
|
|
|
39
39
|
```js
|
|
40
40
|
import { css } from '@compiled/react';
|
|
41
41
|
const styles = css({
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
display: 'flex',
|
|
43
|
+
flexDirection: 'column',
|
|
44
44
|
});
|
|
45
45
|
```
|
|
46
46
|
|
|
@@ -50,13 +50,13 @@ const styles = css({
|
|
|
50
50
|
|
|
51
51
|
By default, this rule will check `css` usages from:
|
|
52
52
|
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
53
|
+
- `@atlaskit/css`
|
|
54
|
+
- `@atlaskit/primitives`
|
|
55
|
+
- `@compiled/react`
|
|
56
|
+
- `@emotion/react`
|
|
57
|
+
- `@emotion/core`
|
|
58
|
+
- `@emotion/styled`
|
|
59
|
+
- `styled-components`
|
|
60
60
|
|
|
61
61
|
To change this list of libraries, you can define a custom set of `importSources`, which accepts an
|
|
62
62
|
array of package names (strings).
|
|
@@ -12,7 +12,7 @@ Avoid usages of styled, eg. `styled.div`, `styled('div')`, `styled(Component)`,
|
|
|
12
12
|
import styled from 'styled-components';
|
|
13
13
|
|
|
14
14
|
const Component = styled.div`
|
|
15
|
-
|
|
15
|
+
color: red;
|
|
16
16
|
`;
|
|
17
17
|
export default styled.div({ color: 'red' });
|
|
18
18
|
```
|
|
@@ -35,7 +35,7 @@ export const ComponentTwo = styled3(Component)({ … });
|
|
|
35
35
|
import styled from 'styled-components';
|
|
36
36
|
|
|
37
37
|
export default styled.div.attrs((props) => ({ 'data-testid': props.testId }))({
|
|
38
|
-
|
|
38
|
+
color: 'red',
|
|
39
39
|
});
|
|
40
40
|
```
|
|
41
41
|
|
|
@@ -43,7 +43,7 @@ export default styled.div.attrs((props) => ({ 'data-testid': props.testId }))({
|
|
|
43
43
|
import styled from 'styled-components';
|
|
44
44
|
|
|
45
45
|
export default styled.div.attrs((props) => ({ 'data-testid': props.testId }))`
|
|
46
|
-
|
|
46
|
+
color: red;
|
|
47
47
|
`;
|
|
48
48
|
```
|
|
49
49
|
|
|
@@ -55,7 +55,7 @@ import { css, jsx } from '@emotion/react';
|
|
|
55
55
|
const styles = css({ color: 'red' });
|
|
56
56
|
|
|
57
57
|
const Component = ({ children }) => {
|
|
58
|
-
|
|
58
|
+
return <div css={styles}>{children}</div>;
|
|
59
59
|
};
|
|
60
60
|
```
|
|
61
61
|
|
|
@@ -64,11 +64,11 @@ const Component = ({ children }) => {
|
|
|
64
64
|
import { Box, xcss } from '@atlaskit/primitives';
|
|
65
65
|
|
|
66
66
|
const styles = xcss({
|
|
67
|
-
|
|
67
|
+
color: 'color.text.subtlest',
|
|
68
68
|
});
|
|
69
69
|
|
|
70
70
|
const Component = ({ children }) => {
|
|
71
|
-
|
|
71
|
+
return <Box xcss={styles}>{children}</Box>;
|
|
72
72
|
};
|
|
73
73
|
```
|
|
74
74
|
|
|
@@ -19,14 +19,14 @@ Use the `keyframes` CSS-in-JS API instead.
|
|
|
19
19
|
|
|
20
20
|
```ts
|
|
21
21
|
css({
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
'@keyframes fadeIn': {
|
|
23
|
+
from: {
|
|
24
|
+
opacity: 0,
|
|
25
|
+
},
|
|
26
|
+
to: {
|
|
27
|
+
opacity: 1,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
30
|
});
|
|
31
31
|
```
|
|
32
32
|
|
|
@@ -38,12 +38,12 @@ _Auto-fixer is available for this violation._
|
|
|
38
38
|
|
|
39
39
|
```ts
|
|
40
40
|
css({
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
':after': {
|
|
42
|
+
content: '""',
|
|
43
|
+
width: 100,
|
|
44
|
+
height: 100,
|
|
45
|
+
backgroundColor: 'red',
|
|
46
|
+
},
|
|
47
47
|
});
|
|
48
48
|
```
|
|
49
49
|
|
|
@@ -53,9 +53,9 @@ Use styles that do not require increased specificity.
|
|
|
53
53
|
|
|
54
54
|
```ts
|
|
55
55
|
css({
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
'&&': {
|
|
57
|
+
color: 'red',
|
|
58
|
+
},
|
|
59
59
|
});
|
|
60
60
|
```
|
|
61
61
|
|
|
@@ -63,11 +63,11 @@ css({
|
|
|
63
63
|
|
|
64
64
|
```ts
|
|
65
65
|
css({
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
66
|
+
'@scope (.article-body) to (figure)': {
|
|
67
|
+
img: {
|
|
68
|
+
display: 'block',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
71
|
});
|
|
72
72
|
```
|
|
73
73
|
|
|
@@ -75,9 +75,9 @@ css({
|
|
|
75
75
|
|
|
76
76
|
```ts
|
|
77
77
|
css({
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
'&:first-child': {
|
|
79
|
+
width: 100,
|
|
80
|
+
},
|
|
81
81
|
});
|
|
82
82
|
```
|
|
83
83
|
|
|
@@ -100,24 +100,24 @@ _Auto-fixer is available for this violation. By default a nesting selector `&` i
|
|
|
100
100
|
|
|
101
101
|
```ts
|
|
102
102
|
css({
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
103
|
+
/**
|
|
104
|
+
* This pseudo-class has no leading selector and is ambiguous.
|
|
105
|
+
*/
|
|
106
|
+
':hover': {},
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* In some contexts the above is treated as implicitly containing a nesting selector.
|
|
110
|
+
*/
|
|
111
|
+
'&:hover': {},
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* In other contexts it is treated as a descendant selector.
|
|
115
|
+
*
|
|
116
|
+
* (The selectors below are equivalent.)
|
|
117
|
+
*/
|
|
118
|
+
'*:hover': {},
|
|
119
|
+
'& :hover': {},
|
|
120
|
+
'& *:hover': {},
|
|
121
121
|
});
|
|
122
122
|
```
|
|
123
123
|
|
|
@@ -129,12 +129,12 @@ Write flattened at-rules instead.
|
|
|
129
129
|
|
|
130
130
|
```ts
|
|
131
131
|
cssMap({
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
132
|
+
success: {
|
|
133
|
+
'@media': {
|
|
134
|
+
'(min-width: 900px)': {},
|
|
135
|
+
'(min-width: 1200px)': {},
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
138
|
});
|
|
139
139
|
```
|
|
140
140
|
|
|
@@ -146,13 +146,13 @@ Refactor your styles so it is not required.
|
|
|
146
146
|
|
|
147
147
|
```ts
|
|
148
148
|
cssMap({
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
149
|
+
success: {
|
|
150
|
+
selectors: {
|
|
151
|
+
'&:not(:active)': {
|
|
152
|
+
backgroundColor: 'white',
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
156
|
});
|
|
157
157
|
```
|
|
158
158
|
|
|
@@ -160,61 +160,61 @@ cssMap({
|
|
|
160
160
|
|
|
161
161
|
```ts
|
|
162
162
|
const fadeIn = keyframes({
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
163
|
+
from: {
|
|
164
|
+
opacity: 0,
|
|
165
|
+
},
|
|
166
|
+
to: {
|
|
167
|
+
opacity: 1,
|
|
168
|
+
},
|
|
169
169
|
});
|
|
170
170
|
|
|
171
171
|
css({
|
|
172
|
-
|
|
172
|
+
animationName: fadeIn,
|
|
173
173
|
});
|
|
174
174
|
```
|
|
175
175
|
|
|
176
176
|
```ts
|
|
177
177
|
css({
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
178
|
+
'::after': {
|
|
179
|
+
content: '""',
|
|
180
|
+
width: 100,
|
|
181
|
+
height: 100,
|
|
182
|
+
backgroundColor: 'red',
|
|
183
|
+
},
|
|
184
184
|
});
|
|
185
185
|
```
|
|
186
186
|
|
|
187
187
|
```ts
|
|
188
188
|
css({
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
189
|
+
'&:first-of-type': {
|
|
190
|
+
width: 100,
|
|
191
|
+
},
|
|
192
192
|
});
|
|
193
193
|
```
|
|
194
194
|
|
|
195
195
|
```ts
|
|
196
196
|
css({
|
|
197
|
-
|
|
197
|
+
'&:hover': {},
|
|
198
198
|
});
|
|
199
199
|
```
|
|
200
200
|
|
|
201
201
|
```ts
|
|
202
202
|
cssMap({
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
203
|
+
success: {
|
|
204
|
+
'@media (min-width: 900px)': {},
|
|
205
|
+
'@media (min-width: 1200px)': {},
|
|
206
|
+
},
|
|
207
207
|
});
|
|
208
208
|
```
|
|
209
209
|
|
|
210
210
|
```ts
|
|
211
211
|
cssMap({
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
212
|
+
success: {
|
|
213
|
+
backgroundColor: 'white',
|
|
214
|
+
'&:active': {
|
|
215
|
+
backgroundColor: 'green',
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
218
|
});
|
|
219
219
|
```
|
|
220
220
|
|
|
@@ -224,13 +224,13 @@ cssMap({
|
|
|
224
224
|
|
|
225
225
|
By default, this rule will check `css` usages from:
|
|
226
226
|
|
|
227
|
-
-
|
|
228
|
-
-
|
|
229
|
-
-
|
|
230
|
-
-
|
|
231
|
-
-
|
|
232
|
-
-
|
|
233
|
-
-
|
|
227
|
+
- `@atlaskit/css`
|
|
228
|
+
- `@atlaskit/primitives`
|
|
229
|
+
- `@compiled/react`
|
|
230
|
+
- `@emotion/react`
|
|
231
|
+
- `@emotion/core`
|
|
232
|
+
- `@emotion/styled`
|
|
233
|
+
- `styled-components`
|
|
234
234
|
|
|
235
235
|
To change this list of libraries, you can define a custom set of `importSources`, which accepts an
|
|
236
236
|
array of package names (strings). This will override the built-in allow-list.
|
|
@@ -15,7 +15,7 @@ Function calls are not allowed as arguments or as values, unless they are specif
|
|
|
15
15
|
import { css } from '@compiled/react';
|
|
16
16
|
|
|
17
17
|
function getStyles() {
|
|
18
|
-
|
|
18
|
+
return { width: 100 };
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
const styles = css(getStyles());
|
|
@@ -25,11 +25,11 @@ const styles = css(getStyles());
|
|
|
25
25
|
import { css } from '@compiled/react';
|
|
26
26
|
|
|
27
27
|
function getWidth() {
|
|
28
|
-
|
|
28
|
+
return 100;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
const styles = css({
|
|
32
|
-
|
|
32
|
+
width: getWidth(),
|
|
33
33
|
});
|
|
34
34
|
```
|
|
35
35
|
|
|
@@ -43,12 +43,12 @@ import { css } from '@compiled/react';
|
|
|
43
43
|
import { SELECTOR } from 'my-package';
|
|
44
44
|
|
|
45
45
|
const styles = css({
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
46
|
+
[SELECTOR]: {
|
|
47
|
+
color: 'red',
|
|
48
|
+
},
|
|
49
|
+
[`${SELECTOR} > p`]: {
|
|
50
|
+
width: 100,
|
|
51
|
+
},
|
|
52
52
|
});
|
|
53
53
|
```
|
|
54
54
|
|
|
@@ -56,19 +56,19 @@ const styles = css({
|
|
|
56
56
|
|
|
57
57
|
Variables are not allowed as values, unless they:
|
|
58
58
|
|
|
59
|
-
-
|
|
60
|
-
-
|
|
59
|
+
- Have a simple, static value
|
|
60
|
+
- Are defined in the same file
|
|
61
61
|
|
|
62
62
|
```tsx
|
|
63
63
|
import { css } from '@compiled/react';
|
|
64
64
|
import { SELECTOR } from 'my-package';
|
|
65
65
|
|
|
66
66
|
function myFunction() {
|
|
67
|
-
|
|
67
|
+
return '5px';
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
const styles = css({
|
|
71
|
-
|
|
71
|
+
height: myFunction,
|
|
72
72
|
});
|
|
73
73
|
```
|
|
74
74
|
|
|
@@ -81,11 +81,11 @@ import { css } from '@compiled/react';
|
|
|
81
81
|
import { token } from '@atlaskit/tokens';
|
|
82
82
|
|
|
83
83
|
const colors = {
|
|
84
|
-
|
|
84
|
+
text: token('color.text'),
|
|
85
85
|
};
|
|
86
86
|
|
|
87
87
|
const styles = css({
|
|
88
|
-
|
|
88
|
+
color: colors.text,
|
|
89
89
|
});
|
|
90
90
|
```
|
|
91
91
|
|
|
@@ -97,11 +97,11 @@ Spread elements are not allowed.
|
|
|
97
97
|
import { css } from '@compiled/react';
|
|
98
98
|
|
|
99
99
|
const buttonStyles = {
|
|
100
|
-
|
|
100
|
+
color: 'blue',
|
|
101
101
|
};
|
|
102
102
|
|
|
103
103
|
const styles = css({
|
|
104
|
-
|
|
104
|
+
...buttonStyles,
|
|
105
105
|
});
|
|
106
106
|
```
|
|
107
107
|
|
|
@@ -113,7 +113,7 @@ Array values are not allowed. This syntax is not supported by most styling libra
|
|
|
113
113
|
import { css } from '@compiled/react';
|
|
114
114
|
|
|
115
115
|
const styles = css({
|
|
116
|
-
|
|
116
|
+
'::before': [{ fontWeight: 'bold' }, { color: 'red' }],
|
|
117
117
|
});
|
|
118
118
|
```
|
|
119
119
|
|
|
@@ -121,26 +121,26 @@ const styles = css({
|
|
|
121
121
|
|
|
122
122
|
Things to note about the following example:
|
|
123
123
|
|
|
124
|
-
-
|
|
125
|
-
-
|
|
126
|
-
-
|
|
127
|
-
|
|
124
|
+
- The `warningStyles` are conditionally applied using the `css` prop
|
|
125
|
+
- The dynamic `width` is applied using the `style` prop
|
|
126
|
+
- The `token()` calls are allowed because they are statically analyzable (and in the default
|
|
127
|
+
allow-list)
|
|
128
128
|
|
|
129
129
|
```tsx
|
|
130
130
|
import { css } from '@compiled/react';
|
|
131
131
|
import { token } from '@atlaskit/tokens';
|
|
132
132
|
|
|
133
133
|
const baseStyles = css({
|
|
134
|
-
|
|
134
|
+
height: 100,
|
|
135
135
|
});
|
|
136
136
|
|
|
137
137
|
const warningStyles = css({
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
color: token('color.text.warning'),
|
|
139
|
+
backgroundColor: token('color.background.warning'),
|
|
140
140
|
});
|
|
141
141
|
|
|
142
142
|
const Component = ({ isWarning, width }: { isWarning: boolean; width: number }) => {
|
|
143
|
-
|
|
143
|
+
return <div style={{ width }} css={[baseStyles, isWarning && warningStyles]} />;
|
|
144
144
|
};
|
|
145
145
|
```
|
|
146
146
|
|
|
@@ -204,13 +204,13 @@ Default imports are not currently supported.
|
|
|
204
204
|
|
|
205
205
|
By default, this rule will check `css` usages from:
|
|
206
206
|
|
|
207
|
-
-
|
|
208
|
-
-
|
|
209
|
-
-
|
|
210
|
-
-
|
|
211
|
-
-
|
|
212
|
-
-
|
|
213
|
-
-
|
|
207
|
+
- `@atlaskit/css`
|
|
208
|
+
- `@atlaskit/primitives`
|
|
209
|
+
- `@compiled/react`
|
|
210
|
+
- `@emotion/react`
|
|
211
|
+
- `@emotion/core`
|
|
212
|
+
- `@emotion/styled`
|
|
213
|
+
- `styled-components`
|
|
214
214
|
|
|
215
215
|
To change this list of libraries, you can define a custom set of `importSources`, which accepts an
|
|
216
216
|
array of package names (strings). This will override the built-in allow-list.
|
|
@@ -16,7 +16,7 @@ var _recommended = _interopRequireDefault(require("./presets/recommended.codegen
|
|
|
16
16
|
var _index = _interopRequireDefault(require("./rules/index.codegen"));
|
|
17
17
|
/**
|
|
18
18
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
19
|
-
* @codegen <<SignedSource::
|
|
19
|
+
* @codegen <<SignedSource::aff3fad2b8534fad07ba5f0f1b981a55>>
|
|
20
20
|
* @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen
|
|
21
21
|
*/
|
|
22
22
|
|