File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed
Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -272,7 +272,11 @@ impl Rule for NoDuplicateImports {
272272 continue ;
273273 }
274274
275- if existing. iter ( ) . any ( |( t, _, module_type) | {
275+ if existing. iter ( ) . any ( |( t, import_span, module_type) | {
276+ // import { a } from 'foo'; export { a as t };
277+ if matches ! ( t, ImportType :: Named ) && module_request. span != * import_span {
278+ return true ;
279+ }
276280 ( matches ! (
277281 t,
278282 ImportType :: Named | ImportType :: SideEffect | ImportType :: Default
@@ -429,9 +433,23 @@ fn test() {
429433 export * from "os";"# ,
430434 Some ( serde_json:: json!( [ { "includeExports" : true } ] ) ) ,
431435 ) ,
436+ (
437+ "
438+ import { a } from 'f';
439+ export { b as r };
440+ " ,
441+ Some ( serde_json:: json!( [ { "includeExports" : true } ] ) ) ,
442+ ) ,
432443 ] ;
433444
434445 let fail = vec ! [
446+ (
447+ "
448+ export { a } from 'foo';
449+ import { f } from 'foo';
450+ " ,
451+ Some ( serde_json:: json!( [ { "includeExports" : true } ] ) ) ,
452+ ) ,
435453 (
436454 r#"import "fs";
437455 import "fs""# ,
Original file line number Diff line number Diff line change 11-- -
22source : crates / oxc_linter / src / tester .rs
33-- -
4+ ⚠ eslint (no - duplicate - imports ): ' foo' export is duplicated
5+ ╭─[no_duplicate_imports .tsx :2 :26 ]
6+ 1 │
7+ 2 │ export { a } from ' foo' ;
8+ · ┬
9+ · ╰── This export is duplicated
10+ 3 │ import { f } from ' foo' ;
11+ · ──┬──
12+ · ╰── Can be merged with this
13+ 4 │
14+ ╰────
15+ help : Merge the duplicated exports into a single export statement
16+
417 ⚠ eslint (no - duplicate - imports ): ' fs' import is duplicated
518 ╭─[no_duplicate_imports .tsx :1 :8 ]
619 1 │ import " fs" ;
You can’t perform that action at this time.
0 commit comments