Skip to content

fix(type-utils): handle external packages that are not in program.sourceFileToPackageName #10097

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

Closed
wants to merge 10 commits into from

Conversation

abrahamguo
Copy link
Contributor

@abrahamguo abrahamguo commented Oct 3, 2024

PR Checklist

Overview

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @abrahamguo!

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 Oct 3, 2024

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 3c2ffaa
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/67314266f448fc0008bba99e
😎 Deploy Preview https://deploy-preview-10097--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: 94 (🟢 up 2 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.

Copy link

nx-cloud bot commented Oct 3, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 3c2ffaa. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

Copy link

codecov bot commented Oct 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.09%. Comparing base (90617a6) to head (25e5120).
Report is 130 commits behind head on main.

Current head 25e5120 differs from pull request most recent head 3c2ffaa

Please upload reports for the commit 3c2ffaa to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10097      +/-   ##
==========================================
- Coverage   86.57%   86.09%   -0.48%     
==========================================
  Files         431      428       -3     
  Lines       15198    14970     -228     
  Branches     4421     4343      -78     
==========================================
- Hits        13158    12889     -269     
- Misses       1683     1734      +51     
+ Partials      357      347      -10     
Flag Coverage Δ
unittest 86.09% <100.00%> (-0.48%) ⬇️

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

Files with missing lines Coverage Δ
...Specifiers/typeDeclaredInPackageDeclarationFile.ts 100.00% <100.00%> (ø)

... and 74 files with indirect coverage changes

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.

Seems like a reasonable direction given TypeScript's weirdness. But we'll have to work with custom typeRoots, I think.

🚀

const packageNameMatcher = new RegExp(`${packageName}|${typesPackageName}`);
const fileNameMatcher = new RegExp(
`node_modules/(?:${packageName}|@types/${typesPackageName})/`,
);
Copy link
Member

Choose a reason for hiding this comment

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

https://www.typescriptlang.org/tsconfig/#typeRoots - if someone customizes this, then fileNameMatcher will be wrong. This'll need to reflect the project's compilerOptions.typeRoots.

Copy link
Member

Choose a reason for hiding this comment

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

@JoshuaKGoldberg JoshuaKGoldberg added the awaiting response Issues waiting for a reply from the OP or another party label Oct 10, 2024
@JoshuaKGoldberg
Copy link
Member

JoshuaKGoldberg commented Nov 10, 2024

👋 Just checking in @abrahamguo, anything we can help with?

@abrahamguo
Copy link
Contributor Author

Should be ready for review now, sorry for the delay! The remaining CI failures come from main.

@github-actions github-actions bot removed the awaiting response Issues waiting for a reply from the OP or another party label Nov 10, 2024
@bradzacher bradzacher added the bug Something isn't working label Nov 16, 2024
const packageNameRegExp = escapeAlternates([
packageName,
// Handle scoped packages: if the name starts with @, remove it and replace / with __
`@types/${packageName.replace(/^@([^/]+)\//, '$1__')}`,
Copy link
Member

Choose a reason for hiding this comment

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

[Bug] @types/ should not be hardcoded to always be considered. From https://www.typescriptlang.org/tsconfig/#typeRoots:

If typeRoots is specified, only packages under typeRoots will be included.

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.

There's a pending [Bug], I believe?

@JoshuaKGoldberg JoshuaKGoldberg added the awaiting response Issues waiting for a reply from the OP or another party label Nov 22, 2024
@JoshuaKGoldberg
Copy link
Member

👋 Hey @abrahamguo! Just checking in, is this still something you have time for? No worries if not - I just don't want to leave it hanging.

@abrahamguo
Copy link
Contributor Author

No, unfortunately I don't have time at the moment to finish this up!

@JoshuaKGoldberg
Copy link
Member

👍 No problem, thanks for getting it started! Closing out then.

If anybody wants to continue this work, please do! And if it builds off this PR, please add a co-author attribution.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
awaiting response Issues waiting for a reply from the OP or another party bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug(type-utils): Node.js' Buffer cannot be matched with a { type: package } TypeOrValueSpecifier
3 participants