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

feat(parser, typescript-estree): export withoutProjectParserOptions utility #9233

Conversation

fpapado
Copy link
Contributor

@fpapado fpapado commented Jun 3, 2024

PR Checklist

Overview

Adds the utility described in #8428, allowing direct callers of the parser to omit options that would cause typechecking / type information to be collected. This essentially inverts the control back into typescript-eslint's codebase, and avoids having to sync changes across multiple third-party packages.

The primary motivation is eslint-plugin-import, which uses the parser in isolation (hrough some eslint indirection), and sees a large speedup by not collecting type information.

Rationale and Open Questions

I placed the utility in typescript-estree, so that it is co-located with the parser options themselves. The utility is re-exported by @typescript-eslint/parser, since I imagine that a a conditional require (as described in #8428) would import the parser. It's a bit hard to design this without trying the call-site 😅

The current implementation uses TSESTreeOptions. This means that we would need a separate PR for the v8 branch, which deletes only the things relevant to it. I think that's kinda nice, since we only ever touch keys that are relevant for the resolved parser. But, I might be missing something!

(I added one other question in a PR comment)

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @fpapado!

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

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 35a3d4b
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/66606abe0f1ab10009eed70b
😎 Deploy Preview https://deploy-preview-9233--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 (🔴 down 5 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 90 (🔴 down 8 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 Jun 3, 2024

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 35a3d4b. 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 31 targets

Sent with 💌 from NxCloud.

@fpapado fpapado marked this pull request as ready for review June 3, 2024 18:15
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.

A lovely start, thanks for sending this in! A few suggestions inline - what do you think?

Randy Marsh from South Park saying "convenience at its peak"

@JoshuaKGoldberg JoshuaKGoldberg added the awaiting response Issues waiting for a reply from the OP or another party label Jun 3, 2024
@fpapado
Copy link
Contributor Author

fpapado commented Jun 4, 2024

Thanks for the suggestions, they all make sense! Let me know if anything else comes up ✍️

Comment on lines 361 to 368
Removes options that prompt the parser to parse the project with type
information. In other words, you can use this if you are invoking the parser
directly, to ensure that one file will be parsed in isolation, which is much,
much faster.

This is useful in cases where you invoke the parser directly, such as in an
ESLint plugin context.

Copy link
Member

Choose a reason for hiding this comment

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

Don't wrap lines by width. Either no breaks or wrap at sentence stops.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for catching this! Changed to sentence stops in 15d47de

JoshuaKGoldberg
JoshuaKGoldberg previously approved these changes Jun 4, 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.

🚀

@JoshuaKGoldberg JoshuaKGoldberg added 1 approval One team member has approved this PR; a second should be enough to merge it and removed awaiting response Issues waiting for a reply from the OP or another party labels Jun 5, 2024
@JoshuaKGoldberg JoshuaKGoldberg changed the title feat(parser, typescript-estree): export removeParserOptionsThatPromptTypechecking utility feat(parser, typescript-estree): export withoutProjectParserOptions utility Jun 6, 2024
@JoshuaKGoldberg JoshuaKGoldberg merged commit c9a6dd9 into typescript-eslint:main Jun 6, 2024
66 of 68 checks passed
@Thorsmercy

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 approval One team member has approved this PR; a second should be enough to merge it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: Add an exported utility to remove type info from parserOptions
4 participants