@atlaskit/eslint-plugin-design-system 10.4.2 → 10.4.4
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 +1024 -1021
- package/README.md +1 -1
- package/constellation/consistent-css-prop-usage/usage.mdx +18 -18
- package/constellation/index/usage.mdx +1 -1
- package/constellation/no-css-tagged-template-expression/usage.mdx +13 -13
- package/constellation/no-deprecated-apis/usage.mdx +26 -26
- package/constellation/no-deprecated-imports/usage.mdx +27 -27
- package/constellation/no-direct-use-of-web-platform-drag-and-drop/usage.mdx +5 -5
- package/constellation/no-empty-styled-expression/usage.mdx +11 -11
- package/constellation/no-exported-css/usage.mdx +7 -7
- package/constellation/no-exported-keyframes/usage.mdx +7 -7
- package/constellation/no-invalid-css-map/usage.mdx +52 -52
- package/constellation/no-keyframes-tagged-template-expression/usage.mdx +14 -14
- package/constellation/no-nested-styles/usage.mdx +13 -13
- package/constellation/no-physical-properties/usage.mdx +9 -9
- package/constellation/no-styled-tagged-template-expression/usage.mdx +30 -30
- package/constellation/no-unsafe-design-token-usage/usage.mdx +4 -4
- package/constellation/no-unsafe-style-overrides/usage.mdx +5 -5
- package/constellation/prefer-primitives/usage.mdx +1 -1
- package/constellation/use-heading/usage.mdx +2 -2
- package/constellation/use-heading-level-in-spotlight-card/usage.mdx +1 -1
- package/constellation/use-latest-xcss-syntax/usage.mdx +2 -2
- package/constellation/use-primitives/usage.mdx +38 -38
- package/constellation/use-tokens-space/usage.mdx +2 -2
- package/dist/cjs/index.codegen.js +1 -1
- package/dist/cjs/presets/all.codegen.js +2 -2
- package/dist/cjs/presets/recommended.codegen.js +3 -2
- package/dist/cjs/rules/index.codegen.js +1 -1
- package/dist/cjs/rules/no-html-button/index.js +1 -1
- package/dist/cjs/rules/use-latest-xcss-syntax/index.js +1 -1
- package/dist/cjs/rules/use-latest-xcss-syntax/transformers/style-property/supported.js +1 -1
- package/dist/es2019/index.codegen.js +1 -1
- package/dist/es2019/presets/all.codegen.js +2 -2
- package/dist/es2019/presets/recommended.codegen.js +3 -2
- package/dist/es2019/rules/index.codegen.js +1 -1
- package/dist/es2019/rules/no-html-button/index.js +1 -1
- package/dist/es2019/rules/use-latest-xcss-syntax/index.js +1 -1
- package/dist/es2019/rules/use-latest-xcss-syntax/transformers/style-property/supported.js +1 -1
- package/dist/esm/index.codegen.js +1 -1
- package/dist/esm/presets/all.codegen.js +2 -2
- package/dist/esm/presets/recommended.codegen.js +3 -2
- package/dist/esm/rules/index.codegen.js +1 -1
- package/dist/esm/rules/no-html-button/index.js +1 -1
- package/dist/esm/rules/use-latest-xcss-syntax/index.js +1 -1
- package/dist/esm/rules/use-latest-xcss-syntax/transformers/style-property/supported.js +1 -1
- package/dist/types/index.codegen.d.ts +1 -0
- package/dist/types/presets/all.codegen.d.ts +1 -1
- package/dist/types/presets/recommended.codegen.d.ts +2 -1
- package/dist/types-ts4.5/index.codegen.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 +2 -1
- package/package.json +4 -6
package/README.md
CHANGED
|
@@ -63,7 +63,7 @@ module.exports = {
|
|
|
63
63
|
| <a href="./src/rules/no-exported-css/README.md">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 | | |
|
|
64
64
|
| <a href="./src/rules/no-exported-keyframes/README.md">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 | | |
|
|
65
65
|
| <a href="./src/rules/no-html-anchor/README.md">no-html-anchor</a> | Discourage direct usage of HTML anchor elements in favor of Atlassian Design System link components. | | | |
|
|
66
|
-
| <a href="./src/rules/no-html-button/README.md">no-html-button</a> | Discourage direct usage of HTML button elements in favor of Atlassian Design System button components. |
|
|
66
|
+
| <a href="./src/rules/no-html-button/README.md">no-html-button</a> | Discourage direct usage of HTML button elements in favor of Atlassian Design System button components. | Yes | | |
|
|
67
67
|
| <a href="./src/rules/no-invalid-css-map/README.md">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 | | |
|
|
68
68
|
| <a href="./src/rules/no-keyframes-tagged-template-expression/README.md">no-keyframes-tagged-template-expression</a> | Disallows any `keyframe` tagged template expressions that originate from Emotion, Styled Components or Compiled | | Yes | |
|
|
69
69
|
| <a href="./src/rules/no-margin/README.md">no-margin</a> | Disallow using the margin CSS property. | | | |
|
|
@@ -11,13 +11,13 @@ linting rules, which we can then all evolve and scale together.
|
|
|
11
11
|
|
|
12
12
|
This rule checks for the following cases:
|
|
13
13
|
|
|
14
|
-
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
14
|
+
- Styles should not be defined inline; it should instead be in a standalone variable.
|
|
15
|
+
- The exception for this is style composition (e.g. `<div css={[baseStyles, moreStyles]} />`),
|
|
16
|
+
which is a way to combine styles from two variables.
|
|
17
|
+
- Styles must be wrapped in a `css` function call.
|
|
18
|
+
- Styles must be defined in the same file as their usage, and not be imported.
|
|
19
|
+
- Styles should not contain spread operators (e.g. `css({ ...spreadStyles })`).
|
|
20
|
+
- Styles must all be defined at the top of the file, or at the bottom of the file.
|
|
21
21
|
|
|
22
22
|
This rule also has an autofixer that enforces and fixes the code (where practical) to meet the above
|
|
23
23
|
requirements.
|
|
@@ -89,16 +89,16 @@ JSX attribute.**
|
|
|
89
89
|
|
|
90
90
|
With the following options turned on:
|
|
91
91
|
|
|
92
|
-
-
|
|
93
|
-
-
|
|
92
|
+
- cssFunctions = ['css']
|
|
93
|
+
- stylesPlacement = 'top'
|
|
94
94
|
|
|
95
95
|
```js
|
|
96
96
|
const containerStyles = css({
|
|
97
|
-
|
|
97
|
+
zIndex: 1,
|
|
98
98
|
});
|
|
99
99
|
|
|
100
100
|
function Button({ children }) {
|
|
101
|
-
|
|
101
|
+
return <button css={containerStyles}>{children}</button>;
|
|
102
102
|
}
|
|
103
103
|
```
|
|
104
104
|
|
|
@@ -106,8 +106,8 @@ function Button({ children }) {
|
|
|
106
106
|
|
|
107
107
|
With the following options turned on:
|
|
108
108
|
|
|
109
|
-
-
|
|
110
|
-
-
|
|
109
|
+
- cssFunctions = ['css']
|
|
110
|
+
- stylesPlacement = 'top'
|
|
111
111
|
|
|
112
112
|
```js
|
|
113
113
|
const borderStyles = cssMap({
|
|
@@ -124,20 +124,20 @@ function Button({ children }) {
|
|
|
124
124
|
|
|
125
125
|
With the following options turned on:
|
|
126
126
|
|
|
127
|
-
-
|
|
128
|
-
-
|
|
127
|
+
- cssFunctions = ['css']
|
|
128
|
+
- stylesPlacement = 'bottom'
|
|
129
129
|
|
|
130
130
|
```js
|
|
131
131
|
function Button({ children }) {
|
|
132
|
-
|
|
132
|
+
return <button css={[baseContainerStyles, containerStyles]}>{children}</button>;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
const baseContainerStyles = css({
|
|
136
|
-
|
|
136
|
+
zIndex: 5,
|
|
137
137
|
});
|
|
138
138
|
|
|
139
139
|
const containerStyles = css({
|
|
140
|
-
|
|
140
|
+
zIndex: 7,
|
|
141
141
|
});
|
|
142
142
|
```
|
|
143
143
|
|
|
@@ -26,7 +26,7 @@ This plugin contains rules that should be used when working with the
|
|
|
26
26
|
| <a href="/components/eslint-plugin-design-system/no-exported-css/usage">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 | | |
|
|
27
27
|
| <a href="/components/eslint-plugin-design-system/no-exported-keyframes/usage">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 | | |
|
|
28
28
|
| <a href="/components/eslint-plugin-design-system/no-html-anchor/usage">no-html-anchor</a> | Discourage direct usage of HTML anchor elements in favor of Atlassian Design System link components. | | | |
|
|
29
|
-
| <a href="/components/eslint-plugin-design-system/no-html-button/usage">no-html-button</a> | Discourage direct usage of HTML button elements in favor of Atlassian Design System button components. |
|
|
29
|
+
| <a href="/components/eslint-plugin-design-system/no-html-button/usage">no-html-button</a> | Discourage direct usage of HTML button elements in favor of Atlassian Design System button components. | Yes | | |
|
|
30
30
|
| <a href="/components/eslint-plugin-design-system/no-invalid-css-map/usage">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 | | |
|
|
31
31
|
| <a href="/components/eslint-plugin-design-system/no-keyframes-tagged-template-expression/usage">no-keyframes-tagged-template-expression</a> | Disallows any `keyframe` tagged template expressions that originate from Emotion, Styled Components or Compiled | | Yes | |
|
|
32
32
|
| <a href="/components/eslint-plugin-design-system/no-margin/usage">no-margin</a> | Disallow using the margin CSS property. | | | |
|
|
@@ -18,12 +18,12 @@ from which this was ported.
|
|
|
18
18
|
import { css } from '@emotion/react';
|
|
19
19
|
|
|
20
20
|
css`
|
|
21
|
-
|
|
21
|
+
color: blue;
|
|
22
22
|
`;
|
|
23
23
|
|
|
24
24
|
const styles = css`
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
color: blue;
|
|
26
|
+
font-weight: 500;
|
|
27
27
|
`;
|
|
28
28
|
```
|
|
29
29
|
|
|
@@ -35,8 +35,8 @@ import { css } from '@emotion/react';
|
|
|
35
35
|
css({ color: 'blue' });
|
|
36
36
|
|
|
37
37
|
const styles = css({
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
color: 'blue',
|
|
39
|
+
fontWeight: 500,
|
|
40
40
|
});
|
|
41
41
|
```
|
|
42
42
|
|
|
@@ -46,13 +46,13 @@ const styles = css({
|
|
|
46
46
|
|
|
47
47
|
By default, this rule will check `css` usages from:
|
|
48
48
|
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
-
|
|
49
|
+
- `@atlaskit/css`
|
|
50
|
+
- `@atlaskit/primitives`
|
|
51
|
+
- `@compiled/react`
|
|
52
|
+
- `@emotion/react`
|
|
53
|
+
- `@emotion/core`
|
|
54
|
+
- `@emotion/styled`
|
|
55
|
+
- `styled-components`
|
|
56
56
|
|
|
57
57
|
To change this list of libraries, you can define a custom set of `importSources`, which accepts an
|
|
58
58
|
array of package names (strings).
|
|
@@ -68,4 +68,4 @@ export const styles = css``;
|
|
|
68
68
|
|
|
69
69
|
## Limitations
|
|
70
70
|
|
|
71
|
-
-
|
|
71
|
+
- Comments are not auto-fixable. You will need to manually convert usages containing functions.
|
|
@@ -27,21 +27,21 @@ config. If provided the rule will use the passed in config instead.
|
|
|
27
27
|
|
|
28
28
|
The following fields can be defined in the config:
|
|
29
29
|
|
|
30
|
-
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
30
|
+
- `deprecatedProp`, which is the deprecated props. Each prop has the following fields:
|
|
31
|
+
- `moduleSpecifier`, which is the module specifier of the package in which the prop was
|
|
32
|
+
deprecated. For example: `@atlaskit/button`.
|
|
33
|
+
- `namedSpecifier` **(optional)**, which is an array of named specifiers of the package in which
|
|
34
|
+
the prop was deprecated. For example: `Button`.
|
|
35
|
+
- `actionableVersion` **(optional)**, which is the version of the package in which the prop can be
|
|
36
|
+
actioned on. For example: `1.0.0`.
|
|
37
37
|
|
|
38
38
|
```json
|
|
39
39
|
{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
"cssFn": [
|
|
41
|
+
{
|
|
42
|
+
"moduleSpecifier": "@atlaskit/menu"
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
45
|
}
|
|
46
46
|
```
|
|
47
47
|
|
|
@@ -49,20 +49,20 @@ The following fields can be defined in the config:
|
|
|
49
49
|
import { configs } from '@atlaskit/eslint-plugin-design-system';
|
|
50
50
|
|
|
51
51
|
module.exports = {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
52
|
+
rules: {
|
|
53
|
+
'@atlaskit/design-system/no-deprecated-api': [
|
|
54
|
+
'error',
|
|
55
|
+
{
|
|
56
|
+
deprecatedConfig: {
|
|
57
|
+
cssFn: [
|
|
58
|
+
{
|
|
59
|
+
moduleSpecifier: '@atlaskit/menu',
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
66
|
};
|
|
67
67
|
```
|
|
68
68
|
|
|
@@ -25,23 +25,23 @@ config. If provided the rule will use the passed in config instead.
|
|
|
25
25
|
|
|
26
26
|
The following fields can be defined in the config:
|
|
27
27
|
|
|
28
|
-
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
- `packagePath`, which is the name of the package. For example: `@atlaskit/navigation-next` and
|
|
29
|
+
`@atlaskit/navigation`. With the package path as the key, you can either provide the values as:
|
|
30
|
+
- `message` **(optional)**, the message to display when the deprecated packages path is used. For
|
|
31
|
+
example: `multi-select is deprecated. Please use '@atlaskit/select' instead.` Or as:
|
|
32
|
+
- `imports`, which is an array of named imports to be deprecated. Each named import has the
|
|
33
|
+
following fields:
|
|
34
|
+
- `importName`, which is the name of the import to be deprecated. For example: `assistive` and
|
|
35
|
+
`visuallyHidden`.
|
|
36
|
+
- `message` **(optional)**, which is the message to display when the deprecated import is used.
|
|
37
|
+
For example:
|
|
38
|
+
`The assistive mixin is deprecated. Please use `@atlaskit/visually-hidden` instead.`.
|
|
39
39
|
|
|
40
40
|
```json
|
|
41
41
|
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
"@atlaskit/navigation-next": {
|
|
43
|
+
"message": "navigation-next is deprecated. Please use '@atlaskit/atlassian-navigation' instead."
|
|
44
|
+
}
|
|
45
45
|
}
|
|
46
46
|
```
|
|
47
47
|
|
|
@@ -49,18 +49,18 @@ The following fields can be defined in the config:
|
|
|
49
49
|
import packageJson from './package.json';
|
|
50
50
|
|
|
51
51
|
module.exports = {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
52
|
+
rules: {
|
|
53
|
+
'@atlaskit/design-system/no-deprecated-imports': [
|
|
54
|
+
'error',
|
|
55
|
+
{
|
|
56
|
+
deprecatedConfig: {
|
|
57
|
+
'@atlaskit/navigation-next': {
|
|
58
|
+
message:
|
|
59
|
+
"navigation-next is deprecated. Please use '@atlaskit/atlassian-navigation' instead.",
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
65
|
};
|
|
66
66
|
```
|
|
@@ -130,11 +130,11 @@ Leveraging Pragmatic drag and drop for web platform drag and drop.
|
|
|
130
130
|
import { monitor } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
131
131
|
|
|
132
132
|
monitor({
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
133
|
+
onGenerateDragPreview: fn,
|
|
134
|
+
onDragStart: fn,
|
|
135
|
+
onDropTargetChange: fn,
|
|
136
|
+
onDrag: fn,
|
|
137
|
+
onDrop: fn,
|
|
138
138
|
});
|
|
139
139
|
```
|
|
140
140
|
|
|
@@ -24,10 +24,10 @@ const EmptyStyledExpressionArgument = styled.div([]);
|
|
|
24
24
|
|
|
25
25
|
```tsx
|
|
26
26
|
const Wrapper = styled.div({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
backgroundColor: 'red',
|
|
28
|
+
MyComponent: {
|
|
29
|
+
backgroundColor: 'green',
|
|
30
|
+
},
|
|
31
31
|
});
|
|
32
32
|
```
|
|
33
33
|
|
|
@@ -61,13 +61,13 @@ const Wrapper = styled.div({
|
|
|
61
61
|
|
|
62
62
|
By default, this rule will check `styled` usages from:
|
|
63
63
|
|
|
64
|
-
-
|
|
65
|
-
-
|
|
66
|
-
-
|
|
67
|
-
-
|
|
68
|
-
-
|
|
69
|
-
-
|
|
70
|
-
-
|
|
64
|
+
- `@atlaskit/css`
|
|
65
|
+
- `@atlaskit/primitives`
|
|
66
|
+
- `@compiled/react`
|
|
67
|
+
- `@emotion/react`
|
|
68
|
+
- `@emotion/core`
|
|
69
|
+
- `@emotion/styled`
|
|
70
|
+
- `styled-components`
|
|
71
71
|
|
|
72
72
|
To change this list of libraries, you can define a custom set of `importSources`, which accepts an
|
|
73
73
|
array of package names (strings).
|
|
@@ -34,13 +34,13 @@ const styles = css({});
|
|
|
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).
|
|
@@ -34,13 +34,13 @@ const animation = keyframes({});
|
|
|
34
34
|
|
|
35
35
|
By default, this rule will check `keyframes` 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).
|
|
@@ -24,11 +24,11 @@ import { cssMap } from '@compiled/react';
|
|
|
24
24
|
// (not within a function, class, etc.)
|
|
25
25
|
|
|
26
26
|
const Foo = () => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
const bar = cssMap({
|
|
28
|
+
danger: {
|
|
29
|
+
color: 'red',
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
32
|
};
|
|
33
33
|
```
|
|
34
34
|
|
|
@@ -42,11 +42,11 @@ import { importedVariable, importedFunction } from 'another-package';
|
|
|
42
42
|
const myVariable = importedFunction();
|
|
43
43
|
|
|
44
44
|
const styles = cssMap({
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
danger: {
|
|
46
|
+
// Both invalid because they rely on an imported function.
|
|
47
|
+
color: myVariable,
|
|
48
|
+
padding: importedFunction(),
|
|
49
|
+
},
|
|
50
50
|
});
|
|
51
51
|
```
|
|
52
52
|
|
|
@@ -58,9 +58,9 @@ import { cssMap } from '@compiled/react';
|
|
|
58
58
|
// Any usages of cssMap must be in the same file.
|
|
59
59
|
|
|
60
60
|
export const foo = cssMap({
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
danger: {
|
|
62
|
+
color: 'red',
|
|
63
|
+
},
|
|
64
64
|
});
|
|
65
65
|
```
|
|
66
66
|
|
|
@@ -73,29 +73,29 @@ import { token } from '@atlaskit/tokens';
|
|
|
73
73
|
// values in cssMap.
|
|
74
74
|
|
|
75
75
|
const styles = cssMap({
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
76
|
+
// Object method
|
|
77
|
+
get danger() {
|
|
78
|
+
return { color: '#123456' };
|
|
79
|
+
},
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
const styles2 = cssMap({
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
// Arrow function
|
|
84
|
+
danger: () => {
|
|
85
|
+
color: '#123456';
|
|
86
|
+
},
|
|
87
87
|
});
|
|
88
88
|
|
|
89
89
|
function customFunction(...args) {
|
|
90
|
-
|
|
90
|
+
return arguments.join('');
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
const styles3 = cssMap({
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
94
|
+
danger: {
|
|
95
|
+
// Locally defined function
|
|
96
|
+
color: customFunction('red', 'blue'),
|
|
97
|
+
backgroundColor: 'red',
|
|
98
|
+
},
|
|
99
99
|
});
|
|
100
100
|
```
|
|
101
101
|
|
|
@@ -106,16 +106,16 @@ import { cssMap } from '@compiled/react';
|
|
|
106
106
|
// Spread elements ("...") cannot be used in cssMap.
|
|
107
107
|
|
|
108
108
|
const base = {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
109
|
+
success: {
|
|
110
|
+
color: 'green',
|
|
111
|
+
},
|
|
112
112
|
};
|
|
113
113
|
|
|
114
114
|
const bar = cssMap({
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
115
|
+
...base,
|
|
116
|
+
danger: {
|
|
117
|
+
color: 'red',
|
|
118
|
+
},
|
|
119
119
|
});
|
|
120
120
|
```
|
|
121
121
|
|
|
@@ -129,14 +129,14 @@ import { cssMap } from '@compiled/react';
|
|
|
129
129
|
// in cssMap.
|
|
130
130
|
|
|
131
131
|
const styles = cssMap({
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
132
|
+
danger: {
|
|
133
|
+
color: 'red',
|
|
134
|
+
backgroundColor: 'red',
|
|
135
|
+
},
|
|
136
|
+
success: {
|
|
137
|
+
color: 'green',
|
|
138
|
+
backgroundColor: 'green',
|
|
139
|
+
},
|
|
140
140
|
});
|
|
141
141
|
```
|
|
142
142
|
|
|
@@ -150,9 +150,9 @@ import { cssMap } from '@compiled/react';
|
|
|
150
150
|
const bap = 'blue';
|
|
151
151
|
|
|
152
152
|
const styles = cssMap({
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
153
|
+
danger: {
|
|
154
|
+
color: bap,
|
|
155
|
+
},
|
|
156
156
|
});
|
|
157
157
|
```
|
|
158
158
|
|
|
@@ -169,13 +169,13 @@ import { cssMap } from '@compiled/react';
|
|
|
169
169
|
import { token } from '@atlaskit/tokens';
|
|
170
170
|
|
|
171
171
|
const styles = cssMap({
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
172
|
+
danger: {
|
|
173
|
+
color: token('my-color'),
|
|
174
|
+
backgroundColor: 'red',
|
|
175
|
+
},
|
|
176
|
+
success: {
|
|
177
|
+
color: 'green',
|
|
178
|
+
},
|
|
179
179
|
});
|
|
180
180
|
```
|
|
181
181
|
|
|
@@ -40,12 +40,12 @@ import { keyframes } from '@compiled/react';
|
|
|
40
40
|
keyframes({ to: { opacity: 0 } });
|
|
41
41
|
|
|
42
42
|
const fadeOut = keyframes({
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
from: {
|
|
44
|
+
opacity: 1,
|
|
45
|
+
},
|
|
46
|
+
to: {
|
|
47
|
+
opacity: 0,
|
|
48
|
+
},
|
|
49
49
|
});
|
|
50
50
|
```
|
|
51
51
|
|
|
@@ -55,13 +55,13 @@ const fadeOut = keyframes({
|
|
|
55
55
|
|
|
56
56
|
By default, this rule will check `keyframes` usages from:
|
|
57
57
|
|
|
58
|
-
-
|
|
59
|
-
-
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
-
|
|
58
|
+
- `@atlaskit/css`
|
|
59
|
+
- `@atlaskit/primitives`
|
|
60
|
+
- `@compiled/react`
|
|
61
|
+
- `@emotion/react`
|
|
62
|
+
- `@emotion/core`
|
|
63
|
+
- `@emotion/styled`
|
|
64
|
+
- `styled-components`
|
|
65
65
|
|
|
66
66
|
To change this list of libraries, you can define a custom set of `importSources`, which accepts an
|
|
67
67
|
array of package names (strings).
|
|
@@ -77,4 +77,4 @@ export const animation = keyframes``;
|
|
|
77
77
|
|
|
78
78
|
## Limitations
|
|
79
79
|
|
|
80
|
-
-
|
|
80
|
+
- Comments are not fixable
|