@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
|
@@ -4,11 +4,11 @@ import rule from '../index';
|
|
|
4
4
|
const importSources = ['@emotion/core', '@emotion/react', 'styled-components'];
|
|
5
5
|
|
|
6
6
|
tester.run('keyframes 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 { keyframes } from '${importSource}';
|
|
13
13
|
|
|
14
14
|
const fadeIn = keyframes({
|
|
@@ -20,7 +20,7 @@ tester.run('keyframes API - fixable', rule, {
|
|
|
20
20
|
}
|
|
21
21
|
});
|
|
22
22
|
`,
|
|
23
|
-
|
|
23
|
+
output: `
|
|
24
24
|
import { keyframes } from '@compiled/react';
|
|
25
25
|
|
|
26
26
|
const fadeIn = keyframes({
|
|
@@ -32,10 +32,10 @@ tester.run('keyframes API - fixable', rule, {
|
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
34
|
`,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
36
|
+
options: [{ canAutoFix: true }],
|
|
37
|
+
},
|
|
38
|
+
]),
|
|
39
39
|
});
|
|
40
40
|
|
|
41
41
|
/**
|
|
@@ -43,11 +43,11 @@ tester.run('keyframes API - fixable', rule, {
|
|
|
43
43
|
* them unsafe to automatically convert.
|
|
44
44
|
*/
|
|
45
45
|
tester.run('keyframes API - not fixable', rule, {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
valid: [],
|
|
47
|
+
invalid: importSources.flatMap((importSource) => [
|
|
48
|
+
{
|
|
49
|
+
name: `[${importSource}] function as style argument`,
|
|
50
|
+
code: `
|
|
51
51
|
import { keyframes } from '${importSource}';
|
|
52
52
|
|
|
53
53
|
const Component = keyframes(() => ({
|
|
@@ -59,12 +59,12 @@ tester.run('keyframes API - not fixable', rule, {
|
|
|
59
59
|
}
|
|
60
60
|
}));
|
|
61
61
|
`,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
63
|
+
options: [{ canAutoFix: true }],
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: `[${importSource}] function as style object value`,
|
|
67
|
+
code: `
|
|
68
68
|
import { keyframes } from '${importSource}';
|
|
69
69
|
|
|
70
70
|
const Component = keyframes({
|
|
@@ -76,12 +76,12 @@ tester.run('keyframes API - not fixable', rule, {
|
|
|
76
76
|
}
|
|
77
77
|
});
|
|
78
78
|
`,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
80
|
+
options: [{ canAutoFix: true }],
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: `[${importSource}] identifier as style object value`,
|
|
84
|
+
code: `
|
|
85
85
|
import { keyframes } from '${importSource}';
|
|
86
86
|
|
|
87
87
|
const startOpacity = 0;
|
|
@@ -94,16 +94,16 @@ tester.run('keyframes API - not fixable', rule, {
|
|
|
94
94
|
}
|
|
95
95
|
});
|
|
96
96
|
`,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
97
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
98
|
+
options: [{ canAutoFix: true }],
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
/**
|
|
102
|
+
* We could auto-fix this safely but intentionally
|
|
103
|
+
* keeping this rule very simple for now.
|
|
104
|
+
*/
|
|
105
|
+
name: `[${importSource}] function call as style object value`,
|
|
106
|
+
code: `
|
|
107
107
|
import { keyframes } from '${importSource}';
|
|
108
108
|
import { token } from '@atlaskit/tokens';
|
|
109
109
|
|
|
@@ -116,12 +116,12 @@ tester.run('keyframes API - not fixable', rule, {
|
|
|
116
116
|
}
|
|
117
117
|
});
|
|
118
118
|
`,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
119
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
120
|
+
options: [{ canAutoFix: true }],
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: `[${importSource}] with unsupported named import`,
|
|
124
|
+
code: `
|
|
125
125
|
import { keyframes, type CSSObject } from '${importSource}';
|
|
126
126
|
|
|
127
127
|
const fadeIn = keyframes({
|
|
@@ -133,8 +133,8 @@ tester.run('keyframes API - not fixable', rule, {
|
|
|
133
133
|
}
|
|
134
134
|
})
|
|
135
135
|
`,
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
136
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
137
|
+
options: [{ canAutoFix: true }],
|
|
138
|
+
},
|
|
139
|
+
]),
|
|
140
140
|
});
|
|
@@ -2,107 +2,107 @@ import { tester } from '../../__tests__/utils/_tester';
|
|
|
2
2
|
import rule from '../index';
|
|
3
3
|
|
|
4
4
|
tester.run('jsxImportSource pragma - fixable', rule, {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
valid: [],
|
|
6
|
+
invalid: ['@emotion/core', '@emotion/react']
|
|
7
|
+
.flatMap((importSource) => [
|
|
8
|
+
{
|
|
9
|
+
name: `[${importSource}] fixable import exists`,
|
|
10
|
+
code: `
|
|
11
11
|
/** @jsxImportSource @emotion/react */
|
|
12
12
|
|
|
13
13
|
import { css } from '${importSource}';
|
|
14
14
|
`,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
/**
|
|
16
|
+
* This output does not have a fixed pragma because the rule tester
|
|
17
|
+
* only does a single pass of the fixers.
|
|
18
|
+
*
|
|
19
|
+
* In reality up to 10 passes are done. We can see that from this state
|
|
20
|
+
* the pragma does get fixed in the test below.
|
|
21
|
+
*/
|
|
22
|
+
output: `
|
|
23
23
|
/** @jsxImportSource @emotion/react */
|
|
24
24
|
|
|
25
25
|
import { css } from '@compiled/react';
|
|
26
26
|
`,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
errors: [{ messageId: 'use-compiled' }, { messageId: 'use-compiled' }],
|
|
28
|
+
options: [{ canAutoFix: true }],
|
|
29
|
+
},
|
|
30
|
+
])
|
|
31
|
+
.concat([
|
|
32
|
+
{
|
|
33
|
+
name: `[@emotion/styled] fixable import exists`,
|
|
34
|
+
code: `
|
|
35
35
|
/** @jsxImportSource @emotion/react */
|
|
36
36
|
|
|
37
37
|
import styled from '@emotion/styled';
|
|
38
38
|
`,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
/**
|
|
40
|
+
* This output does not have a fixed pragma because the rule tester
|
|
41
|
+
* only does a single pass of the fixers.
|
|
42
|
+
*
|
|
43
|
+
* In reality up to 10 passes are done. We can see that from this state
|
|
44
|
+
* the pragma does get fixed in the test below.
|
|
45
|
+
*/
|
|
46
|
+
output: `
|
|
47
47
|
/** @jsxImportSource @emotion/react */
|
|
48
48
|
|
|
49
49
|
import { styled } from '@compiled/react';
|
|
50
50
|
`,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
errors: [{ messageId: 'use-compiled' }, { messageId: 'use-compiled' }],
|
|
52
|
+
options: [{ canAutoFix: true }],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
name: 'no @emotion imports and has @compiled/react import',
|
|
56
|
+
code: `
|
|
57
57
|
/** @jsxImportSource @emotion/react */
|
|
58
58
|
|
|
59
59
|
import { css } from '@compiled/react';
|
|
60
60
|
`,
|
|
61
|
-
|
|
61
|
+
output: `
|
|
62
62
|
/** @jsxImportSource @compiled/react */
|
|
63
63
|
|
|
64
64
|
import { css } from '@compiled/react';
|
|
65
65
|
`,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
67
|
+
options: [{ canAutoFix: true }],
|
|
68
|
+
},
|
|
69
|
+
]),
|
|
70
70
|
});
|
|
71
71
|
|
|
72
72
|
tester.run('jsxImportSource pragma - not fixable', rule, {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
73
|
+
valid: [],
|
|
74
|
+
invalid: [
|
|
75
|
+
{
|
|
76
|
+
name: 'no @compiled/react import',
|
|
77
|
+
code: `/** @jsxImportSource @emotion/react */`,
|
|
78
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: 'non-fixable @emotion/core import exists',
|
|
82
|
+
code: `
|
|
83
83
|
/** @jsxImportSource @emotion/react */
|
|
84
84
|
|
|
85
85
|
import { type CSSObject } from '@emotion/core';
|
|
86
86
|
`,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
87
|
+
errors: [{ messageId: 'use-compiled' }, { messageId: 'use-compiled' }],
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: 'non-fixable @emotion/react import exists',
|
|
91
|
+
code: `
|
|
92
92
|
/** @jsxImportSource @emotion/react */
|
|
93
93
|
|
|
94
94
|
import { type CSSObject } from '@emotion/react';
|
|
95
95
|
`,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
96
|
+
errors: [{ messageId: 'use-compiled' }, { messageId: 'use-compiled' }],
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: 'non-fixable @emotion/styled import exists',
|
|
100
|
+
code: `
|
|
101
101
|
/** @jsxImportSource @emotion/react */
|
|
102
102
|
|
|
103
103
|
import { type CSSObject } from '@emotion/styled';
|
|
104
104
|
`,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
errors: [{ messageId: 'use-compiled' }, { messageId: 'use-compiled' }],
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
108
|
});
|
|
@@ -2,28 +2,28 @@ import { tester } from '../../__tests__/utils/_tester';
|
|
|
2
2
|
import rule from '../index';
|
|
3
3
|
|
|
4
4
|
tester.run('styled API - fixable', rule, {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
valid: [],
|
|
6
|
+
invalid: ['@emotion/styled', 'styled-components'].flatMap((importSource) => [
|
|
7
|
+
{
|
|
8
|
+
name: `[${importSource}] styles are a plain object with literal values`,
|
|
9
|
+
code: `
|
|
10
10
|
import styled from '${importSource}';
|
|
11
11
|
|
|
12
12
|
const Component = styled.div({
|
|
13
13
|
color: 'red',
|
|
14
14
|
});
|
|
15
15
|
`,
|
|
16
|
-
|
|
16
|
+
output: `
|
|
17
17
|
import { styled } from '@compiled/react';
|
|
18
18
|
|
|
19
19
|
const Component = styled.div({
|
|
20
20
|
color: 'red',
|
|
21
21
|
});
|
|
22
22
|
`,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
24
|
+
options: [{ canAutoFix: true }],
|
|
25
|
+
},
|
|
26
|
+
]),
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
/**
|
|
@@ -31,35 +31,35 @@ tester.run('styled API - fixable', rule, {
|
|
|
31
31
|
* them unsafe to automatically convert.
|
|
32
32
|
*/
|
|
33
33
|
tester.run('styled API - not fixable', rule, {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
valid: [],
|
|
35
|
+
invalid: ['@emotion/styled', 'styled-components'].flatMap((importSource) => [
|
|
36
|
+
{
|
|
37
|
+
name: `[${importSource}] function as style argument`,
|
|
38
|
+
code: `
|
|
39
39
|
import styled from '${importSource}';
|
|
40
40
|
|
|
41
41
|
const Component = styled.div(() => ({
|
|
42
42
|
color: 'red',
|
|
43
43
|
}));
|
|
44
44
|
`,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
46
|
+
options: [{ canAutoFix: true }],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: `[${importSource}] function as style object value`,
|
|
50
|
+
code: `
|
|
51
51
|
import styled from '${importSource}';
|
|
52
52
|
|
|
53
53
|
const Component = styled.div({
|
|
54
54
|
color: () => 'red',
|
|
55
55
|
});
|
|
56
56
|
`,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
57
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
58
|
+
options: [{ canAutoFix: true }],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: `[${importSource}] identifier as style object value`,
|
|
62
|
+
code: `
|
|
63
63
|
import styled from '${importSource}';
|
|
64
64
|
|
|
65
65
|
const textColor = 'red';
|
|
@@ -67,16 +67,16 @@ tester.run('styled API - not fixable', rule, {
|
|
|
67
67
|
color: textColor,
|
|
68
68
|
});
|
|
69
69
|
`,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
70
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
71
|
+
options: [{ canAutoFix: true }],
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
/**
|
|
75
|
+
* We could auto-fix this safely but intentionally
|
|
76
|
+
* keeping this rule very simple for now.
|
|
77
|
+
*/
|
|
78
|
+
name: `[${importSource}] function call as style object value`,
|
|
79
|
+
code: `
|
|
80
80
|
import styled from '${importSource}';
|
|
81
81
|
import { token } from '@atlaskit/tokens';
|
|
82
82
|
|
|
@@ -84,31 +84,31 @@ tester.run('styled API - not fixable', rule, {
|
|
|
84
84
|
color: token('color.text'),
|
|
85
85
|
});
|
|
86
86
|
`,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
88
|
+
options: [{ canAutoFix: true }],
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: `[${importSource}] styled call extends component`,
|
|
92
|
+
code: `
|
|
93
93
|
import styled from '${importSource}';
|
|
94
94
|
import { BaseComponent } from './base-component';
|
|
95
95
|
|
|
96
96
|
const Component = styled(BaseComponent)({});
|
|
97
97
|
`,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
99
|
+
options: [{ canAutoFix: true }],
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: `[${importSource}] with unsupported named import`,
|
|
103
|
+
code: `
|
|
104
104
|
import styled, { type CSSObject } from '${importSource}';
|
|
105
105
|
|
|
106
106
|
const Component = styled.div({
|
|
107
107
|
color: 'red',
|
|
108
108
|
});
|
|
109
109
|
`,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
110
|
+
errors: [{ messageId: 'use-compiled' }],
|
|
111
|
+
options: [{ canAutoFix: true }],
|
|
112
|
+
},
|
|
113
|
+
]),
|
|
114
114
|
});
|
|
@@ -2,14 +2,14 @@ import { tester } from '../../__tests__/utils/_tester';
|
|
|
2
2
|
import rule from '../index';
|
|
3
3
|
|
|
4
4
|
tester.run('use-compiled', rule, {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
valid: [
|
|
6
|
+
`import { styled } from '@compiled/react';`,
|
|
7
|
+
`import { css } from '@compiled/react';`,
|
|
8
|
+
`import { ClassNames } from '@compiled/react';`,
|
|
9
|
+
`import { css, ClassNames, styled } from '@compiled/react';`,
|
|
10
|
+
`import '@compiled/react'`,
|
|
11
|
+
`/** @jsx jsx */`,
|
|
12
|
+
`/** @jsxImportSource @compiled/react */`,
|
|
13
|
+
],
|
|
14
|
+
invalid: [],
|
|
15
15
|
});
|