@@ -22,7 +22,7 @@ ruleTester.run('no-wildcard-imports', rule, {
22
22
code : `import type {UnknownImport} from '@primer/react/lib-esm/unknown-path'` ,
23
23
errors : [
24
24
{
25
- message : 'Wildcard imports from @primer/react are not allowed. Import from an entrypoint instead ' ,
25
+ messageId : 'unknownWildcardImport ' ,
26
26
} ,
27
27
] ,
28
28
} ,
@@ -33,7 +33,10 @@ ruleTester.run('no-wildcard-imports', rule, {
33
33
output : `import type {SxProp} from '@primer/react'` ,
34
34
errors : [
35
35
{
36
- message : 'Wildcard imports from @primer/react/lib-esm/sx are not allowed. Import from an entrypoint instead' ,
36
+ messageId : 'wildcardMigration' ,
37
+ data : {
38
+ wildcardEntrypoint : '@primer/react/lib-esm/sx' ,
39
+ } ,
37
40
} ,
38
41
] ,
39
42
} ,
@@ -44,7 +47,10 @@ ruleTester.run('no-wildcard-imports', rule, {
44
47
output : `import type {BetterSystemStyleObject, SxProp, BetterCssProperties} from '@primer/react'` ,
45
48
errors : [
46
49
{
47
- message : 'Wildcard imports from @primer/react/lib-esm/sx are not allowed. Import from an entrypoint instead' ,
50
+ messageId : 'wildcardMigration' ,
51
+ data : {
52
+ wildcardEntrypoint : '@primer/react/lib-esm/sx' ,
53
+ } ,
48
54
} ,
49
55
] ,
50
56
} ,
@@ -55,7 +61,10 @@ ruleTester.run('no-wildcard-imports', rule, {
55
61
output : `import type {SxProp as RenamedSxProp} from '@primer/react'` ,
56
62
errors : [
57
63
{
58
- message : 'Wildcard imports from @primer/react/lib-esm/sx are not allowed. Import from an entrypoint instead' ,
64
+ messageId : 'wildcardMigration' ,
65
+ data : {
66
+ wildcardEntrypoint : '@primer/react/lib-esm/sx' ,
67
+ } ,
59
68
} ,
60
69
] ,
61
70
} ,
@@ -66,26 +75,287 @@ ruleTester.run('no-wildcard-imports', rule, {
66
75
output : `import {useIsomorphicLayoutEffect} from '@primer/react'` ,
67
76
errors : [
68
77
{
69
- message :
70
- 'Wildcard imports from @primer/react/lib-esm/useIsomorphicLayoutEffect are not allowed. Import from an entrypoint instead' ,
78
+ messageId : 'wildcardMigration' ,
79
+ data : {
80
+ wildcardEntrypoint : '@primer/react/lib-esm/useIsomorphicLayoutEffect' ,
81
+ } ,
71
82
} ,
72
83
] ,
73
84
} ,
74
85
75
86
// Test multiple wildcard imports into single entrypoint
76
87
{
77
88
code : `import useResizeObserver from '@primer/react/lib-esm/hooks/useResizeObserver'
78
- import useIsomorphicLayoutEffect from '@primer/react/lib-esm/useIsomorphicLayoutEffect'` ,
89
+ import useIsomorphicLayoutEffect from '@primer/react/lib-esm/useIsomorphicLayoutEffect'`,
79
90
output : `import {useResizeObserver} from '@primer/react'
80
- import {useIsomorphicLayoutEffect} from '@primer/react'` ,
91
+ import {useIsomorphicLayoutEffect} from '@primer/react'`,
81
92
errors : [
82
93
{
83
- message :
84
- 'Wildcard imports from @primer/react/lib-esm/hooks/useResizeObserver are not allowed. Import from an entrypoint instead' ,
94
+ messageId : 'wildcardMigration' ,
95
+ data : {
96
+ wildcardEntrypoint : '@primer/react/lib-esm/hooks/useResizeObserver' ,
97
+ } ,
85
98
} ,
86
99
{
87
- message :
88
- 'Wildcard imports from @primer/react/lib-esm/useIsomorphicLayoutEffect are not allowed. Import from an entrypoint instead' ,
100
+ messageId : 'wildcardMigration' ,
101
+ data : {
102
+ wildcardEntrypoint : '@primer/react/lib-esm/useIsomorphicLayoutEffect' ,
103
+ } ,
104
+ } ,
105
+ ] ,
106
+ } ,
107
+
108
+ // Test migrations
109
+
110
+ // Components --------------------------------------------------------------
111
+ {
112
+ code : `import {ButtonBase} from '@primer/react/lib-esm/Button/ButtonBase';
113
+ import type {ButtonBaseProps} from '@primer/react/lib-esm/Button/ButtonBase'` ,
114
+ output : `import {ButtonBase} from '@primer/react'
115
+ import type {ButtonBaseProps} from '@primer/react'` ,
116
+ errors : [
117
+ {
118
+ messageId : 'wildcardMigration' ,
119
+ data : {
120
+ wildcardEntrypoint : '@primer/react/lib-esm/Button/ButtonBase' ,
121
+ } ,
122
+ } ,
123
+ {
124
+ messageId : 'wildcardMigration' ,
125
+ data : {
126
+ wildcardEntrypoint : '@primer/react/lib-esm/Button/ButtonBase' ,
127
+ } ,
128
+ } ,
129
+ ] ,
130
+ } ,
131
+ {
132
+ code : `import type {ButtonBaseProps} from '@primer/react/lib-esm/Button/types'` ,
133
+ output : `import type {ButtonBaseProps} from '@primer/react'` ,
134
+ errors : [
135
+ {
136
+ messageId : 'wildcardMigration' ,
137
+ data : {
138
+ wildcardEntrypoint : '@primer/react/lib-esm/Button/types' ,
139
+ } ,
140
+ } ,
141
+ ] ,
142
+ } ,
143
+ {
144
+ code : `import {Dialog} from '@primer/react/lib-esm/Dialog/Dialog'` ,
145
+ output : `import {Dialog} from '@primer/react/experimental'` ,
146
+ errors : [
147
+ {
148
+ messageId : 'wildcardMigration' ,
149
+ data : {
150
+ wildcardEntrypoint : '@primer/react/lib-esm/Dialog/Dialog' ,
151
+ } ,
152
+ } ,
153
+ ] ,
154
+ } ,
155
+ {
156
+ code : `import {SelectPanel} from '@primer/react/lib-esm/SelectPanel/SelectPanel'` ,
157
+ output : `import {SelectPanel} from '@primer/react/experimental'` ,
158
+ errors : [
159
+ {
160
+ messageId : 'wildcardMigration' ,
161
+ data : {
162
+ wildcardEntrypoint : '@primer/react/lib-esm/SelectPanel/SelectPanel' ,
163
+ } ,
164
+ } ,
165
+ ] ,
166
+ } ,
167
+ {
168
+ code : `import type {SelectPanelProps} from '@primer/react/lib-esm/SelectPanel/SelectPanel'` ,
169
+ output : `import type {SelectPanelProps} from '@primer/react/experimental'` ,
170
+ errors : [
171
+ {
172
+ messageId : 'wildcardMigration' ,
173
+ data : {
174
+ wildcardEntrypoint : '@primer/react/lib-esm/SelectPanel/SelectPanel' ,
175
+ } ,
176
+ } ,
177
+ ] ,
178
+ } ,
179
+ {
180
+ code : `import type {LabelColorOptions} from '@primer/react/lib-esm/Label/Label'` ,
181
+ output : `import type {LabelColorOptions} from '@primer/react'` ,
182
+ errors : [
183
+ {
184
+ messageId : 'wildcardMigration' ,
185
+ data : {
186
+ wildcardEntrypoint : '@primer/react/lib-esm/Label/Label' ,
187
+ } ,
188
+ } ,
189
+ ] ,
190
+ } ,
191
+ {
192
+ code : `import VisuallyHidden from '@primer/react/lib-esm/_VisuallyHidden'` ,
193
+ output : `import {VisuallyHidden} from '@primer/react'` ,
194
+ errors : [
195
+ {
196
+ messageId : 'wildcardMigration' ,
197
+ data : {
198
+ wildcardEntrypoint : '@primer/react/lib-esm/_VisuallyHidden' ,
199
+ } ,
200
+ } ,
201
+ ] ,
202
+ } ,
203
+ {
204
+ code : `import type {IssueLabelTokenProps} from '@primer/react/lib-esm/Token/IssueLabelToken'` ,
205
+ output : `import type {IssueLabelTokenProps} from '@primer/react'` ,
206
+ errors : [
207
+ {
208
+ messageId : 'wildcardMigration' ,
209
+ data : {
210
+ wildcardEntrypoint : '@primer/react/lib-esm/Token/IssueLabelToken' ,
211
+ } ,
212
+ } ,
213
+ ] ,
214
+ } ,
215
+ {
216
+ code : `import type {TokenSizeKeys} from '@primer/react/lib-esm/Token/TokenBase'` ,
217
+ output : `import type {TokenSizeKeys} from '@primer/react'` ,
218
+ errors : [
219
+ {
220
+ messageId : 'wildcardMigration' ,
221
+ data : {
222
+ wildcardEntrypoint : '@primer/react/lib-esm/Token/TokenBase' ,
223
+ } ,
224
+ } ,
225
+ ] ,
226
+ } ,
227
+ {
228
+ code : `import type {ItemProps} from '@primer/react/lib-esm/deprecated/ActionList'` ,
229
+ output : `import type {ActionListItemProps} from '@primer/react/deprecated'` ,
230
+ errors : [
231
+ {
232
+ messageId : 'wildcardMigration' ,
233
+ data : {
234
+ wildcardEntrypoint : '@primer/react/lib-esm/deprecated/ActionList' ,
235
+ } ,
236
+ } ,
237
+ ] ,
238
+ } ,
239
+ {
240
+ code : `import type {GroupedListProps} from '@primer/react/lib-esm/deprecated/ActionList/List'` ,
241
+ output : `import type {ActionListGroupedListProps} from '@primer/react/deprecated'` ,
242
+ errors : [
243
+ {
244
+ messageId : 'wildcardMigration' ,
245
+ data : {
246
+ wildcardEntrypoint : '@primer/react/lib-esm/deprecated/ActionList/List' ,
247
+ } ,
248
+ } ,
249
+ ] ,
250
+ } ,
251
+ {
252
+ code : `import {ItemInput} from '@primer/react/lib-esm/deprecated/ActionList/List'` ,
253
+ output : `import {ActionListItemInput} from '@primer/react/deprecated'` ,
254
+ errors : [
255
+ {
256
+ messageId : 'wildcardMigration' ,
257
+ data : {
258
+ wildcardEntrypoint : '@primer/react/lib-esm/deprecated/ActionList/List' ,
259
+ } ,
260
+ } ,
261
+ ] ,
262
+ } ,
263
+ {
264
+ code : `import type {ItemProps} from '@primer/react/lib-esm/deprecated/ActionList/Item'` ,
265
+ output : `import type {ActionListItemProps} from '@primer/react/deprecated'` ,
266
+ errors : [
267
+ {
268
+ messageId : 'wildcardMigration' ,
269
+ data : {
270
+ wildcardEntrypoint : '@primer/react/lib-esm/deprecated/ActionList/Item' ,
271
+ } ,
272
+ } ,
273
+ ] ,
274
+ } ,
275
+
276
+ // Hooks -------------------------------------------------------------------
277
+
278
+ // @primer /react/lib-esm/useIsomorphicLayoutEffect
279
+ {
280
+ code : `import useIsomorphicLayoutEffect from '@primer/react/lib-esm/useIsomorphicLayoutEffect'` ,
281
+ output : `import {useIsomorphicLayoutEffect} from '@primer/react'` ,
282
+ errors : [
283
+ {
284
+ messageId : 'wildcardMigration' ,
285
+ data : {
286
+ wildcardEntrypoint : '@primer/react/lib-esm/useIsomorphicLayoutEffect' ,
287
+ } ,
288
+ } ,
289
+ ] ,
290
+ } ,
291
+
292
+ // @primer /react/lib-esm/hooks/useResizeObserver
293
+ {
294
+ code : `import useResizeObserver from '@primer/react/lib-esm/hooks/useResizeObserver'` ,
295
+ output : `import {useResizeObserver} from '@primer/react'` ,
296
+ errors : [
297
+ {
298
+ messageId : 'wildcardMigration' ,
299
+ data : {
300
+ wildcardEntrypoint : '@primer/react/lib-esm/hooks/useResizeObserver' ,
301
+ } ,
302
+ } ,
303
+ ] ,
304
+ } ,
305
+
306
+ // @primer /react/lib-esm/hooks/useProvidedRefOrCreate
307
+ {
308
+ code : `import useProvidedRefOrCreate from '@primer/react/lib-esm/hooks/useProvidedRefOrCreate'` ,
309
+ output : `import {useProvidedRefOrCreate} from '@primer/react'` ,
310
+ errors : [
311
+ {
312
+ messageId : 'wildcardMigration' ,
313
+ data : {
314
+ wildcardEntrypoint : '@primer/react/lib-esm/hooks/useProvidedRefOrCreate' ,
315
+ } ,
316
+ } ,
317
+ ] ,
318
+ } ,
319
+
320
+ // @primer /react/lib-esm/hooks/useResponsiveValue
321
+ {
322
+ code : `import useResponsiveValue from '@primer/react/lib-esm/hooks/useResponsiveValue'` ,
323
+ output : `import {useResponsiveValue} from '@primer/react'` ,
324
+ errors : [
325
+ {
326
+ messageId : 'wildcardMigration' ,
327
+ data : {
328
+ wildcardEntrypoint : '@primer/react/lib-esm/hooks/useResponsiveValue' ,
329
+ } ,
330
+ } ,
331
+ ] ,
332
+ } ,
333
+
334
+ // Utilities ---------------------------------------------------------------
335
+
336
+ // @primer /react/lib-esm/sx
337
+ {
338
+ code : `import type {BetterSystemStyleObject, SxProp, BetterCssProperties} from '@primer/react/lib-esm/sx'` ,
339
+ output : `import type {BetterSystemStyleObject, SxProp, BetterCssProperties} from '@primer/react'` ,
340
+ errors : [
341
+ {
342
+ messageId : 'wildcardMigration' ,
343
+ data : {
344
+ wildcardEntrypoint : '@primer/react/lib-esm/sx' ,
345
+ } ,
346
+ } ,
347
+ ] ,
348
+ } ,
349
+ // @primer /react/lib-esm/FeatureFlags/DefaultFeatureFlags
350
+ {
351
+ code : `import {DefaultFeatureFlags} from '@primer/react/lib-esm/FeatureFlags/DefaultFeatureFlags'` ,
352
+ output : `import {DefaultFeatureFlags} from '@primer/react/experimental'` ,
353
+ errors : [
354
+ {
355
+ messageId : 'wildcardMigration' ,
356
+ data : {
357
+ wildcardEntrypoint : '@primer/react/lib-esm/FeatureFlags/DefaultFeatureFlags' ,
358
+ } ,
89
359
} ,
90
360
] ,
91
361
} ,
0 commit comments