@atlaskit/eslint-plugin-ui-styling-standard 0.15.2 → 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 +8 -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/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 +128 -128
- 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
|
@@ -2,44 +2,44 @@ import { typescriptEslintTester } from '../../__tests__/utils/_tester';
|
|
|
2
2
|
import rule from '../index';
|
|
3
3
|
|
|
4
4
|
typescriptEslintTester.run(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
'convert-props-syntax',
|
|
6
|
+
// @ts-expect-error
|
|
7
|
+
rule,
|
|
8
|
+
{
|
|
9
|
+
valid: [
|
|
10
|
+
{
|
|
11
|
+
name: 'ignores styled-components usages using supported props syntax',
|
|
12
|
+
code: `
|
|
13
13
|
import styled from 'styled-components';
|
|
14
14
|
|
|
15
15
|
styled.div((props) => ({
|
|
16
16
|
color: props.color,
|
|
17
17
|
}));
|
|
18
18
|
`,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: 'ignores @emotion/styled usages using supported props syntax',
|
|
22
|
+
code: `
|
|
23
23
|
import styled from '@emotion/styled';
|
|
24
24
|
|
|
25
25
|
styled.div((props) => ({
|
|
26
26
|
color: props.color,
|
|
27
27
|
}));
|
|
28
28
|
`,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
name: 'ignores styled-components usages already using supported props syntax (with logical operator)',
|
|
32
|
+
code: `
|
|
33
33
|
import styled from 'styled-components';
|
|
34
34
|
|
|
35
35
|
styled.div((props) => ({
|
|
36
36
|
color: props => props.color || 'red',
|
|
37
37
|
}));
|
|
38
38
|
`,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: 'ignores styled-components usages using supported props syntax (with multiple properties)',
|
|
42
|
+
code: `
|
|
43
43
|
import styled from 'styled-components';
|
|
44
44
|
|
|
45
45
|
styled.div((props) => ({
|
|
@@ -47,10 +47,10 @@ typescriptEslintTester.run(
|
|
|
47
47
|
backgroundColor: props.backgroundColor,
|
|
48
48
|
}));
|
|
49
49
|
`,
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'ignores compiled usages (props argument)',
|
|
53
|
+
code: `
|
|
54
54
|
import { styled } from '@compiled/react';
|
|
55
55
|
|
|
56
56
|
styled.div({
|
|
@@ -58,10 +58,10 @@ typescriptEslintTester.run(
|
|
|
58
58
|
backgroundColor: (props) => props.backgroundColor,
|
|
59
59
|
});
|
|
60
60
|
`,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'ignores compiled usages (destructured props)',
|
|
64
|
+
code: `
|
|
65
65
|
import { styled } from '@compiled/react';
|
|
66
66
|
|
|
67
67
|
styled.div({
|
|
@@ -69,10 +69,10 @@ typescriptEslintTester.run(
|
|
|
69
69
|
backgroundColor: ({ backgroundColor }) => backgroundColor,
|
|
70
70
|
});
|
|
71
71
|
`,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: 'ignores compiled usages (styled-components style syntax)',
|
|
75
|
+
code: `
|
|
76
76
|
import { styled } from '@compiled/react';
|
|
77
77
|
|
|
78
78
|
styled.div((props) => ({
|
|
@@ -80,20 +80,20 @@ typescriptEslintTester.run(
|
|
|
80
80
|
backgroundColor: props.backgroundColor,
|
|
81
81
|
}));
|
|
82
82
|
`,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: 'ignores template literals passed to styled-components',
|
|
86
|
+
code: `
|
|
87
87
|
import { styled } from 'styled-components';
|
|
88
88
|
|
|
89
89
|
const someStyles = \`border-radius: \${token('border.radius', '3px')};\`;
|
|
90
90
|
|
|
91
91
|
styled.div(someStyles);
|
|
92
92
|
`,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: 'ignores token function passed to styled-components',
|
|
96
|
+
code: `
|
|
97
97
|
import styled from 'styled-components';
|
|
98
98
|
import { token } from 'some-package';
|
|
99
99
|
import { someFallback } from 'other-package';
|
|
@@ -102,10 +102,10 @@ typescriptEslintTester.run(
|
|
|
102
102
|
color: token('some-token', someFallback),
|
|
103
103
|
});
|
|
104
104
|
`,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: 'ignores styled(...).attrs() call',
|
|
108
|
+
code: `
|
|
109
109
|
import { styled } from 'styled-components';
|
|
110
110
|
|
|
111
111
|
const StyledMinimized = styled(Minimized).attrs({
|
|
@@ -114,10 +114,10 @@ typescriptEslintTester.run(
|
|
|
114
114
|
color: blue;
|
|
115
115
|
\`;
|
|
116
116
|
`,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: 'ignores styled.div.attrs<...>() call',
|
|
120
|
+
code: `
|
|
121
121
|
import { styled } from '@compiled/react';
|
|
122
122
|
|
|
123
123
|
export const ModalAnchorOld = styled.div.attrs<ModalAnchorProps>({
|
|
@@ -129,10 +129,10 @@ typescriptEslintTester.run(
|
|
|
129
129
|
position: fixed;
|
|
130
130
|
\`;
|
|
131
131
|
`,
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: 'ignores styled.div.attrs() call',
|
|
135
|
+
code: `
|
|
136
136
|
const BlanketControl = styled.div.attrs({
|
|
137
137
|
style: ({ scrollOffset, width }) => ({
|
|
138
138
|
top: scrollOffset,
|
|
@@ -144,20 +144,20 @@ typescriptEslintTester.run(
|
|
|
144
144
|
justify-content: center;
|
|
145
145
|
\`;
|
|
146
146
|
`,
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
name: 'ignores styled.img.attrs() call',
|
|
150
|
+
code: `
|
|
151
151
|
export const FieldsRestoredIllustration = styled.img.attrs({ src: fieldsRestoredImage })\`
|
|
152
152
|
display: block;
|
|
153
153
|
min-height: 190px;
|
|
154
154
|
max-width: 290px;
|
|
155
155
|
\`;
|
|
156
156
|
`,
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
name: 'ignores options passed to base components',
|
|
160
|
+
code: `
|
|
161
161
|
import styled from '@emotion/styled';
|
|
162
162
|
import { token } from 'some-package';
|
|
163
163
|
import { someFallback } from 'other-package';
|
|
@@ -169,10 +169,10 @@ typescriptEslintTester.run(
|
|
|
169
169
|
color: token('some-token', someFallback),
|
|
170
170
|
});
|
|
171
171
|
`,
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
name: 'ignores options passed to base components when using template string',
|
|
175
|
+
code: `
|
|
176
176
|
import styled from '@emotion/styled';
|
|
177
177
|
import { token } from 'some-package';
|
|
178
178
|
import { someFallback } from 'other-package';
|
|
@@ -184,22 +184,22 @@ typescriptEslintTester.run(
|
|
|
184
184
|
cursor: pointer;
|
|
185
185
|
\`;
|
|
186
186
|
`,
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
name: 'No error on TSAsExpression node type when using ESTraverse',
|
|
190
|
+
code: `
|
|
191
191
|
import styled from '@emotion/styled';
|
|
192
192
|
|
|
193
193
|
const Component = styled.div({
|
|
194
194
|
color: token('color.text') as string,
|
|
195
195
|
});
|
|
196
196
|
`,
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
197
|
+
},
|
|
198
|
+
],
|
|
199
|
+
invalid: [
|
|
200
|
+
{
|
|
201
|
+
name: 'converts @emotion/styled props argument',
|
|
202
|
+
code: `
|
|
203
203
|
import styled from '@emotion/styled';
|
|
204
204
|
|
|
205
205
|
styled.div({
|
|
@@ -207,7 +207,7 @@ typescriptEslintTester.run(
|
|
|
207
207
|
backgroundColor: (props) => props.backgroundColor,
|
|
208
208
|
});
|
|
209
209
|
`,
|
|
210
|
-
|
|
210
|
+
output: `
|
|
211
211
|
import styled from '@emotion/styled';
|
|
212
212
|
|
|
213
213
|
styled.div((props) => ({
|
|
@@ -215,11 +215,11 @@ typescriptEslintTester.run(
|
|
|
215
215
|
backgroundColor: props.backgroundColor,
|
|
216
216
|
}));
|
|
217
217
|
`,
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
218
|
+
errors: [{ messageId: 'unsupported-prop-syntax' }],
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
name: 'converts styled-components props argument',
|
|
222
|
+
code: `
|
|
223
223
|
import styled from 'styled-components';
|
|
224
224
|
|
|
225
225
|
styled.div({
|
|
@@ -227,7 +227,7 @@ typescriptEslintTester.run(
|
|
|
227
227
|
backgroundColor: (props) => props.backgroundColor,
|
|
228
228
|
});
|
|
229
229
|
`,
|
|
230
|
-
|
|
230
|
+
output: `
|
|
231
231
|
import styled from 'styled-components';
|
|
232
232
|
|
|
233
233
|
styled.div((props) => ({
|
|
@@ -235,11 +235,11 @@ typescriptEslintTester.run(
|
|
|
235
235
|
backgroundColor: props.backgroundColor,
|
|
236
236
|
}));
|
|
237
237
|
`,
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
238
|
+
errors: [{ messageId: 'unsupported-prop-syntax' }],
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
name: 'converts styled-components destructured props',
|
|
242
|
+
code: `
|
|
243
243
|
import styled from 'styled-components';
|
|
244
244
|
|
|
245
245
|
styled.div({
|
|
@@ -247,7 +247,7 @@ typescriptEslintTester.run(
|
|
|
247
247
|
backgroundColor: ({ backgroundColor }) => backgroundColor,
|
|
248
248
|
});
|
|
249
249
|
`,
|
|
250
|
-
|
|
250
|
+
output: `
|
|
251
251
|
import styled from 'styled-components';
|
|
252
252
|
|
|
253
253
|
styled.div((props) => ({
|
|
@@ -255,11 +255,11 @@ typescriptEslintTester.run(
|
|
|
255
255
|
backgroundColor: props.backgroundColor,
|
|
256
256
|
}));
|
|
257
257
|
`,
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
258
|
+
errors: [{ messageId: 'unsupported-prop-syntax' }],
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
name: 'converts mixture of props argument and destructured props',
|
|
262
|
+
code: `
|
|
263
263
|
import styled from 'styled-components';
|
|
264
264
|
|
|
265
265
|
styled.div({
|
|
@@ -267,7 +267,7 @@ typescriptEslintTester.run(
|
|
|
267
267
|
backgroundColor: (props) => props.backgroundColor,
|
|
268
268
|
});
|
|
269
269
|
`,
|
|
270
|
-
|
|
270
|
+
output: `
|
|
271
271
|
import styled from 'styled-components';
|
|
272
272
|
|
|
273
273
|
styled.div((props) => ({
|
|
@@ -275,11 +275,11 @@ typescriptEslintTester.run(
|
|
|
275
275
|
backgroundColor: props.backgroundColor,
|
|
276
276
|
}));
|
|
277
277
|
`,
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
278
|
+
errors: [{ messageId: 'unsupported-prop-syntax' }],
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
name: 'converts mix of valid props syntax and invalid props syntax',
|
|
282
|
+
code: `
|
|
283
283
|
import styled from 'styled-components';
|
|
284
284
|
|
|
285
285
|
styled.div(
|
|
@@ -292,7 +292,7 @@ typescriptEslintTester.run(
|
|
|
292
292
|
}
|
|
293
293
|
);
|
|
294
294
|
`,
|
|
295
|
-
|
|
295
|
+
output: `
|
|
296
296
|
import styled from 'styled-components';
|
|
297
297
|
|
|
298
298
|
styled.div(
|
|
@@ -305,11 +305,11 @@ typescriptEslintTester.run(
|
|
|
305
305
|
})
|
|
306
306
|
);
|
|
307
307
|
`,
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
308
|
+
errors: [{ messageId: 'unsupported-prop-syntax' }],
|
|
309
|
+
},
|
|
310
|
+
{
|
|
311
|
+
name: 'converts mix of renamed props argument and destructured props',
|
|
312
|
+
code: `
|
|
313
313
|
import styled from 'styled-components';
|
|
314
314
|
|
|
315
315
|
styled.div({
|
|
@@ -318,7 +318,7 @@ typescriptEslintTester.run(
|
|
|
318
318
|
height: (props) => props.customHeight,
|
|
319
319
|
});
|
|
320
320
|
`,
|
|
321
|
-
|
|
321
|
+
output: `
|
|
322
322
|
import styled from 'styled-components';
|
|
323
323
|
|
|
324
324
|
styled.div((props) => ({
|
|
@@ -327,11 +327,11 @@ typescriptEslintTester.run(
|
|
|
327
327
|
height: props.customHeight,
|
|
328
328
|
}));
|
|
329
329
|
`,
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
330
|
+
errors: [{ messageId: 'unsupported-prop-syntax' }],
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
name: 'converts props with same name',
|
|
334
|
+
code: `
|
|
335
335
|
import styled from 'styled-components';
|
|
336
336
|
|
|
337
337
|
styled.div({
|
|
@@ -340,7 +340,7 @@ typescriptEslintTester.run(
|
|
|
340
340
|
height: (props) => props.customHeight,
|
|
341
341
|
});
|
|
342
342
|
`,
|
|
343
|
-
|
|
343
|
+
output: `
|
|
344
344
|
import styled from 'styled-components';
|
|
345
345
|
|
|
346
346
|
styled.div((props) => ({
|
|
@@ -349,11 +349,11 @@ typescriptEslintTester.run(
|
|
|
349
349
|
height: props.customHeight,
|
|
350
350
|
}));
|
|
351
351
|
`,
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
352
|
+
errors: [{ messageId: 'unsupported-prop-syntax' }],
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
name: 'converts props with same name (variant two)',
|
|
356
|
+
code: `
|
|
357
357
|
import styled from 'styled-components';
|
|
358
358
|
|
|
359
359
|
styled.div({
|
|
@@ -362,7 +362,7 @@ typescriptEslintTester.run(
|
|
|
362
362
|
height: (props) => props.customHeight,
|
|
363
363
|
});
|
|
364
364
|
`,
|
|
365
|
-
|
|
365
|
+
output: `
|
|
366
366
|
import styled from 'styled-components';
|
|
367
367
|
|
|
368
368
|
styled.div((props) => ({
|
|
@@ -371,11 +371,11 @@ typescriptEslintTester.run(
|
|
|
371
371
|
height: props.customHeight,
|
|
372
372
|
}));
|
|
373
373
|
`,
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
374
|
+
errors: [{ messageId: 'unsupported-prop-syntax' }],
|
|
375
|
+
},
|
|
376
|
+
{
|
|
377
|
+
name: 'converts props with same name (variant three)',
|
|
378
|
+
code: `
|
|
379
379
|
import styled from 'styled-components';
|
|
380
380
|
|
|
381
381
|
styled.div({
|
|
@@ -384,7 +384,7 @@ typescriptEslintTester.run(
|
|
|
384
384
|
height: (props) => props.customHeight,
|
|
385
385
|
});
|
|
386
386
|
`,
|
|
387
|
-
|
|
387
|
+
output: `
|
|
388
388
|
import styled from 'styled-components';
|
|
389
389
|
|
|
390
390
|
styled.div((props) => ({
|
|
@@ -393,11 +393,11 @@ typescriptEslintTester.run(
|
|
|
393
393
|
height: props.customHeight,
|
|
394
394
|
}));
|
|
395
395
|
`,
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
396
|
+
errors: [{ messageId: 'unsupported-prop-syntax' }],
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
name: 'converts props inside template literal',
|
|
400
|
+
code: `
|
|
401
401
|
import styled from 'styled-components';
|
|
402
402
|
|
|
403
403
|
styled.div({
|
|
@@ -405,7 +405,7 @@ typescriptEslintTester.run(
|
|
|
405
405
|
backgroundSize: 'cover',
|
|
406
406
|
});
|
|
407
407
|
`,
|
|
408
|
-
|
|
408
|
+
output: `
|
|
409
409
|
import styled from 'styled-components';
|
|
410
410
|
|
|
411
411
|
styled.div((props) => ({
|
|
@@ -413,11 +413,11 @@ typescriptEslintTester.run(
|
|
|
413
413
|
backgroundSize: 'cover',
|
|
414
414
|
}));
|
|
415
415
|
`,
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
416
|
+
errors: [{ messageId: 'unsupported-prop-syntax' }],
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
name: 'converts props with complicated expressions',
|
|
420
|
+
code: `
|
|
421
421
|
import styled from 'styled-components';
|
|
422
422
|
|
|
423
423
|
styled.div({
|
|
@@ -426,7 +426,7 @@ typescriptEslintTester.run(
|
|
|
426
426
|
padding: ({ width }) => \`\${width}px \${width + 3}px \${width + 2}px\`,
|
|
427
427
|
});
|
|
428
428
|
`,
|
|
429
|
-
|
|
429
|
+
output: `
|
|
430
430
|
import styled from 'styled-components';
|
|
431
431
|
|
|
432
432
|
styled.div((props) => ({
|
|
@@ -435,11 +435,11 @@ typescriptEslintTester.run(
|
|
|
435
435
|
padding: \`\${props.width}px \${props.width + 3}px \${props.width + 2}px\`,
|
|
436
436
|
}));
|
|
437
437
|
`,
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
438
|
+
errors: [{ messageId: 'unsupported-prop-syntax' }],
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
name: 'converts props with overlapping names',
|
|
442
|
+
code: `
|
|
443
443
|
import styled from 'styled-components';
|
|
444
444
|
|
|
445
445
|
styled.div({
|
|
@@ -447,7 +447,7 @@ typescriptEslintTester.run(
|
|
|
447
447
|
width: ({ height, oldHeight }) => height + oldHeight,
|
|
448
448
|
});
|
|
449
449
|
`,
|
|
450
|
-
|
|
450
|
+
output: `
|
|
451
451
|
import styled from 'styled-components';
|
|
452
452
|
|
|
453
453
|
styled.div((props) => ({
|
|
@@ -455,11 +455,11 @@ typescriptEslintTester.run(
|
|
|
455
455
|
width: props.height + props.oldHeight,
|
|
456
456
|
}));
|
|
457
457
|
`,
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
458
|
+
errors: [{ messageId: 'unsupported-prop-syntax' }],
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
name: 'converts props mixed with token function',
|
|
462
|
+
code: `
|
|
463
463
|
import styled from 'styled-components';
|
|
464
464
|
import { someFallback } from 'some-package';
|
|
465
465
|
|
|
@@ -467,7 +467,7 @@ typescriptEslintTester.run(
|
|
|
467
467
|
padding: ({ myPadding }) => \`\${token('some-token', someFallback)} \${myPadding}\`,
|
|
468
468
|
});
|
|
469
469
|
`,
|
|
470
|
-
|
|
470
|
+
output: `
|
|
471
471
|
import styled from 'styled-components';
|
|
472
472
|
import { someFallback } from 'some-package';
|
|
473
473
|
|
|
@@ -475,11 +475,11 @@ typescriptEslintTester.run(
|
|
|
475
475
|
padding: \`\${token('some-token', someFallback)} \${props.myPadding}\`,
|
|
476
476
|
}));
|
|
477
477
|
`,
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
478
|
+
errors: [{ messageId: 'unsupported-prop-syntax' }],
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
name: 'converts mix of styled variable arguments and object arguments',
|
|
482
|
+
code: `
|
|
483
483
|
import styled from 'styled-components';
|
|
484
484
|
import { someFallback } from 'some-package';
|
|
485
485
|
|
|
@@ -497,7 +497,7 @@ typescriptEslintTester.run(
|
|
|
497
497
|
}
|
|
498
498
|
);
|
|
499
499
|
`,
|
|
500
|
-
|
|
500
|
+
output: `
|
|
501
501
|
import styled from 'styled-components';
|
|
502
502
|
import { someFallback } from 'some-package';
|
|
503
503
|
|
|
@@ -515,11 +515,11 @@ typescriptEslintTester.run(
|
|
|
515
515
|
})
|
|
516
516
|
);
|
|
517
517
|
`,
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
518
|
+
errors: [{ messageId: 'unsupported-prop-syntax' }],
|
|
519
|
+
},
|
|
520
|
+
{
|
|
521
|
+
name: 'converts mix of props and non-props',
|
|
522
|
+
code: `
|
|
523
523
|
import styled from 'styled-components';
|
|
524
524
|
|
|
525
525
|
styled.div({
|
|
@@ -528,7 +528,7 @@ typescriptEslintTester.run(
|
|
|
528
528
|
margin: \`2px \${token('some-token')}\`
|
|
529
529
|
});
|
|
530
530
|
`,
|
|
531
|
-
|
|
531
|
+
output: `
|
|
532
532
|
import styled from 'styled-components';
|
|
533
533
|
|
|
534
534
|
styled.div((props) => ({
|
|
@@ -537,11 +537,11 @@ typescriptEslintTester.run(
|
|
|
537
537
|
margin: \`2px \${token('some-token')}\`
|
|
538
538
|
}));
|
|
539
539
|
`,
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
540
|
+
errors: [{ messageId: 'unsupported-prop-syntax' }],
|
|
541
|
+
},
|
|
542
|
+
{
|
|
543
|
+
name: 'converts styled-components props argument when extending existing component',
|
|
544
|
+
code: `
|
|
545
545
|
import styled from 'styled-components';
|
|
546
546
|
|
|
547
547
|
styled(BaseComponent)({
|
|
@@ -549,7 +549,7 @@ typescriptEslintTester.run(
|
|
|
549
549
|
backgroundColor: (props) => props.backgroundColor,
|
|
550
550
|
});
|
|
551
551
|
`,
|
|
552
|
-
|
|
552
|
+
output: `
|
|
553
553
|
import styled from 'styled-components';
|
|
554
554
|
|
|
555
555
|
styled(BaseComponent)((props) => ({
|
|
@@ -557,11 +557,11 @@ typescriptEslintTester.run(
|
|
|
557
557
|
backgroundColor: props.backgroundColor,
|
|
558
558
|
}));
|
|
559
559
|
`,
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
560
|
+
errors: [{ messageId: 'unsupported-prop-syntax' }],
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
name: 'converts styled-components props argument when using css function',
|
|
564
|
+
code: `
|
|
565
565
|
import { css } from 'styled-components';
|
|
566
566
|
|
|
567
567
|
css({
|
|
@@ -569,7 +569,7 @@ typescriptEslintTester.run(
|
|
|
569
569
|
backgroundColor: (props) => props.backgroundColor,
|
|
570
570
|
});
|
|
571
571
|
`,
|
|
572
|
-
|
|
572
|
+
output: `
|
|
573
573
|
import { css } from 'styled-components';
|
|
574
574
|
|
|
575
575
|
css((props) => ({
|
|
@@ -577,8 +577,8 @@ typescriptEslintTester.run(
|
|
|
577
577
|
backgroundColor: props.backgroundColor,
|
|
578
578
|
}));
|
|
579
579
|
`,
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
580
|
+
errors: [{ messageId: 'unsupported-prop-syntax' }],
|
|
581
|
+
},
|
|
582
|
+
],
|
|
583
|
+
},
|
|
584
584
|
);
|