Skip to content

Commit a404b2c

Browse files
authored
test(linter): eslint/no-duplicate-imports shouldn't report the same span (#11324)
Adds a test for a bug that was unintentionally fixed by #11320. I also confirmed that the test would have failed before my original PR. Context: #11320 (comment)
1 parent e2f0f0a commit a404b2c

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

crates/oxc_linter/src/rules/eslint/no_duplicate_imports.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,13 @@ fn test() {
487487
export * from "os";"#,
488488
Some(serde_json::json!([{ "includeExports": true }])),
489489
),
490+
(
491+
// Verifies that the error for the second line appears only once in the test snapshot.
492+
// https://github.com/oxc-project/oxc/pull/11320#issuecomment-2912286528
493+
r#"import type { PriorityDialogCustomClassNames, WeightDialogCustomClassNames } from "./HostEditDialogs";
494+
import { PriorityDialog, WeightDialog } from "./HostEditDialogs";"#,
495+
None,
496+
),
490497
];
491498

492499
Tester::new(NoDuplicateImports::NAME, NoDuplicateImports::PLUGIN, pass, fail)

crates/oxc_linter/src/snapshots/eslint_no_duplicate_imports.snap

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,14 @@ source: crates/oxc_linter/src/tester.rs
158158
· ╰── This export is duplicated
159159
╰────
160160
help: Merge the duplicated exports into a single export statement
161+
162+
eslint(no-duplicate-imports): './HostEditDialogs' import is duplicated
163+
╭─[no_duplicate_imports.tsx:1:83]
164+
1import type { PriorityDialogCustomClassNames, WeightDialogCustomClassNames } from "./HostEditDialogs";
165+
· ─────────┬─────────
166+
· ╰── Can be merged with this import
167+
2import { PriorityDialog, WeightDialog } from "./HostEditDialogs";
168+
· ─────────┬─────────
169+
· ╰── This import is duplicated
170+
╰────
171+
help: Merge the duplicated import into a single import statement

0 commit comments

Comments
 (0)