Skip to content

Commit 22aba38

Browse files
committed
no-barrel-files: Cover exports before imports
Fixes #3520
1 parent f126fa3 commit 22aba38

3 files changed

Lines changed: 28 additions & 11 deletions

File tree

test/no-barrel-files.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ test.snapshot({
3535
'import foo from "foo"; export default foo;',
3636
'export default foo; import foo from "foo";',
3737
'import * as namespace from "foo"; export {namespace as default};',
38+
'export {foo}; import {foo} from "foo";',
3839
outdent`
3940
import {foo} from './foo.js';
4041
export {foo};

test/snapshots/no-barrel-files.js.md

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,23 @@ Generated by [AVA](https://avajs.dev).
180180
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Barrel files are not allowed.␊
181181
`
182182

183-
## invalid(12): import {foo} from './foo.js'; export {foo}; export {bar} from './bar.js';
183+
## invalid(12): export {foo}; import {foo} from "foo";
184+
185+
> Input
186+
187+
`␊
188+
1 | export {foo}; import {foo} from "foo";␊
189+
`
190+
191+
> Error 1/1
192+
193+
`␊
194+
Message:␊
195+
> 1 | export {foo}; import {foo} from "foo";␊
196+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Barrel files are not allowed.␊
197+
`
198+
199+
## invalid(13): import {foo} from './foo.js'; export {foo}; export {bar} from './bar.js';
184200

185201
> Input
186202
@@ -202,7 +218,7 @@ Generated by [AVA](https://avajs.dev).
202218
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Barrel files are not allowed.␊
203219
`
204220

205-
## invalid(13): // This is still a barrel file. export {}; export {foo} from './foo.js'; export {bar} from './bar.js';
221+
## invalid(14): // This is still a barrel file. export {}; export {foo} from './foo.js'; export {bar} from './bar.js';
206222

207223
> Input
208224
@@ -227,7 +243,7 @@ Generated by [AVA](https://avajs.dev).
227243
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Barrel files are not allowed.␊
228244
`
229245

230-
## invalid(14): export type {Foo} from "foo";
246+
## invalid(15): export type {Foo} from "foo";
231247

232248
> Input
233249
@@ -243,7 +259,7 @@ Generated by [AVA](https://avajs.dev).
243259
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Barrel files are not allowed.␊
244260
`
245261

246-
## invalid(15): export type * from "foo";
262+
## invalid(16): export type * from "foo";
247263

248264
> Input
249265
@@ -259,7 +275,7 @@ Generated by [AVA](https://avajs.dev).
259275
| ^^^^^^^^^^^^^^^^^^^^^^^^^ Barrel files are not allowed.␊
260276
`
261277

262-
## invalid(16): export type * as Namespace from "foo";
278+
## invalid(17): export type * as Namespace from "foo";
263279

264280
> Input
265281
@@ -275,7 +291,7 @@ Generated by [AVA](https://avajs.dev).
275291
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Barrel files are not allowed.␊
276292
`
277293

278-
## invalid(17): import foo from "foo"; export default foo as Foo;
294+
## invalid(18): import foo from "foo"; export default foo as Foo;
279295

280296
> Input
281297
@@ -291,7 +307,7 @@ Generated by [AVA](https://avajs.dev).
291307
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Barrel files are not allowed.␊
292308
`
293309

294-
## invalid(18): import foo from "foo"; export default foo satisfies Foo;
310+
## invalid(19): import foo from "foo"; export default foo satisfies Foo;
295311

296312
> Input
297313
@@ -307,7 +323,7 @@ Generated by [AVA](https://avajs.dev).
307323
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Barrel files are not allowed.␊
308324
`
309325

310-
## invalid(19): import foo from "foo"; export default foo!;
326+
## invalid(20): import foo from "foo"; export default foo!;
311327

312328
> Input
313329
@@ -323,7 +339,7 @@ Generated by [AVA](https://avajs.dev).
323339
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Barrel files are not allowed.␊
324340
`
325341

326-
## invalid(20): import foo from "foo"; export default foo<string>;
342+
## invalid(21): import foo from "foo"; export default foo<string>;
327343

328344
> Input
329345
@@ -339,7 +355,7 @@ Generated by [AVA](https://avajs.dev).
339355
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Barrel files are not allowed.␊
340356
`
341357

342-
## invalid(21): import foo from "foo"; export default <Foo>foo;
358+
## invalid(22): import foo from "foo"; export default <Foo>foo;
343359

344360
> Input
345361
@@ -355,7 +371,7 @@ Generated by [AVA](https://avajs.dev).
355371
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Barrel files are not allowed.␊
356372
`
357373

358-
## invalid(22): import type {Foo} from './foo.js'; export type {Foo};
374+
## invalid(23): import type {Foo} from './foo.js'; export type {Foo};
359375

360376
> Input
361377
22 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)