Skip to content

fix(typescript-estree): adds support for project services using extended config files #9306

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

Conversation

higherorderfunctor
Copy link
Contributor

@higherorderfunctor higherorderfunctor commented Jun 8, 2024

PR Checklist

Overview

  • Changes packages/typescript-estree/src/create-program/createProjectService.ts to use tsserver.getParsedCommandLineOfConfigFile instead of tsserver.readConfigFile to process extended tsconfigs.
  • Moves the tsserver.getParsedCommandLineOfConfigFile boilerplate from packages/typescript-estree/src/create-program/useProvidedPrograms.ts into a new file packages/typescript-estree/src/create-program/getParsedConfigFile.ts to keep the code DRY.
  • Adds tests for single and multiple extends to packages/typescript-estree/tests/lib/createProjectService.test.ts. Also adds a couple tests to round out coverage for uncommon code paths to bring getParsedConfigFile.ts to 100% (tsserver.sys === undefined and triggering getCanonicalFileName with tsserver.formatDiagnostics).
  • Adds a new fixture at packages/typescript-estree/tests/fixtures/projectServicesComplex/.

A few implementation notes for the reviewer:

  • There is a hard any cast in packages/typescript-estree/src/create-program/createProjectService.ts. I left a code comment with reasoning for doing so. The original tsserver.readConfigFile was also any with a hard cast.
  • formatDiagnostics in the new packages/typescript-estree/src/create-program/getParsedConfigFile.ts file was placed inside getParsedConfigFile. This was only to share the lazy import of tsserver. The existing Jest mocks seem to rely on tsserver being a lazy import. I'm not very familiar with eslint's module import cache-bypassing behavior, so I don't know if there is a performance implication here. The original lazy import is also still present in packages/typescript-estree/tests/lib/createProjectService.test.ts. We could try adding tsserver as a parameter to getParsedConfigFile to remove the extra lazy import if we think it will be a problem.
  • Switched from a global mock to a doMock inside a beforeAll for testing tsserver.env === undefined case. I've primarily used mocha/chai, vitest, and bun test; so if it there is a cleaner way to do this in jest I can make that update.
  • All previous unit tests in packages/typescript-estree/tests/lib/createProjectService.test.ts were truly unit tests mocking all calls to tsserver. Wanting to test the extends behavior, some of the tests now call through to tsserver. Since these are really testing integration functionality, please let me know if adjustments are required. These tests also have slightly looser assertions since tsserver adds some metadata. A code comment has been added to mark each.
  • I did not end up needing to use all of the projectServicesComplex fixture, specifically the project references. It may have future uses, but I can trim the currently unused project references if preferred.

Inline comments work for me on the PR.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @higherorderfunctor!

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 Jun 8, 2024

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 4478aea
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/66a62e98249f920008d167c1
😎 Deploy Preview https://deploy-preview-9306--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: 99 (no change from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 90 (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.

@higherorderfunctor higherorderfunctor changed the title fix(typescript-estree): Adds support for project services and extended config files fix(typescript-estree): adds support for project services and extended config files Jun 8, 2024
Copy link

nx-cloud bot commented Jun 8, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 4478aea. 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 1 target

Sent with 💌 from NxCloud.

Copy link

codecov bot commented Jun 8, 2024

Codecov Report

Attention: Patch coverage is 95.83333% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.04%. Comparing base (f3dfc0a) to head (ac8c9bc).
Report is 4 commits behind head on v8.

Current head ac8c9bc differs from pull request most recent head 4478aea

Please upload reports for the commit 4478aea to get more accurate results.

Additional details and impacted files
@@            Coverage Diff             @@
##               v8    #9306      +/-   ##
==========================================
+ Coverage   88.01%   88.04%   +0.03%     
==========================================
  Files         401      402       +1     
  Lines       13637    13639       +2     
  Branches     3960     3959       -1     
==========================================
+ Hits        12003    12009       +6     
+ Misses       1325     1322       -3     
+ Partials      309      308       -1     
Flag Coverage Δ
unittest 88.04% <95.83%> (+0.03%) ⬆️

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

Files Coverage Δ
...-estree/src/create-program/createProjectService.ts 95.34% <100.00%> (+1.87%) ⬆️
...t-estree/src/create-program/useProvidedPrograms.ts 100.00% <100.00%> (+12.12%) ⬆️
...t-estree/src/create-program/getParsedConfigFile.ts 93.75% <93.75%> (ø)

... and 3 files with indirect coverage changes

@higherorderfunctor higherorderfunctor marked this pull request as ready for review June 8, 2024 23:25
@higherorderfunctor higherorderfunctor changed the title fix(typescript-estree): adds support for project services and extended config files fix(typescript-estree): adds support for project services using extended config files Jun 10, 2024
@JoshuaKGoldberg JoshuaKGoldberg added this to the 8.0.0 milestone Jun 20, 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.

I like the general direction! +1 on extracting out a getParsedConfigFile, that's really useful. 🚀

Requesting changes mostly on reorganization, and the require()ing too. Cheers!

@JoshuaKGoldberg JoshuaKGoldberg added the awaiting response Issues waiting for a reply from the OP or another party label Jun 25, 2024
…ts with review feedback

Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com>
@JoshuaKGoldberg
Copy link
Member

👋 are you waiting on us for anything @higherorderfunctor?

@higherorderfunctor
Copy link
Contributor Author

👋 are you waiting on us for anything @higherorderfunctor?

Nope! I'll be picking this back up this week / weekend. Had a vacation and some deadlines the last two weeks.

@JoshuaKGoldberg
Copy link
Member

Great! Let's time box this to a week from now, then - we really want to release v8 as soon as possible.

@higherorderfunctor
Copy link
Contributor Author

Created getParsedConfigFile.test.ts.

Will revert most of the changes to createProjectService.test.ts except for the use of the new function (mocked).
Decide if dropping or creating the complex tests as an integration (probably drop).
Merge in v8 again and resolve conflicts.

Plan to be done by tonight.

@higherorderfunctor
Copy link
Contributor Author

@JoshuaKGoldberg I will have some time tomorrow to check on the CI for any errors or for any final edits you would like to make. Thanks!

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.

🔥 this is great, thanks!

I only have one teeny nit. It's absolutely not blocking at all. Will leave this open for a bit in case anybody else from the team has time to review.

@JoshuaKGoldberg JoshuaKGoldberg added 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge and removed awaiting response Issues waiting for a reply from the OP or another party labels Jul 24, 2024
higherorderfunctor and others added 2 commits July 24, 2024 19:09
Co-authored-by: Brad Zacher <brad.zacher@gmail.com>
Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com>
Co-authored-by: Brad Zacher <brad.zacher@gmail.com>
Co-authored-by: Josh Goldberg ✨ <git@joshuakgoldberg.com>
@higherorderfunctor
Copy link
Contributor Author

All changes made. Let me know if anything else!

I think the running CI job is stuck, netlify shows complete.

Opened #9641 for the test clean up.

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.

🔥 thanks!

@JoshuaKGoldberg JoshuaKGoldberg merged commit 2a05336 into typescript-eslint:v8 Jul 28, 2024
4 checks passed
@JoshuaKGoldberg JoshuaKGoldberg deleted the fix/9205-project-service-extends-issue branch July 28, 2024 11:42
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants