@atlaskit/eslint-plugin-ui-styling-standard 0.14.2 → 0.15.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 +188 -167
- package/README.md +1 -0
- package/afm-cc/tsconfig.json +10 -3
- package/afm-jira/tsconfig.json +28 -0
- 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 +99 -98
- 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 +244 -0
- package/constellation/no-unsafe-values/usage.mdx +33 -33
- package/dist/cjs/index.codegen.js +1 -1
- package/dist/cjs/presets/all.codegen.js +2 -1
- package/dist/cjs/presets/recommended.codegen.js +2 -1
- package/dist/cjs/rules/index.codegen.js +3 -1
- package/dist/cjs/rules/no-unsafe-selectors/constants.js +30 -0
- package/dist/cjs/rules/no-unsafe-selectors/index.js +188 -0
- package/dist/cjs/rules/no-unsafe-selectors/lint-selector.js +198 -0
- package/dist/cjs/rules/no-unsafe-selectors/source-position-utils.js +42 -0
- package/dist/cjs/rules/no-unsafe-selectors/walk-css-map.js +186 -0
- package/dist/es2019/index.codegen.js +1 -1
- package/dist/es2019/presets/all.codegen.js +2 -1
- package/dist/es2019/presets/recommended.codegen.js +2 -1
- package/dist/es2019/rules/index.codegen.js +3 -1
- package/dist/es2019/rules/no-unsafe-selectors/constants.js +22 -0
- package/dist/es2019/rules/no-unsafe-selectors/index.js +176 -0
- package/dist/es2019/rules/no-unsafe-selectors/lint-selector.js +161 -0
- package/dist/es2019/rules/no-unsafe-selectors/source-position-utils.js +31 -0
- package/dist/es2019/rules/no-unsafe-selectors/walk-css-map.js +180 -0
- package/dist/esm/index.codegen.js +1 -1
- package/dist/esm/presets/all.codegen.js +2 -1
- package/dist/esm/presets/recommended.codegen.js +2 -1
- package/dist/esm/rules/index.codegen.js +3 -1
- package/dist/esm/rules/no-unsafe-selectors/constants.js +24 -0
- package/dist/esm/rules/no-unsafe-selectors/index.js +181 -0
- package/dist/esm/rules/no-unsafe-selectors/lint-selector.js +191 -0
- package/dist/esm/rules/no-unsafe-selectors/source-position-utils.js +34 -0
- package/dist/esm/rules/no-unsafe-selectors/walk-css-map.js +179 -0
- package/dist/types/index.codegen.d.ts +2 -0
- package/dist/types/presets/all.codegen.d.ts +2 -1
- package/dist/types/presets/recommended.codegen.d.ts +2 -1
- package/dist/types/rules/index.codegen.d.ts +1 -0
- package/dist/types/rules/no-unsafe-selectors/constants.d.ts +23 -0
- package/dist/types/rules/no-unsafe-selectors/index.d.ts +3 -0
- package/dist/types/rules/no-unsafe-selectors/lint-selector.d.ts +14 -0
- package/dist/types/rules/no-unsafe-selectors/source-position-utils.d.ts +20 -0
- package/dist/types/rules/no-unsafe-selectors/walk-css-map.d.ts +23 -0
- package/dist/types-ts4.5/index.codegen.d.ts +2 -0
- package/dist/types-ts4.5/presets/all.codegen.d.ts +2 -1
- package/dist/types-ts4.5/presets/recommended.codegen.d.ts +2 -1
- package/dist/types-ts4.5/rules/index.codegen.d.ts +1 -0
- package/dist/types-ts4.5/rules/no-unsafe-selectors/constants.d.ts +84 -0
- package/dist/types-ts4.5/rules/no-unsafe-selectors/index.d.ts +3 -0
- package/dist/types-ts4.5/rules/no-unsafe-selectors/lint-selector.d.ts +14 -0
- package/dist/types-ts4.5/rules/no-unsafe-selectors/source-position-utils.d.ts +23 -0
- package/dist/types-ts4.5/rules/no-unsafe-selectors/walk-css-map.d.ts +23 -0
- package/package.json +7 -8
- package/scripts/codegen.tsx +3 -4
- package/src/index.codegen.tsx +3 -3
- package/src/presets/all.codegen.tsx +70 -72
- package/src/presets/recommended.codegen.tsx +70 -72
- package/src/rules/index.codegen.tsx +19 -17
- package/src/rules/no-classname-prop/index.tsx +1 -1
- package/src/rules/no-nested-selectors/index.tsx +1 -1
- package/src/rules/no-unsafe-selectors/README.md +232 -0
- package/src/rules/no-unsafe-selectors/__tests__/no-ambiguous-pseudos.test.tsx +368 -0
- package/src/rules/no-unsafe-selectors/__tests__/no-grouped-at-rules.test.tsx +60 -0
- package/src/rules/no-unsafe-selectors/__tests__/no-increased-specificity.test.tsx +73 -0
- package/src/rules/no-unsafe-selectors/__tests__/no-keyframes-at-rules.test.tsx +40 -0
- package/src/rules/no-unsafe-selectors/__tests__/no-legacy-pseudo-element-syntax.test.tsx +101 -0
- package/src/rules/no-unsafe-selectors/__tests__/no-restricted-at-rules.test.tsx +131 -0
- package/src/rules/no-unsafe-selectors/__tests__/no-restricted-pseudos.test.tsx +132 -0
- package/src/rules/no-unsafe-selectors/__tests__/no-selectors-object.test.tsx +25 -0
- package/src/rules/no-unsafe-selectors/__tests__/no-unparsable-selectors.test.tsx +35 -0
- package/src/rules/no-unsafe-selectors/__tests__/rule.test.tsx +238 -0
- package/src/rules/no-unsafe-selectors/constants.tsx +99 -0
- package/src/rules/no-unsafe-selectors/index.tsx +198 -0
- package/src/rules/no-unsafe-selectors/lint-selector.tsx +155 -0
- package/src/rules/no-unsafe-selectors/source-position-utils.tsx +55 -0
- package/src/rules/no-unsafe-selectors/walk-css-map.tsx +232 -0
- package/tsconfig.app.json +45 -45
- package/tsconfig.dev.json +43 -43
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../../tsconfig.products.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"target": "es5",
|
|
5
|
+
"lib": [
|
|
6
|
+
"ES2021.String"
|
|
7
|
+
],
|
|
8
|
+
"outDir": "../../../../../tsDist/@atlaskit__eslint-plugin-ui-styling-standard/app",
|
|
9
|
+
"composite": true,
|
|
10
|
+
"rootDir": "../",
|
|
11
|
+
"baseUrl": "../"
|
|
12
|
+
},
|
|
13
|
+
"include": [
|
|
14
|
+
"../src/**/*.ts",
|
|
15
|
+
"../src/**/*.tsx"
|
|
16
|
+
],
|
|
17
|
+
"exclude": [
|
|
18
|
+
"../src/**/__tests__/*",
|
|
19
|
+
"../__tests__/*",
|
|
20
|
+
"../src/**/*.test.*",
|
|
21
|
+
"../src/**/test.*"
|
|
22
|
+
],
|
|
23
|
+
"references": [
|
|
24
|
+
{
|
|
25
|
+
"path": "../../eslint-utils/afm-jira/tsconfig.json"
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
@@ -16,7 +16,7 @@ import { styled } from '@compiled/react';
|
|
|
16
16
|
import { typography } from '@atlaskit/theme';
|
|
17
17
|
|
|
18
18
|
export const HeadingComponent = styled.h2`
|
|
19
|
-
|
|
19
|
+
${typography.h200()};
|
|
20
20
|
`;
|
|
21
21
|
```
|
|
22
22
|
|
|
@@ -33,7 +33,7 @@ export const HeadingComponent = styled.h2(typography.h200());
|
|
|
33
33
|
import { styled } from '@compiled/react';
|
|
34
34
|
|
|
35
35
|
const HeadingComponent = styled.h2({
|
|
36
|
-
|
|
36
|
+
fontSize: '20px',
|
|
37
37
|
});
|
|
38
38
|
```
|
|
39
39
|
|
|
@@ -43,13 +43,13 @@ import { token } from '@atlaskit/tokens';
|
|
|
43
43
|
import { styled } from '@compiled/react';
|
|
44
44
|
|
|
45
45
|
const TitleComponent = styled.span({
|
|
46
|
-
|
|
46
|
+
marginTop: token('space.150', '12px'),
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
export const Title = (props) => (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
<Heading level="h200" as="h3">
|
|
51
|
+
<TitleComponent {...props} />
|
|
52
|
+
</Heading>
|
|
53
53
|
);
|
|
54
54
|
```
|
|
55
55
|
|
|
@@ -64,7 +64,7 @@ import { styled } from '@compiled/react';
|
|
|
64
64
|
import { elevation } from '@atlaskit/theme';
|
|
65
65
|
|
|
66
66
|
export const ElevationComponent = styled.div`
|
|
67
|
-
|
|
67
|
+
${elevation.e100()};
|
|
68
68
|
`;
|
|
69
69
|
```
|
|
70
70
|
|
|
@@ -75,10 +75,10 @@ import { styled } from '@compiled/react';
|
|
|
75
75
|
import { token } from '@atlaskit/tokens';
|
|
76
76
|
|
|
77
77
|
export const TestComponent = styled.div({
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
boxShadow: token(
|
|
79
|
+
'elevation.shadow.raised',
|
|
80
|
+
'0 1px 1px rgba(9,30,66,0.25),0 0 1px 1px rgba(9,30,66,0.13)',
|
|
81
|
+
),
|
|
82
82
|
});
|
|
83
83
|
```
|
|
84
84
|
|
|
@@ -96,7 +96,7 @@ import { styled } from '@compiled/react';
|
|
|
96
96
|
import { skeletonShimmer } from '@atlaskit/theme/constants';
|
|
97
97
|
|
|
98
98
|
export const SkeletonShimmerComponent = styled.div`
|
|
99
|
-
|
|
99
|
+
${skeletonShimmer};
|
|
100
100
|
`;
|
|
101
101
|
```
|
|
102
102
|
|
|
@@ -104,10 +104,10 @@ export const SkeletonShimmerComponent = styled.div`
|
|
|
104
104
|
|
|
105
105
|
```tsx
|
|
106
106
|
export const SkeletonShimmerComponent = () => {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
return (
|
|
108
|
+
<Wrapper>
|
|
109
|
+
<object data="./skeleton.svg" type="image/svg+xml"></object>
|
|
110
|
+
</Wrapper>
|
|
111
|
+
);
|
|
112
112
|
};
|
|
113
113
|
```
|
|
@@ -9,8 +9,8 @@ These libraries do not support having an arrow function inside a CSS value:
|
|
|
9
9
|
|
|
10
10
|
```js
|
|
11
11
|
styled.div({
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
color: ({ myColor }) => myColor,
|
|
13
|
+
backgroundColor: (props) => props.someColor,
|
|
14
14
|
});
|
|
15
15
|
```
|
|
16
16
|
|
|
@@ -19,8 +19,8 @@ issue:
|
|
|
19
19
|
|
|
20
20
|
```js
|
|
21
21
|
styled.div((props) => ({
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
color: props.myColor,
|
|
23
|
+
backgroundColor: props.someColor,
|
|
24
24
|
}));
|
|
25
25
|
```
|
|
26
26
|
|
|
@@ -73,8 +73,8 @@ remediated manually. For example:
|
|
|
73
73
|
|
|
74
74
|
```js
|
|
75
75
|
styled.div({
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
color: ({ myColor = '#fff' }) => myColor,
|
|
77
|
+
backgroundColor: ({ myColor = '#aaa' }) => myColor,
|
|
78
78
|
});
|
|
79
79
|
```
|
|
80
80
|
|
|
@@ -82,8 +82,8 @@ could potentially be remediated with
|
|
|
82
82
|
|
|
83
83
|
```js
|
|
84
84
|
styled.div((props) => ({
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
color: myColor ?? '#fff',
|
|
86
|
+
backgroundColor: myColor ?? '#aaa',
|
|
87
87
|
}));
|
|
88
88
|
```
|
|
89
89
|
|
|
@@ -95,12 +95,12 @@ styled.div((props) => ({
|
|
|
95
95
|
import styled from 'styled-components';
|
|
96
96
|
|
|
97
97
|
styled.div({
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
color: ({ myColor }) => myColor,
|
|
99
|
+
backgroundColor: (props) => props.someColor,
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
styled.div({
|
|
103
|
-
|
|
103
|
+
color: `url(/tmp/${({ coolProp }) => coolProp}.png)`,
|
|
104
104
|
});
|
|
105
105
|
```
|
|
106
106
|
|
|
@@ -110,12 +110,12 @@ styled.div({
|
|
|
110
110
|
import styled from '@emotion/styled';
|
|
111
111
|
|
|
112
112
|
styled.div((props) => ({
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
color: props.myColor,
|
|
114
|
+
backgroundColor: props.someColor,
|
|
115
115
|
}));
|
|
116
116
|
|
|
117
117
|
styled.div((props) => ({
|
|
118
|
-
|
|
118
|
+
color: url(`/tmp/${coolProp}.png`),
|
|
119
119
|
}));
|
|
120
120
|
```
|
|
121
121
|
|
|
@@ -13,14 +13,14 @@ values should be passed into the `css` prop in JSX components.
|
|
|
13
13
|
|
|
14
14
|
```tsx
|
|
15
15
|
function Component() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
return (
|
|
17
|
+
<div
|
|
18
|
+
style={{
|
|
19
|
+
margin: 0,
|
|
20
|
+
color: 'red',
|
|
21
|
+
}}
|
|
22
|
+
/>
|
|
23
|
+
);
|
|
24
24
|
}
|
|
25
25
|
```
|
|
26
26
|
|
|
@@ -28,14 +28,14 @@ function Component() {
|
|
|
28
28
|
|
|
29
29
|
```tsx
|
|
30
30
|
function Component(props) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
31
|
+
return (
|
|
32
|
+
<div
|
|
33
|
+
style={{
|
|
34
|
+
width: props.width,
|
|
35
|
+
'--my-nested-width': props.width,
|
|
36
|
+
}}
|
|
37
|
+
css={css({ margin: 0, color: 'red' })}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
40
|
}
|
|
41
41
|
```
|
|
@@ -9,34 +9,35 @@ but more are planned to support the standard over time.
|
|
|
9
9
|
<!-- START_RULE_TABLE_CODEGEN -->
|
|
10
10
|
<!-- @codegenCommand yarn workspace @atlaskit/eslint-plugin-ui-styling-standard codegen -->
|
|
11
11
|
|
|
12
|
-
| Rule
|
|
13
|
-
|
|
|
14
|
-
| <a href="atlaskit-theme/usage">atlaskit-theme</a> | Ban certain usages of `@atlaskit/theme` that `@compiled/react` does not understand | Yes | | |
|
|
15
|
-
| <a href="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 | |
|
|
16
|
-
| <a href="enforce-style-prop/usage">enforce-style-prop</a> | Disallows usage of static styles in the `style` attribute in components | Yes | | |
|
|
17
|
-
| <a href="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 | | |
|
|
18
|
-
| <a href="no-array-arguments/usage">no-array-arguments</a> | Prevents usage of array arguments to style declaration functions | Yes | Yes | |
|
|
19
|
-
| <a href="no-classname-prop/usage">no-classname-prop</a> | Disallows usage of the `className` prop in JSX | Yes | | |
|
|
20
|
-
| <a href="no-container-queries/usage">no-container-queries</a> | Prevents usage of @container query within css styling | Yes | | |
|
|
21
|
-
| <a href="no-dynamic-styles/usage">no-dynamic-styles</a> | Disallows use of dynamic styles in CSS-in-JS calls | Yes | | |
|
|
22
|
-
| <a href="no-exported-styles/usage">no-exported-styles</a> | Disallows exports of css, keyframes, styled and xcss | Yes | | |
|
|
23
|
-
| <a href="no-global-styles/usage">no-global-styles</a> | Prevents global styles through CSS-in-JS or CSS module imports | Yes | | |
|
|
24
|
-
| <a href="no-important-styles/usage">no-important-styles</a> | Disallows important style declarations | Yes | | |
|
|
25
|
-
| <a href="no-imported-style-values/usage">no-imported-style-values</a> | Disallows imports of style values | Yes | | |
|
|
26
|
-
| <a href="no-nested-selectors/usage">no-nested-selectors</a> | Prevents usage of nested selectors within css styling | Yes | | |
|
|
27
|
-
| <a href="no-styled/usage">no-styled</a> | Disallows usage of the `styled` imports | Yes | | |
|
|
28
|
-
| <a href="no-unsafe-
|
|
29
|
-
| <a href="
|
|
30
|
-
| <a href="
|
|
31
|
-
| <a href="
|
|
32
|
-
| <a href="no-
|
|
33
|
-
| <a href="no-
|
|
34
|
-
| <a href="no-
|
|
35
|
-
| <a href="no-
|
|
36
|
-
| <a href="
|
|
37
|
-
| <a href="no-
|
|
38
|
-
| <a href="no-exported-
|
|
39
|
-
| <a href="
|
|
12
|
+
| Rule | Description | Recommended | Fixable | Suggestions |
|
|
13
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------- | ------- | ----------- |
|
|
14
|
+
| <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 | | |
|
|
15
|
+
| <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 | |
|
|
16
|
+
| <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 | | |
|
|
17
|
+
| <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 | | |
|
|
18
|
+
| <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 | |
|
|
19
|
+
| <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 | | |
|
|
20
|
+
| <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 | | |
|
|
21
|
+
| <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 | | |
|
|
22
|
+
| <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 | | |
|
|
23
|
+
| <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 | | |
|
|
24
|
+
| <a href="/components/eslint-plugin-ui-styling-standard/no-important-styles/usage">no-important-styles</a> | Disallows important style declarations | Yes | | |
|
|
25
|
+
| <a href="/components/eslint-plugin-ui-styling-standard/no-imported-style-values/usage">no-imported-style-values</a> | Disallows imports of style values | Yes | | |
|
|
26
|
+
| <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 | | |
|
|
27
|
+
| <a href="/components/eslint-plugin-ui-styling-standard/no-styled/usage">no-styled</a> | Disallows usage of the `styled` imports | Yes | | |
|
|
28
|
+
| <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 |
|
|
29
|
+
| <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 | | |
|
|
30
|
+
| <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 | |
|
|
31
|
+
| <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 | |
|
|
32
|
+
| <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 | |
|
|
33
|
+
| <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 | |
|
|
34
|
+
| <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 | |
|
|
35
|
+
| <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 | | |
|
|
36
|
+
| <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 | | |
|
|
37
|
+
| <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 | | |
|
|
38
|
+
| <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 | | |
|
|
39
|
+
| <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 | | |
|
|
40
|
+
| <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 | | |
|
|
40
41
|
|
|
41
42
|
<!-- END_RULE_TABLE_CODEGEN -->
|
|
42
43
|
|
|
@@ -53,17 +54,17 @@ future advancements like generative AI.
|
|
|
53
54
|
|
|
54
55
|
### Desired outcomes:
|
|
55
56
|
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
|
|
59
|
-
-
|
|
60
|
-
|
|
61
|
-
-
|
|
62
|
-
|
|
63
|
-
-
|
|
64
|
-
|
|
65
|
-
-
|
|
66
|
-
|
|
57
|
+
- We can make large visual changes and migrations safely and in a fraction of the time.
|
|
58
|
+
- To have the vast majority of styling code be deterministic, immutable, and bound to its scope,
|
|
59
|
+
reducing unknown visual and UX regressions.
|
|
60
|
+
- To enable teams to write tooling quicker that's better and more performant to lint, test, and
|
|
61
|
+
migrate UI code to improve current and future developer productivity and satisfaction.
|
|
62
|
+
- To enable large performance improvements for customers and developers with a zero-runtime styling
|
|
63
|
+
solution.
|
|
64
|
+
- To reduce the amount of overall custom styling code written while supporting customization without
|
|
65
|
+
without the need for hacks and technical debt.
|
|
66
|
+
- We aim to see a reduction of the “average styles per component”, reducing the effort to build and
|
|
67
|
+
maintain UIs.
|
|
67
68
|
|
|
68
69
|
## Basic principles
|
|
69
70
|
|
|
@@ -73,12 +74,12 @@ Java, Go, etc.
|
|
|
73
74
|
|
|
74
75
|
### Like other languages, styling code must be:
|
|
75
76
|
|
|
76
|
-
-
|
|
77
|
-
-
|
|
78
|
-
-
|
|
79
|
-
-
|
|
80
|
-
-
|
|
81
|
-
-
|
|
77
|
+
- type-safe
|
|
78
|
+
- static and locally analyzable
|
|
79
|
+
- reusable and composable
|
|
80
|
+
- restricted to an encapsulated scope
|
|
81
|
+
- deterministic—with styling known in isolation
|
|
82
|
+
- discoverable and readable without deep knowledge of the CSS spec
|
|
82
83
|
|
|
83
84
|
As the W3C CSS spec and wider industry grows, having our styling code meet these principles will
|
|
84
85
|
mean we can programatically evolve that a better future state.
|
|
@@ -158,20 +159,20 @@ context so both humans and tooling can read this component in a performant and d
|
|
|
158
159
|
|
|
159
160
|
1. Use `@compiled/react` or [Primitives](/components/primitives/overview) wherever possible!
|
|
160
161
|
2. Instead of dynamic styles:
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
1. Use static `css()` calls everywhere.
|
|
163
|
+
2. Compose styles together, turning styles on or off.
|
|
164
|
+
3. When absoluteuly necessary, use `props.style` for dynamic styles.
|
|
164
165
|
3. Instead of nested selectors or global styles:
|
|
165
|
-
|
|
166
|
-
|
|
166
|
+
1. Style components directly.
|
|
167
|
+
2. Treat everything as local scope, parents shouldn't interact with children wherever feasible.
|
|
167
168
|
4. Instead of passing raw styles around:
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
169
|
+
1. Write composable and reusable components which distribute styles with clear context.
|
|
170
|
+
2. Co-locate styles in the same file for human readability and far better tooling feasibility and
|
|
171
|
+
performance.
|
|
171
172
|
5. Instead of `styled.…`, use `const styles = css({ … });` (hoisted and static) and
|
|
172
173
|
`<div css={styles} />`.
|
|
173
|
-
|
|
174
|
-
|
|
174
|
+
1. There will be a safe way to make bounded customizations on components through the use of
|
|
175
|
+
`<Component xcss={css({ … })}>` in the future.
|
|
175
176
|
6. Instead of `...props`, be explicit with the `aria-` or `data-` props you support, or have more
|
|
176
177
|
complex spread handling. This is because `className`, `style`, and other things can be applied
|
|
177
178
|
without any knowledge, resulting in regressions in the future.
|
|
@@ -183,63 +184,63 @@ import { css } from '@compiled/react';
|
|
|
183
184
|
import { token } from '@atlaskit/tokens';
|
|
184
185
|
|
|
185
186
|
const wrapperStyles = css({
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
187
|
+
padding: token('space.200'), // eg. from mixin
|
|
188
|
+
font: token('font.body'), // eg. from mixin
|
|
189
|
+
color: token('color.text'),
|
|
189
190
|
});
|
|
190
191
|
const disabledWrapperStyles = css({
|
|
191
|
-
|
|
192
|
+
color: token('color.text.disabled'),
|
|
192
193
|
});
|
|
193
194
|
const innerWrapperStyles = css({
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
195
|
+
// eg. colocated `innerWrapperStyles` (alternatively could create a reusable `<InnerWrapper>`)
|
|
196
|
+
display: 'flex',
|
|
197
|
+
gap: token('space.100'),
|
|
198
|
+
flexDirection: 'column',
|
|
198
199
|
});
|
|
199
200
|
const buttonStyles = css({
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
201
|
+
appearance: 'none', // eg. from global styles
|
|
202
|
+
padding: `${token('space.100')} ${token('space.200')}`, // eg. from global styles
|
|
203
|
+
color: token('color.link'),
|
|
203
204
|
});
|
|
204
205
|
const disabledButtonStyles = css({
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
206
|
+
cursor: 'not-allowed', // eg. from disabledStyles
|
|
207
|
+
color: token('color.text.disabled'),
|
|
208
|
+
opacity: '70%',
|
|
208
209
|
});
|
|
209
210
|
const buttonAppearanceStyles = cssMap({
|
|
210
|
-
|
|
211
|
-
|
|
211
|
+
primary: { background: token('color.background.brand.subtlest') },
|
|
212
|
+
secondary: { background: token('color.background.success') },
|
|
212
213
|
});
|
|
213
214
|
|
|
214
215
|
export const Component = ({
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
216
|
+
disabled = false,
|
|
217
|
+
width = 100,
|
|
218
|
+
appearance = 'primary',
|
|
219
|
+
'aria-label': ariaLabel,
|
|
219
220
|
}: {
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
221
|
+
disabled?: boolean;
|
|
222
|
+
width?: number;
|
|
223
|
+
appearance?: 'primary' | 'secondary';
|
|
224
|
+
'aria-label'?: string;
|
|
224
225
|
}) => (
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
226
|
+
<div
|
|
227
|
+
css={[wrapperStyles, props.disabled && disabledWrapperStyles]}
|
|
228
|
+
style={{ width: `${props.width}px` }}
|
|
229
|
+
aria-label={ariaLabel}
|
|
230
|
+
>
|
|
231
|
+
<div css={innerWrapperStyles}>
|
|
232
|
+
{/* Typically, this `<button>` should be an Atlassian Design System `<Button>` */}
|
|
233
|
+
<button
|
|
234
|
+
disabled={props.disabled}
|
|
235
|
+
css={[
|
|
236
|
+
buttonStyles,
|
|
237
|
+
buttonAppearances[props.appearance],
|
|
238
|
+
props.disabled && disabledButtonStyles,
|
|
239
|
+
]}
|
|
240
|
+
>
|
|
241
|
+
Click me
|
|
242
|
+
</button>
|
|
243
|
+
</div>
|
|
244
|
+
</div>
|
|
244
245
|
);
|
|
245
246
|
```
|
|
@@ -18,8 +18,8 @@ robust enough type checking.
|
|
|
18
18
|
import { cx, cssMap } from '@compiled/react';
|
|
19
19
|
|
|
20
20
|
const styles = cssMap({
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
text: { color: 'red' },
|
|
22
|
+
bg: { background: 'blue' },
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
const joinedStyles = cx(styles.text, styles.bg);
|
|
@@ -33,8 +33,8 @@ const joinedStyles = cx(styles.text, styles.bg);
|
|
|
33
33
|
import { cx, cssMap } from '@compiled/react';
|
|
34
34
|
|
|
35
35
|
const styles = cssMap({
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
text: { color: 'red' },
|
|
37
|
+
bg: { background: 'blue' },
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
<Button xcss={cx(styles.text, styles.bg)} />;
|
|
@@ -34,13 +34,13 @@ const styles = css({ width: 100 }, ...items);
|
|
|
34
34
|
|
|
35
35
|
By default, this rule will check `css` usages from:
|
|
36
36
|
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
37
|
+
- `@atlaskit/css`
|
|
38
|
+
- `@atlaskit/primitives`
|
|
39
|
+
- `@compiled/react`
|
|
40
|
+
- `@emotion/react`
|
|
41
|
+
- `@emotion/core`
|
|
42
|
+
- `@emotion/styled`
|
|
43
|
+
- `styled-components`
|
|
44
44
|
|
|
45
45
|
To change this list of libraries, you can define a custom set of `importSources`, which accepts an
|
|
46
46
|
array of package names (strings).
|
|
@@ -15,11 +15,11 @@ We suggest you explore the use alternatives such as client JavaScript-based APIs
|
|
|
15
15
|
import { css } from '@compiled/react';
|
|
16
16
|
|
|
17
17
|
const styles = css({
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
'@container (width > 400px)': {
|
|
19
|
+
h2: {
|
|
20
|
+
fontSize: '1.5rem',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
23
|
});
|
|
24
24
|
```
|
|
25
25
|
|
|
@@ -29,8 +29,8 @@ const styles = css({
|
|
|
29
29
|
import { css } from '@compiled/react';
|
|
30
30
|
|
|
31
31
|
const containerStyles = css({
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
display: 'flex',
|
|
33
|
+
flexDirection: 'column',
|
|
34
34
|
});
|
|
35
35
|
```
|
|
36
36
|
|
|
@@ -40,13 +40,13 @@ const containerStyles = css({
|
|
|
40
40
|
|
|
41
41
|
By default, this rule will check `css` usages from:
|
|
42
42
|
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
43
|
+
- `@atlaskit/css`
|
|
44
|
+
- `@atlaskit/primitives`
|
|
45
|
+
- `@compiled/react`
|
|
46
|
+
- `@emotion/react`
|
|
47
|
+
- `@emotion/core`
|
|
48
|
+
- `@emotion/styled`
|
|
49
|
+
- `styled-components`
|
|
50
50
|
|
|
51
51
|
To change this list of libraries, you can define a custom set of `importSources`, which accepts an
|
|
52
52
|
array of package names (strings).
|