@atlaskit/menu 2.14.2 → 2.14.3
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/package.json +9 -6
- package/codemods/0.7.0-change-css-fn-prop.tsx +0 -149
- package/codemods/2.1.0-invalid-link-item-to-button-item.tsx +0 -146
- package/codemods/__tests__/0.7.0-change-css-fn-prop.tsx +0 -360
- package/codemods/__tests__/next-invalid-link-item-to-button-item.tsx +0 -308
- package/codemods/helpers/generic.tsx +0 -637
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
jest.autoMockOff();
|
|
2
|
-
|
|
3
|
-
import * as transformer from '../2.1.0-invalid-link-item-to-button-item';
|
|
4
|
-
|
|
5
|
-
const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
|
|
6
|
-
|
|
7
|
-
describe('Converts link items with invalid or missing `href` to button items', () => {
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* Success cases
|
|
11
|
-
*
|
|
12
|
-
*/
|
|
13
|
-
defineInlineTest(
|
|
14
|
-
{ ...transformer, parser: 'tsx' },
|
|
15
|
-
{},
|
|
16
|
-
`
|
|
17
|
-
import { LinkItem } from '@atlaskit/something';
|
|
18
|
-
|
|
19
|
-
const App = () => {
|
|
20
|
-
return <LinkItem />;
|
|
21
|
-
}
|
|
22
|
-
`,
|
|
23
|
-
`
|
|
24
|
-
import { LinkItem } from '@atlaskit/something';
|
|
25
|
-
|
|
26
|
-
const App = () => {
|
|
27
|
-
return <LinkItem />;
|
|
28
|
-
}
|
|
29
|
-
`,
|
|
30
|
-
'leaves unrelated code untouched',
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
defineInlineTest(
|
|
34
|
-
{ ...transformer, parser: 'tsx' },
|
|
35
|
-
{},
|
|
36
|
-
`
|
|
37
|
-
import { LinkItem } from '@atlaskit/menu';
|
|
38
|
-
import { variable } from 'somewhere';
|
|
39
|
-
|
|
40
|
-
const App = () => {
|
|
41
|
-
return <LinkItem href={variable}>test</LinkItem>;
|
|
42
|
-
}
|
|
43
|
-
`,
|
|
44
|
-
`
|
|
45
|
-
import { LinkItem } from '@atlaskit/menu';
|
|
46
|
-
import { variable } from 'somewhere';
|
|
47
|
-
|
|
48
|
-
const App = () => {
|
|
49
|
-
return <LinkItem href={variable}>test</LinkItem>;
|
|
50
|
-
}
|
|
51
|
-
`,
|
|
52
|
-
'should not do anything with `href`s that are variables',
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
defineInlineTest(
|
|
56
|
-
{ ...transformer, parser: 'tsx' },
|
|
57
|
-
{},
|
|
58
|
-
`
|
|
59
|
-
import { LinkItem } from '@atlaskit/menu';
|
|
60
|
-
|
|
61
|
-
const App = () => {
|
|
62
|
-
return <LinkItem href="http://valid.com">test</LinkItem>;
|
|
63
|
-
}
|
|
64
|
-
`,
|
|
65
|
-
`
|
|
66
|
-
import { LinkItem } from '@atlaskit/menu';
|
|
67
|
-
|
|
68
|
-
const App = () => {
|
|
69
|
-
return <LinkItem href="http://valid.com">test</LinkItem>;
|
|
70
|
-
}
|
|
71
|
-
`,
|
|
72
|
-
'should not do anything with a valid `href`',
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
*
|
|
77
|
-
* Missing `href`
|
|
78
|
-
*
|
|
79
|
-
*/
|
|
80
|
-
|
|
81
|
-
defineInlineTest(
|
|
82
|
-
{ ...transformer, parser: 'tsx' },
|
|
83
|
-
{},
|
|
84
|
-
`
|
|
85
|
-
import { LinkItem } from '@atlaskit/menu';
|
|
86
|
-
|
|
87
|
-
const App = () => {
|
|
88
|
-
return <LinkItem>test</LinkItem>;
|
|
89
|
-
}
|
|
90
|
-
`,
|
|
91
|
-
`
|
|
92
|
-
import { LinkItem, ButtonItem } from '@atlaskit/menu';
|
|
93
|
-
|
|
94
|
-
const App = () => {
|
|
95
|
-
return <ButtonItem>test</ButtonItem>;
|
|
96
|
-
}
|
|
97
|
-
`,
|
|
98
|
-
'Should convert to ButtonItem if no href exists on LinkItem',
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
defineInlineTest(
|
|
102
|
-
{ ...transformer, parser: 'tsx' },
|
|
103
|
-
{},
|
|
104
|
-
`
|
|
105
|
-
import { LinkItem } from '@atlaskit/menu';
|
|
106
|
-
|
|
107
|
-
const App = () => {
|
|
108
|
-
return <LinkItem id="test">test</LinkItem>;
|
|
109
|
-
}
|
|
110
|
-
`,
|
|
111
|
-
`
|
|
112
|
-
import { LinkItem, ButtonItem } from '@atlaskit/menu';
|
|
113
|
-
|
|
114
|
-
const App = () => {
|
|
115
|
-
return <ButtonItem id="test">test</ButtonItem>;
|
|
116
|
-
}
|
|
117
|
-
`,
|
|
118
|
-
'Should convert to ButtonItem but keep existing props if no href exists on LinkItem',
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
*
|
|
123
|
-
* Invalid `href`
|
|
124
|
-
*
|
|
125
|
-
*/
|
|
126
|
-
|
|
127
|
-
defineInlineTest(
|
|
128
|
-
{ ...transformer, parser: 'tsx' },
|
|
129
|
-
{},
|
|
130
|
-
`
|
|
131
|
-
import { LinkItem } from '@atlaskit/menu';
|
|
132
|
-
|
|
133
|
-
const App = () => {
|
|
134
|
-
return <LinkItem href="#">test</LinkItem>;
|
|
135
|
-
}
|
|
136
|
-
`,
|
|
137
|
-
`
|
|
138
|
-
import { LinkItem, ButtonItem } from '@atlaskit/menu';
|
|
139
|
-
|
|
140
|
-
const App = () => {
|
|
141
|
-
return <ButtonItem>test</ButtonItem>;
|
|
142
|
-
}
|
|
143
|
-
`,
|
|
144
|
-
'Should convert to ButtonItem if invalid `href`',
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
defineInlineTest(
|
|
148
|
-
{ ...transformer, parser: 'tsx' },
|
|
149
|
-
{},
|
|
150
|
-
`
|
|
151
|
-
import { LinkItem } from '@atlaskit/menu';
|
|
152
|
-
|
|
153
|
-
const App = () => {
|
|
154
|
-
return <LinkItem href="#" id="test">test</LinkItem>;
|
|
155
|
-
}
|
|
156
|
-
`,
|
|
157
|
-
`
|
|
158
|
-
import { LinkItem, ButtonItem } from '@atlaskit/menu';
|
|
159
|
-
|
|
160
|
-
const App = () => {
|
|
161
|
-
return <ButtonItem id="test">test</ButtonItem>;
|
|
162
|
-
}
|
|
163
|
-
`,
|
|
164
|
-
'Should convert to ButtonItem but keep existing props if invalid `href`',
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
defineInlineTest(
|
|
168
|
-
{ ...transformer, parser: 'tsx' },
|
|
169
|
-
{},
|
|
170
|
-
`
|
|
171
|
-
import { LinkItem } from '@atlaskit/menu';
|
|
172
|
-
|
|
173
|
-
const App = () => {
|
|
174
|
-
return <LinkItem href="">test</LinkItem>;
|
|
175
|
-
}
|
|
176
|
-
`,
|
|
177
|
-
`
|
|
178
|
-
import { LinkItem, ButtonItem } from '@atlaskit/menu';
|
|
179
|
-
|
|
180
|
-
const App = () => {
|
|
181
|
-
return <ButtonItem>test</ButtonItem>;
|
|
182
|
-
}
|
|
183
|
-
`,
|
|
184
|
-
'Should convert to ButtonItem if invalid `href`',
|
|
185
|
-
);
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
*
|
|
189
|
-
* Expressions
|
|
190
|
-
*
|
|
191
|
-
*/
|
|
192
|
-
|
|
193
|
-
defineInlineTest(
|
|
194
|
-
{ ...transformer, parser: 'tsx' },
|
|
195
|
-
{},
|
|
196
|
-
`
|
|
197
|
-
import { LinkItem } from '@atlaskit/menu';
|
|
198
|
-
|
|
199
|
-
const App = () => {
|
|
200
|
-
return <LinkItem href={''}>test</LinkItem>;
|
|
201
|
-
}
|
|
202
|
-
`,
|
|
203
|
-
`
|
|
204
|
-
import { LinkItem, ButtonItem } from '@atlaskit/menu';
|
|
205
|
-
|
|
206
|
-
const App = () => {
|
|
207
|
-
return <ButtonItem>test</ButtonItem>;
|
|
208
|
-
}
|
|
209
|
-
`,
|
|
210
|
-
'should handle strings in expression containers',
|
|
211
|
-
);
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
*
|
|
215
|
-
* Edge cases
|
|
216
|
-
*
|
|
217
|
-
*/
|
|
218
|
-
|
|
219
|
-
defineInlineTest(
|
|
220
|
-
{ ...transformer, parser: 'tsx' },
|
|
221
|
-
{},
|
|
222
|
-
`
|
|
223
|
-
import { LinkItem, ButtonItem } from '@atlaskit/menu';
|
|
224
|
-
|
|
225
|
-
const App = () => {
|
|
226
|
-
return (
|
|
227
|
-
<div>
|
|
228
|
-
<LinkItem href="">test 1</LinkItem>
|
|
229
|
-
<ButtonItem>test 2</ButtonItem>
|
|
230
|
-
</div>
|
|
231
|
-
);
|
|
232
|
-
}
|
|
233
|
-
`,
|
|
234
|
-
`
|
|
235
|
-
import { LinkItem, ButtonItem } from '@atlaskit/menu';
|
|
236
|
-
|
|
237
|
-
const App = () => {
|
|
238
|
-
return (
|
|
239
|
-
<div>
|
|
240
|
-
<ButtonItem>test 1</ButtonItem>
|
|
241
|
-
<ButtonItem>test 2</ButtonItem>
|
|
242
|
-
</div>
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
`,
|
|
246
|
-
'Should handle multiple item types',
|
|
247
|
-
);
|
|
248
|
-
|
|
249
|
-
defineInlineTest(
|
|
250
|
-
{ ...transformer, parser: 'tsx' },
|
|
251
|
-
{},
|
|
252
|
-
`
|
|
253
|
-
import { LinkItem, CustomItem } from '@atlaskit/menu';
|
|
254
|
-
|
|
255
|
-
const App = () => {
|
|
256
|
-
return (
|
|
257
|
-
<div>
|
|
258
|
-
<LinkItem href="">test 1</LinkItem>
|
|
259
|
-
<CustomItem>test 2</CustomItem>
|
|
260
|
-
</div>
|
|
261
|
-
);
|
|
262
|
-
}
|
|
263
|
-
`,
|
|
264
|
-
`
|
|
265
|
-
import { LinkItem, CustomItem, ButtonItem } from '@atlaskit/menu';
|
|
266
|
-
|
|
267
|
-
const App = () => {
|
|
268
|
-
return (
|
|
269
|
-
<div>
|
|
270
|
-
<ButtonItem>test 1</ButtonItem>
|
|
271
|
-
<CustomItem>test 2</CustomItem>
|
|
272
|
-
</div>
|
|
273
|
-
);
|
|
274
|
-
}
|
|
275
|
-
`,
|
|
276
|
-
'Should not delete any imports',
|
|
277
|
-
);
|
|
278
|
-
|
|
279
|
-
defineInlineTest(
|
|
280
|
-
{ ...transformer, parser: 'tsx' },
|
|
281
|
-
{},
|
|
282
|
-
`
|
|
283
|
-
import { LinkItem } from '@atlaskit/menu';
|
|
284
|
-
|
|
285
|
-
const App = () => {
|
|
286
|
-
return (
|
|
287
|
-
<div>
|
|
288
|
-
<LinkItem href="">test 1</LinkItem>
|
|
289
|
-
<LinkItem href="http://example.com">test 2</LinkItem>
|
|
290
|
-
</div>
|
|
291
|
-
);
|
|
292
|
-
}
|
|
293
|
-
`,
|
|
294
|
-
`
|
|
295
|
-
import { LinkItem, ButtonItem } from '@atlaskit/menu';
|
|
296
|
-
|
|
297
|
-
const App = () => {
|
|
298
|
-
return (
|
|
299
|
-
<div>
|
|
300
|
-
<ButtonItem>test 1</ButtonItem>
|
|
301
|
-
<LinkItem href="http://example.com">test 2</LinkItem>
|
|
302
|
-
</div>
|
|
303
|
-
);
|
|
304
|
-
}
|
|
305
|
-
`,
|
|
306
|
-
'Should allow valid `href` and convert invalid ones',
|
|
307
|
-
);
|
|
308
|
-
});
|