Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(eslint-plugin): [consistent-type-imports] handle imports without specifiers #8308

Merged

Conversation

courageousillumination
Copy link
Contributor

PR Checklist

Overview

Currently side effect imports will be marked as a valueOnlyNamedImport, which causes an error when trying insert the correct value import because it is expecting a }.

With these changes, we require that there is at least one specifier. If there is only a side effect import, a new import will be added with the specific value import.

One note is that this will also impact a named import with no specifiers import {} from 'foo'; Previously this would have inserted the value import into the empty {}; now it would insert it in a new import on a new line. I didn't see any way to distinguish between these two cases without looking for the braces explicitly; if that is not acceptable (since it changes how a fix is applied), please let me know and I can do the parsing.

This is my first PR against this repository, so please let me know if I missed anything 💖

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @courageousillumination!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint.

Copy link

netlify bot commented Jan 28, 2024

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 5a892c9
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/65f4f1893ab51c0008e33e12
😎 Deploy Preview https://deploy-preview-8308--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 96 (🟢 up 3 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 98 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@courageousillumination courageousillumination marked this pull request as ready for review January 28, 2024 05:37
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An excellent start for a first PR! Great 💖 emoji choice too, noticed & appreciated. 😄

Requesting changes on adding a unit test (and rule logic if needed) for the extra case mentioned.

@JoshuaKGoldberg JoshuaKGoldberg added the awaiting response Issues waiting for a reply from the OP or another party label Jan 29, 2024
@courageousillumination courageousillumination changed the title fix(eslint-plugin): [onsistent-type-imports] handle imports without specifiers fix(eslint-plugin): [consistent-type-imports] handle imports without specifiers Jan 29, 2024
@github-actions github-actions bot removed the awaiting response Issues waiting for a reply from the OP or another party label Jan 30, 2024
JoshuaKGoldberg
JoshuaKGoldberg previously approved these changes Feb 3, 2024
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! Very clean & straightforward. Nice. 🙂

Adding 1 approval and requesting review from @bradzacher because it coincidentally intersects with #8335.

@JoshuaKGoldberg JoshuaKGoldberg added the 1 approval PR that a maintainer has LGTM'd - any maintainer can merge this when ready label Feb 3, 2024
bradzacher
bradzacher previously approved these changes Mar 16, 2024
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bradzacher bradzacher dismissed stale reviews from JoshuaKGoldberg and themself via 5a892c9 March 16, 2024 01:10
Copy link

codecov bot commented Mar 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.24%. Comparing base (609a000) to head (5a892c9).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8308      +/-   ##
==========================================
+ Coverage   87.23%   87.24%   +0.01%     
==========================================
  Files         251      251              
  Lines       12319    12319              
  Branches     3884     3884              
==========================================
+ Hits        10746    10748       +2     
+ Misses       1303     1302       -1     
+ Partials      270      269       -1     
Flag Coverage Δ
unittest 87.24% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
...eslint-plugin/src/rules/consistent-type-imports.ts 95.98% <ø> (+0.72%) ⬆️

@bradzacher bradzacher merged commit b5e5bda into typescript-eslint:main Mar 16, 2024
59 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1 approval PR that a maintainer has LGTM'd - any maintainer can merge this when ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: [consistent-type-imports] Attempts to fix the wrong import statement
4 participants