eslint-plugin-primer-react 6.1.2 → 6.1.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
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# eslint-plugin-primer-react
|
|
2
2
|
|
|
3
|
+
## 6.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#242](https://github.com/primer/eslint-plugin-primer-react/pull/242) [`e139c02`](https://github.com/primer/eslint-plugin-primer-react/commit/e139c02ae0d0d656d2276320ae0e4756b3a1debd) Thanks [@joshblack](https://github.com/joshblack)! - Update no-wildcard-imports rule to work for imports that specify value and type imports
|
|
8
|
+
|
|
3
9
|
## 6.1.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -119,8 +119,37 @@ ruleTester.run('no-wildcard-imports', rule, {
|
|
|
119
119
|
],
|
|
120
120
|
},
|
|
121
121
|
|
|
122
|
+
// Test mixed imports
|
|
123
|
+
{
|
|
124
|
+
code: `import {Dialog, type DialogProps} from '@primer/react/lib-esm/Dialog/Dialog'`,
|
|
125
|
+
output: `import {Dialog} from '@primer/react/experimental'
|
|
126
|
+
import type {DialogProps} from '@primer/react/experimental'`,
|
|
127
|
+
errors: [
|
|
128
|
+
{
|
|
129
|
+
messageId: 'wildcardMigration',
|
|
130
|
+
data: {
|
|
131
|
+
wildcardEntrypoint: '@primer/react/lib-esm/Dialog/Dialog',
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
},
|
|
136
|
+
|
|
122
137
|
// Test migrations
|
|
123
138
|
|
|
139
|
+
// Test helpers ------------------------------------------------------------
|
|
140
|
+
{
|
|
141
|
+
code: `import '@primer/react/lib-esm/utils/test-helpers'`,
|
|
142
|
+
output: `import '@primer/react/test-helpers'`,
|
|
143
|
+
errors: [
|
|
144
|
+
{
|
|
145
|
+
messageId: 'wildcardMigration',
|
|
146
|
+
data: {
|
|
147
|
+
wildcardEntrypoint: '@primer/react/lib-esm/utils/test-helpers',
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
},
|
|
152
|
+
|
|
124
153
|
// Components --------------------------------------------------------------
|
|
125
154
|
{
|
|
126
155
|
code: `import {ButtonBase} from '@primer/react/lib-esm/Button/ButtonBase';
|
|
@@ -344,6 +373,18 @@ import type {ButtonBaseProps} from '@primer/react'`,
|
|
|
344
373
|
},
|
|
345
374
|
],
|
|
346
375
|
},
|
|
376
|
+
{
|
|
377
|
+
code: `import type {ResponsiveValue} from '@primer/react/lib-esm/hooks/useResponsiveValue'`,
|
|
378
|
+
output: `import type {ResponsiveValue} from '@primer/react'`,
|
|
379
|
+
errors: [
|
|
380
|
+
{
|
|
381
|
+
messageId: 'wildcardMigration',
|
|
382
|
+
data: {
|
|
383
|
+
wildcardEntrypoint: '@primer/react/lib-esm/hooks/useResponsiveValue',
|
|
384
|
+
},
|
|
385
|
+
},
|
|
386
|
+
],
|
|
387
|
+
},
|
|
347
388
|
|
|
348
389
|
// Utilities ---------------------------------------------------------------
|
|
349
390
|
|
|
@@ -40,6 +40,16 @@ const wildcardImports = new Map([
|
|
|
40
40
|
from: '@primer/react/experimental',
|
|
41
41
|
type: 'type',
|
|
42
42
|
},
|
|
43
|
+
{
|
|
44
|
+
name: 'DialogProps',
|
|
45
|
+
from: '@primer/react/experimental',
|
|
46
|
+
type: 'type',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: 'DialogButtonProps',
|
|
50
|
+
from: '@primer/react/experimental',
|
|
51
|
+
type: 'type',
|
|
52
|
+
},
|
|
43
53
|
],
|
|
44
54
|
],
|
|
45
55
|
[
|
|
@@ -171,6 +181,11 @@ const wildcardImports = new Map([
|
|
|
171
181
|
name: 'useResponsiveValue',
|
|
172
182
|
from: '@primer/react',
|
|
173
183
|
},
|
|
184
|
+
{
|
|
185
|
+
type: 'type',
|
|
186
|
+
name: 'ResponsiveValue',
|
|
187
|
+
from: '@primer/react',
|
|
188
|
+
},
|
|
174
189
|
],
|
|
175
190
|
],
|
|
176
191
|
|
|
@@ -204,6 +219,15 @@ const wildcardImports = new Map([
|
|
|
204
219
|
},
|
|
205
220
|
],
|
|
206
221
|
],
|
|
222
|
+
[
|
|
223
|
+
'@primer/react/lib-esm/FeatureFlags/useFeatureFlag',
|
|
224
|
+
[
|
|
225
|
+
{
|
|
226
|
+
name: 'useFeatureFlag',
|
|
227
|
+
from: '@primer/react/experimental',
|
|
228
|
+
},
|
|
229
|
+
],
|
|
230
|
+
],
|
|
207
231
|
[
|
|
208
232
|
'@primer/react/lib-esm/theme',
|
|
209
233
|
[
|
|
@@ -245,6 +269,20 @@ module.exports = {
|
|
|
245
269
|
return
|
|
246
270
|
}
|
|
247
271
|
|
|
272
|
+
if (node.source.value === '@primer/react/lib-esm/utils/test-helpers') {
|
|
273
|
+
context.report({
|
|
274
|
+
node,
|
|
275
|
+
messageId: 'wildcardMigration',
|
|
276
|
+
data: {
|
|
277
|
+
wildcardEntrypoint: node.source.value,
|
|
278
|
+
},
|
|
279
|
+
fix(fixer) {
|
|
280
|
+
return fixer.replaceText(node.source, `'@primer/react/test-helpers'`)
|
|
281
|
+
},
|
|
282
|
+
})
|
|
283
|
+
return
|
|
284
|
+
}
|
|
285
|
+
|
|
248
286
|
const wildcardImportMigrations = wildcardImports.get(node.source.value)
|
|
249
287
|
if (!wildcardImportMigrations) {
|
|
250
288
|
context.report({
|
|
@@ -353,7 +391,7 @@ module.exports = {
|
|
|
353
391
|
yield fixer.replaceText(node, `import {${specifiers.join(', ')}} from '${entrypoint}'`)
|
|
354
392
|
|
|
355
393
|
if (typeSpecifiers.length > 0) {
|
|
356
|
-
const specifiers =
|
|
394
|
+
const specifiers = typeSpecifiers.map(([imported, local]) => {
|
|
357
395
|
if (imported !== local) {
|
|
358
396
|
return `${imported} as ${local}`
|
|
359
397
|
}
|