@atlaskit/eslint-plugin-ui-styling-standard 0.15.1 → 0.16.0
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/index/migration-guide.mdx +309 -0
- package/constellation/index/overview.mdx +4 -0
- package/constellation/index/props.mdx +9 -5
- package/dist/cjs/rules/no-nested-selectors/index.js +68 -49
- package/dist/es2019/rules/no-nested-selectors/index.js +63 -45
- package/dist/esm/rules/no-nested-selectors/index.js +64 -49
- package/dist/types/rules/no-unsafe-selectors/constants.d.ts +1 -4
- package/index.js +9 -9
- package/package.json +3 -3
- package/scripts/codegen.tsx +223 -284
- package/src/rules/__tests__/utils/_tester.tsx +24 -24
- package/src/rules/atlaskit-theme/README.md +21 -19
- package/src/rules/atlaskit-theme/__tests__/test.ts +53 -53
- package/src/rules/atlaskit-theme/index.ts +107 -115
- package/src/rules/convert-props-syntax/README.md +32 -22
- package/src/rules/convert-props-syntax/__tests__/invalid.test.tsx +46 -46
- package/src/rules/convert-props-syntax/__tests__/rule.test.tsx +175 -175
- package/src/rules/convert-props-syntax/__tests__/type-annotations.test.tsx +52 -52
- package/src/rules/convert-props-syntax/__tests__/unusual-properties.test.tsx +33 -33
- package/src/rules/convert-props-syntax/index.tsx +356 -386
- package/src/rules/enforce-style-prop/README.md +21 -18
- package/src/rules/enforce-style-prop/__tests__/rule.test.tsx +90 -96
- package/src/rules/enforce-style-prop/index.tsx +144 -160
- package/src/rules/external-rules.tsx +163 -164
- package/src/rules/local-cx-xcss/README.md +10 -6
- package/src/rules/local-cx-xcss/__tests__/rule.test.tsx +26 -26
- package/src/rules/local-cx-xcss/index.tsx +46 -56
- package/src/rules/no-array-arguments/README.md +2 -1
- package/src/rules/no-array-arguments/__tests__/rule.test.tsx +37 -46
- package/src/rules/no-array-arguments/index.tsx +68 -69
- package/src/rules/no-classname-prop/README.md +7 -4
- package/src/rules/no-classname-prop/__tests__/rule.test.tsx +22 -22
- package/src/rules/no-classname-prop/index.tsx +25 -25
- package/src/rules/no-container-queries/README.md +11 -9
- package/src/rules/no-container-queries/__tests__/rule.test.tsx +47 -50
- package/src/rules/no-container-queries/index.tsx +75 -81
- package/src/rules/no-dynamic-styles/README.md +16 -19
- package/src/rules/no-dynamic-styles/__tests__/rule.test.tsx +58 -67
- package/src/rules/no-dynamic-styles/index.tsx +45 -48
- package/src/rules/no-exported-styles/README.md +17 -12
- package/src/rules/no-exported-styles/__tests__/rule.test.tsx +102 -111
- package/src/rules/no-exported-styles/index.tsx +36 -36
- package/src/rules/no-global-styles/README.md +15 -14
- package/src/rules/no-global-styles/__tests__/no-css-modules.test.tsx +28 -28
- package/src/rules/no-global-styles/__tests__/no-global-styles.test.tsx +37 -37
- package/src/rules/no-global-styles/index.tsx +59 -62
- package/src/rules/no-important-styles/README.md +5 -3
- package/src/rules/no-important-styles/__tests__/rule.test.tsx +66 -66
- package/src/rules/no-important-styles/index.tsx +49 -49
- package/src/rules/no-imported-style-values/README.md +23 -15
- package/src/rules/no-imported-style-values/__tests__/rule.test.tsx +123 -123
- package/src/rules/no-imported-style-values/index.tsx +116 -120
- package/src/rules/no-nested-selectors/README.md +15 -13
- package/src/rules/no-nested-selectors/__tests__/rule.test.tsx +186 -149
- package/src/rules/no-nested-selectors/index.tsx +92 -105
- package/src/rules/no-styled/README.md +14 -9
- package/src/rules/no-styled/__tests__/rule.test.tsx +31 -31
- package/src/rules/no-styled/index.tsx +34 -41
- package/src/rules/no-unsafe-selectors/README.md +103 -93
- package/src/rules/no-unsafe-selectors/__tests__/no-grouped-at-rules.test.tsx +21 -24
- package/src/rules/no-unsafe-selectors/__tests__/no-increased-specificity.test.tsx +44 -44
- package/src/rules/no-unsafe-selectors/__tests__/no-keyframes-at-rules.test.tsx +21 -21
- package/src/rules/no-unsafe-selectors/__tests__/no-legacy-pseudo-element-syntax.test.tsx +57 -57
- package/src/rules/no-unsafe-selectors/__tests__/no-restricted-at-rules.test.tsx +58 -58
- package/src/rules/no-unsafe-selectors/__tests__/no-restricted-pseudos.test.tsx +85 -85
- package/src/rules/no-unsafe-selectors/__tests__/no-selectors-object.test.tsx +12 -12
- package/src/rules/no-unsafe-selectors/__tests__/no-unparsable-selectors.test.tsx +23 -23
- package/src/rules/no-unsafe-selectors/__tests__/rule.test.tsx +114 -114
- package/src/rules/no-unsafe-selectors/constants.tsx +69 -77
- package/src/rules/no-unsafe-selectors/source-position-utils.tsx +38 -38
- package/src/rules/no-unsafe-selectors/walk-css-map.tsx +178 -184
- package/src/rules/no-unsafe-values/README.md +34 -40
- package/src/rules/no-unsafe-values/__tests__/no-array-values.test.tsx +13 -13
- package/src/rules/no-unsafe-values/__tests__/no-conditional-values.test.tsx +18 -18
- package/src/rules/no-unsafe-values/__tests__/no-dynamic-keys.test.tsx +104 -104
- package/src/rules/no-unsafe-values/__tests__/no-function-calls.test.tsx +128 -128
- package/src/rules/no-unsafe-values/__tests__/no-identifier-arguments.test.tsx +23 -23
- package/src/rules/no-unsafe-values/__tests__/no-object-access.test.tsx +38 -38
- package/src/rules/no-unsafe-values/__tests__/no-object-references.test.tsx +18 -18
- package/src/rules/no-unsafe-values/__tests__/no-spread-elements.test.tsx +18 -18
- package/src/rules/no-unsafe-values/__tests__/no-unsafe-values.test.tsx +28 -28
- package/src/rules/no-unsafe-values/__tests__/no-variables.test.tsx +47 -47
- package/src/rules/no-unsafe-values/index.tsx +76 -78
- package/src/rules/no-unsafe-values/messages.tsx +12 -12
- package/src/rules/no-unsafe-values/utils.tsx +370 -382
- package/src/rules/use-compiled/README.md +11 -8
- package/src/rules/use-compiled/__tests__/can-auto-fix.test.tsx +32 -32
- package/src/rules/use-compiled/__tests__/css.test.tsx +53 -53
- package/src/rules/use-compiled/__tests__/imports.test.tsx +90 -95
- package/src/rules/use-compiled/__tests__/keyframes.test.tsx +47 -47
- package/src/rules/use-compiled/__tests__/pragma.test.tsx +64 -64
- package/src/rules/use-compiled/__tests__/styled.test.tsx +53 -53
- package/src/rules/use-compiled/__tests__/use-compiled.test.tsx +10 -10
- package/src/rules/use-compiled/index.tsx +203 -226
- package/src/rules/use-compiled/is-safe.tsx +113 -117
- package/src/rules/use-compiled/utils.tsx +14 -18
- package/src/rules/utils/create-rule-with-typed-config.tsx +62 -63
- package/src/rules/utils/create-rule.tsx +3 -6
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
Ensures usage of `@compiled/react` over other CSS-in-JS libraries like Emotion or styled-components.
|
|
2
2
|
|
|
3
|
-
**WARNING**
|
|
4
|
-
|
|
3
|
+
**WARNING** It may be unsafe to mix usages of `@compiled/react` with other CSS-in-JS libraries on
|
|
4
|
+
the same component. When converting to `@compiled/react` verify ALL changes. For this reason, the
|
|
5
|
+
auto-fixer has been disabled by default, but it may be useful to enable to empower a migration.
|
|
5
6
|
|
|
6
7
|
## Examples
|
|
7
8
|
|
|
@@ -20,21 +21,22 @@ import styled, { css } from 'styled-components';
|
|
|
20
21
|
|
|
21
22
|
### Correct
|
|
22
23
|
|
|
23
|
-
We expect usage of `xcss` with `@atlaskit/primitives` when working with Primitives, and `css` with
|
|
24
|
+
We expect usage of `xcss` with `@atlaskit/primitives` when working with Primitives, and `css` with
|
|
25
|
+
`@compiled/react` when working with custom or native code.
|
|
24
26
|
|
|
25
27
|
```js
|
|
26
28
|
/** @jsx jsx */
|
|
27
29
|
import { jsx, css, styled } from '@compiled/react';
|
|
28
30
|
|
|
29
31
|
const styles = css({ color: 'var(--ds-color-text)' });
|
|
30
|
-
export default () => <div css={styles}>…</div
|
|
32
|
+
export default () => <div css={styles}>…</div>;
|
|
31
33
|
```
|
|
32
34
|
|
|
33
35
|
```js
|
|
34
36
|
import { xcss, Box } from '@atlaskit/primitives';
|
|
35
37
|
|
|
36
38
|
const styles = xcss({ color: 'color.text' });
|
|
37
|
-
export default () => <Box xcss={styles}>…</Box
|
|
39
|
+
export default () => <Box xcss={styles}>…</Box>;
|
|
38
40
|
```
|
|
39
41
|
|
|
40
42
|
## Options
|
|
@@ -43,7 +45,8 @@ export default () => <Box xcss={styles}>…</Box>
|
|
|
43
45
|
|
|
44
46
|
Determines whether or not the auto-fixer is enabled.
|
|
45
47
|
|
|
46
|
-
Defaults to `false` due to safety concerns when mixing Compiled and other CSS-in-JS libraries on the
|
|
48
|
+
Defaults to `false` due to safety concerns when mixing Compiled and other CSS-in-JS libraries on the
|
|
49
|
+
same component.
|
|
47
50
|
|
|
48
|
-
Even when enabled, the auto-fixer will only convert usages that are deemed safe.
|
|
49
|
-
|
|
51
|
+
Even when enabled, the auto-fixer will only convert usages that are deemed safe. Currently this is
|
|
52
|
+
limited to purely static styles where all keys and values are simple literals.
|
|
@@ -3,27 +3,27 @@ import { tester } from '../../__tests__/utils/_tester';
|
|
|
3
3
|
import rule from '../index';
|
|
4
4
|
|
|
5
5
|
const invalid: RuleTester.InvalidTestCase[] = [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
{
|
|
7
|
+
name: 'css API',
|
|
8
|
+
code: `
|
|
9
9
|
import { css } from '@emotion/react';
|
|
10
10
|
|
|
11
11
|
const Component = css({
|
|
12
12
|
color: 'red',
|
|
13
13
|
});
|
|
14
14
|
`,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'imports',
|
|
19
|
+
code: `
|
|
20
20
|
import { css as c, keyframes as kf } from '@emotion/core';
|
|
21
21
|
`,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: `keyframes API`,
|
|
26
|
+
code: `
|
|
27
27
|
import { keyframes } from 'styled-components';
|
|
28
28
|
|
|
29
29
|
const fadeIn = keyframes({
|
|
@@ -35,39 +35,39 @@ const invalid: RuleTester.InvalidTestCase[] = [
|
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
`,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'pragma fix',
|
|
42
|
+
code: `
|
|
43
43
|
/** @jsxImportSource @emotion/react */
|
|
44
44
|
|
|
45
45
|
import { css } from '@compiled/react';
|
|
46
46
|
`,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: `styles are a plain object with literal values`,
|
|
51
|
+
code: `
|
|
52
52
|
import styled from '@emotion/styled';
|
|
53
53
|
|
|
54
54
|
const Component = styled.div({
|
|
55
55
|
color: 'red',
|
|
56
56
|
});
|
|
57
57
|
`,
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
59
|
+
},
|
|
60
60
|
];
|
|
61
61
|
|
|
62
62
|
tester.run('canAutoFix is not provided', rule, {
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
valid: [],
|
|
64
|
+
invalid,
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
tester.run('canAutoFix is false', rule, {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
valid: [],
|
|
69
|
+
invalid: invalid.map((testCase) => ({
|
|
70
|
+
...testCase,
|
|
71
|
+
options: [{ canAutoFix: false }],
|
|
72
|
+
})),
|
|
73
73
|
});
|
|
@@ -4,28 +4,28 @@ import rule from '../index';
|
|
|
4
4
|
const importSources = ['@emotion/core', '@emotion/react', 'styled-components'];
|
|
5
5
|
|
|
6
6
|
tester.run('css API - fixable', rule, {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
valid: [],
|
|
8
|
+
invalid: importSources.flatMap((importSource) => [
|
|
9
|
+
{
|
|
10
|
+
name: `[${importSource}] styles are a plain object with literal values`,
|
|
11
|
+
code: `
|
|
12
12
|
import { css } from '${importSource}';
|
|
13
13
|
|
|
14
14
|
const Component = css({
|
|
15
15
|
color: 'red',
|
|
16
16
|
});
|
|
17
17
|
`,
|
|
18
|
-
|
|
18
|
+
output: `
|
|
19
19
|
import { css } from '@compiled/react';
|
|
20
20
|
|
|
21
21
|
const Component = css({
|
|
22
22
|
color: 'red',
|
|
23
23
|
});
|
|
24
24
|
`,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
26
|
+
options: [{ canAutoFix: true }],
|
|
27
|
+
},
|
|
28
|
+
]),
|
|
29
29
|
});
|
|
30
30
|
|
|
31
31
|
/**
|
|
@@ -33,35 +33,35 @@ tester.run('css API - fixable', rule, {
|
|
|
33
33
|
* them unsafe to automatically convert.
|
|
34
34
|
*/
|
|
35
35
|
tester.run('css API - not fixable', rule, {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
valid: [],
|
|
37
|
+
invalid: importSources.flatMap((importSource) => [
|
|
38
|
+
{
|
|
39
|
+
name: `[${importSource}] function as style argument`,
|
|
40
|
+
code: `
|
|
41
41
|
import { css } from '${importSource}';
|
|
42
42
|
|
|
43
43
|
const Component = css(() => ({
|
|
44
44
|
color: 'red',
|
|
45
45
|
}));
|
|
46
46
|
`,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
48
|
+
options: [{ canAutoFix: true }],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: `[${importSource}] function as style object value`,
|
|
52
|
+
code: `
|
|
53
53
|
import { css } from '${importSource}';
|
|
54
54
|
|
|
55
55
|
const Component = css({
|
|
56
56
|
color: () => 'red',
|
|
57
57
|
});
|
|
58
58
|
`,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
60
|
+
options: [{ canAutoFix: true }],
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: `[${importSource}] identifier as style object value`,
|
|
64
|
+
code: `
|
|
65
65
|
import { css } from '${importSource}';
|
|
66
66
|
|
|
67
67
|
const textColor = 'red';
|
|
@@ -69,16 +69,16 @@ tester.run('css API - not fixable', rule, {
|
|
|
69
69
|
color: textColor,
|
|
70
70
|
});
|
|
71
71
|
`,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
72
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
73
|
+
options: [{ canAutoFix: true }],
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
/**
|
|
77
|
+
* We could auto-fix this safely but intentionally
|
|
78
|
+
* keeping this rule very simple for now.
|
|
79
|
+
*/
|
|
80
|
+
name: `[${importSource}] function call as style object value`,
|
|
81
|
+
code: `
|
|
82
82
|
import { css } from '${importSource}';
|
|
83
83
|
import { token } from '@atlaskit/tokens';
|
|
84
84
|
|
|
@@ -86,24 +86,24 @@ tester.run('css API - not fixable', rule, {
|
|
|
86
86
|
color: token('color.text'),
|
|
87
87
|
});
|
|
88
88
|
`,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
90
|
+
options: [{ canAutoFix: true }],
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: `[${importSource}] with unsupported named import`,
|
|
94
|
+
code: `
|
|
95
95
|
import { css, type CSSObject } from '${importSource}';
|
|
96
96
|
|
|
97
97
|
const Component = css({
|
|
98
98
|
color: 'red',
|
|
99
99
|
});
|
|
100
100
|
`,
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
101
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
102
|
+
options: [{ canAutoFix: true }],
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: `[${importSource}] with unsafe usage of other import`,
|
|
106
|
+
code: `
|
|
107
107
|
import { css, keyframes } from '${importSource}';
|
|
108
108
|
|
|
109
109
|
const Component = css({
|
|
@@ -119,8 +119,8 @@ tester.run('css API - not fixable', rule, {
|
|
|
119
119
|
}
|
|
120
120
|
})
|
|
121
121
|
`,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
123
|
+
options: [{ canAutoFix: true }],
|
|
124
|
+
},
|
|
125
|
+
]),
|
|
126
126
|
});
|
|
@@ -3,137 +3,132 @@ import outdent from 'outdent';
|
|
|
3
3
|
import { tester } from '../../__tests__/utils/_tester';
|
|
4
4
|
import rule from '../index';
|
|
5
5
|
|
|
6
|
-
const importSources = [
|
|
7
|
-
'@emotion/core',
|
|
8
|
-
'@emotion/react',
|
|
9
|
-
'@emotion/styled',
|
|
10
|
-
'styled-components',
|
|
11
|
-
];
|
|
6
|
+
const importSources = ['@emotion/core', '@emotion/react', '@emotion/styled', 'styled-components'];
|
|
12
7
|
|
|
13
8
|
tester.run('imports - ignored', rule, {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
valid: [
|
|
10
|
+
{
|
|
11
|
+
name: "[@atlaskit/primitives.xcss] - is ignored (it's okay to use, for now)",
|
|
12
|
+
code: `
|
|
18
13
|
import { xcss, Box } from '@atlaskit/primitives';
|
|
19
14
|
`,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: "[@atlaskit/css] - is ignored (it's okay to use)",
|
|
18
|
+
code: `
|
|
24
19
|
import { cssMap, keyframes } from '@atlaskit/css';
|
|
25
20
|
`,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: "[@stylexjs/stylex] - is ignored (we don't maintain a list of all CSS-in-JS libraries, but we could)",
|
|
24
|
+
code: `
|
|
30
25
|
import * as stylex from '@stylexjs/stylex';
|
|
31
26
|
`,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
invalid: [],
|
|
35
30
|
});
|
|
36
31
|
|
|
37
32
|
tester.run('imports - fixable', rule, {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
valid: [],
|
|
34
|
+
invalid: [
|
|
35
|
+
{
|
|
36
|
+
name: '[@emotion/core] - supported imports with aliasing',
|
|
37
|
+
code: `
|
|
43
38
|
import { css as c, keyframes as kf } from '@emotion/core';
|
|
44
39
|
`,
|
|
45
|
-
|
|
40
|
+
output: `
|
|
46
41
|
import { css as c, keyframes as kf } from '@compiled/react';
|
|
47
42
|
`,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
43
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
44
|
+
options: [{ canAutoFix: true }],
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: '[@emotion/react] - supported imports with aliasing',
|
|
48
|
+
code: `
|
|
54
49
|
import { css as c, keyframes as kf } from '@emotion/react';
|
|
55
50
|
`,
|
|
56
|
-
|
|
51
|
+
output: `
|
|
57
52
|
import { css as c, keyframes as kf } from '@compiled/react';
|
|
58
53
|
`,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
54
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
55
|
+
options: [{ canAutoFix: true }],
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: '[@emotion/styled] - supported imports with aliasing',
|
|
59
|
+
code: `
|
|
65
60
|
import s from '@emotion/styled';
|
|
66
61
|
`,
|
|
67
|
-
|
|
62
|
+
output: `
|
|
68
63
|
import { styled as s } from '@compiled/react';
|
|
69
64
|
`,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
65
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
66
|
+
options: [{ canAutoFix: true }],
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: '[styled-components] - supported imports with aliasing',
|
|
70
|
+
code: `
|
|
76
71
|
import s, { css as c, keyframes as kf } from 'styled-components';
|
|
77
72
|
`,
|
|
78
|
-
|
|
73
|
+
output: `
|
|
79
74
|
import { css as c, keyframes as kf, styled as s } from '@compiled/react';
|
|
80
75
|
`,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
76
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
77
|
+
options: [{ canAutoFix: true }],
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: '[@emotion/core] - with existing compiled import',
|
|
81
|
+
code: outdent`
|
|
87
82
|
import { css } from '@emotion/core';
|
|
88
83
|
import { styled } from '@compiled/react';
|
|
89
84
|
`,
|
|
90
|
-
|
|
85
|
+
output: outdent`
|
|
91
86
|
|
|
92
87
|
import { styled, css } from '@compiled/react';
|
|
93
88
|
`,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
89
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
90
|
+
options: [{ canAutoFix: true }],
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: '[@emotion/react] - with existing compiled import',
|
|
94
|
+
code: outdent`
|
|
100
95
|
import { css } from '@emotion/react';
|
|
101
96
|
import { styled } from '@compiled/react';
|
|
102
97
|
`,
|
|
103
|
-
|
|
98
|
+
output: outdent`
|
|
104
99
|
|
|
105
100
|
import { styled, css } from '@compiled/react';
|
|
106
101
|
`,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
102
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
103
|
+
options: [{ canAutoFix: true }],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: '[@emotion/styled] - with existing compiled import',
|
|
107
|
+
code: outdent`
|
|
113
108
|
import styled from '@emotion/styled';
|
|
114
109
|
import { css } from '@compiled/react';
|
|
115
110
|
`,
|
|
116
|
-
|
|
111
|
+
output: outdent`
|
|
117
112
|
|
|
118
113
|
import { css, styled } from '@compiled/react';
|
|
119
114
|
`,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
115
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
116
|
+
options: [{ canAutoFix: true }],
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: '[styled-components] - with existing compiled import',
|
|
120
|
+
code: outdent`
|
|
126
121
|
import styled from 'styled-components';
|
|
127
122
|
import { css } from '@compiled/react';
|
|
128
123
|
`,
|
|
129
|
-
|
|
124
|
+
output: outdent`
|
|
130
125
|
|
|
131
126
|
import { css, styled } from '@compiled/react';
|
|
132
127
|
`,
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
128
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
129
|
+
options: [{ canAutoFix: true }],
|
|
130
|
+
},
|
|
131
|
+
],
|
|
137
132
|
});
|
|
138
133
|
|
|
139
134
|
/**
|
|
@@ -141,23 +136,23 @@ tester.run('imports - fixable', rule, {
|
|
|
141
136
|
* them unsafe to automatically convert.
|
|
142
137
|
*/
|
|
143
138
|
tester.run('imports - not fixable', rule, {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
139
|
+
valid: [],
|
|
140
|
+
invalid: importSources.flatMap((importSource) => [
|
|
141
|
+
{
|
|
142
|
+
name: `[${importSource}] namespace import`,
|
|
143
|
+
code: `
|
|
149
144
|
import * as namespace from '${importSource}';
|
|
150
145
|
`,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
146
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
147
|
+
options: [{ canAutoFix: true }],
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: `[${importSource}] unsupported import`,
|
|
151
|
+
code: `
|
|
157
152
|
import { type CSSObject } from '${importSource}';
|
|
158
153
|
`,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
154
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
155
|
+
options: [{ canAutoFix: true }],
|
|
156
|
+
},
|
|
157
|
+
]),
|
|
163
158
|
});
|