import-js / eslint-plugin-import

ESLint plugin with rules that help validate proper imports.
MIT License
5.57k stars 1.57k forks source link

[Fix] `no-duplicates`: Removing duplicates breaks in TypeScript #3033

Closed yesl-kim closed 2 months ago

yesl-kim commented 3 months ago

This PR addresses the issue where multiple import type statements from the same module are not properly combined when the prefer-inline option is enabled. Specifically, the problem arises when importing types with separate import type statements, which should be consolidated into a single import statement with inline type specifiers.

Fixes #3016, fixes #2792.

Given the following code:

import type { x } from 'foo';
import { type y } from 'foo';

as-is:

import type { x, type y } from 'foo';

to-be:

import { type x, type y } from 'foo';
codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 95.91%. Comparing base (09476d7) to head (eb8882d).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #3033 +/- ## ========================================== - Coverage 96.02% 95.91% -0.12% ========================================== Files 78 78 Lines 3299 3305 +6 Branches 1160 1162 +2 ========================================== + Hits 3168 3170 +2 - Misses 131 135 +4 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.