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-named-as-default`: allow named specifier if equivalent to default #3032

Closed akwodkiewicz closed 2 months ago

akwodkiewicz commented 3 months ago

New behaviour / fix for rule no-named-as-default: the rule will not show an error if the thing that was imported with someName is exported from the source both as default and someName

There's a big caveat related to how the thing is defined in the imported module. If it's a re-export, then this fix will work. If it's defined in the imported module -- it won't work.

This PR fixes all the issues with

import userEvent from '@testing-library/user-event';

because, luckily to us, userEvent is re-exported there and not defined in the imported file.

Fixes #1594

codecov[bot] commented 2 months ago

Codecov Report

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

Project coverage is 90.47%. Comparing base (95849c8) to head (7e2e78f).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #3032 +/- ## ========================================== - Coverage 95.46% 90.47% -4.99% ========================================== Files 82 82 Lines 3549 3560 +11 Branches 1244 1249 +5 ========================================== - Hits 3388 3221 -167 - Misses 161 339 +178 ```

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