Skip to content

feat(typescript-estree): add allowDefaultProjectForFiles project service allowlist option #7752

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

JoshuaKGoldberg
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg commented Oct 15, 2023

PR Checklist

Overview

Removes the check that projectService.openClientFile should return an opened file. In my testing, it looks like we can still generate type info for the file just with the default program for it?

Standalone repro here: https://github.com/JoshuaKGoldberg/repros/tree/project-service-without-opened-file https://github.com/JoshuaKGoldberg/repros/tree/allow-default-project-for-files

Asked for confirmation about this approach on the TypeScript Discord: https://discord.com/channels/508357248330760243/640177429775777792/1163133940115197952. Edit: confirmed, and filed #7761 as a followup ✅

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @JoshuaKGoldberg!

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.

@netlify
Copy link

netlify bot commented Oct 15, 2023

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 2ce23c0
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/6587e15e2cd6e300080fb3e7
😎 Deploy Preview https://deploy-preview-7752--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: 98 (no change 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.

@mrazauskas
Copy link
Contributor

Thanks for working on this.

I wonder, should it perhaps throw an error or at least log a warning is the default TSConfig is used? For instance, in my case there was no intention to use the default config. Seeing a warning or error would make me either to include the file into the program or to exclude it from lint.

Just thinking out loud. Can be I misunderstood the fix.

@JoshuaKGoldberg
Copy link
Member Author

JoshuaKGoldberg commented Oct 15, 2023

Hmm yeah it's an interesting idea. I don't think we'd want to warn by default, because one of the primary motivations for the option is to allow unlisted files to be linted (e.g. .eslintrc.cjs). But I can definitely see why you'd want that. I'll wait on getting explicit feedback around the approach from the TypeScript team (asked in the TS Discord & linked in the OP) before maybe filing an issue or discussion.

Edit: #7761 👍

Copy link
Collaborator

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

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

Theoretically looks correct to me; the only actual change is not returning early.

@JoshuaKGoldberg
Copy link
Member Author

JoshuaKGoldberg commented Oct 19, 2023

Excellent, thanks. I'll hold off on considering this mergeable until the conversation in #7761 is resolved. Just in case we end up radically overhauling everything. ✅ I think we're good to go for this specific issue.

@JoshuaKGoldberg JoshuaKGoldberg added the blocked by another issue Issues which are not ready because another issue needs to be resolved first label Oct 19, 2023
@JoshuaKGoldberg JoshuaKGoldberg changed the title fix(typescript-estree): allow project service for unknown client file feat(typescript-estree): allow project service for unknown client file Nov 2, 2023
@JoshuaKGoldberg
Copy link
Member Author

Re-targeting this to specifically focus on #7871.

@JoshuaKGoldberg JoshuaKGoldberg changed the title feat(typescript-estree): allow project service for unknown client file feat(typescript-estree): add allowDefaultProjectForFiles project service allowlist option Nov 7, 2023
@JoshuaKGoldberg JoshuaKGoldberg removed the blocked by another issue Issues which are not ready because another issue needs to be resolved first label Nov 7, 2023
@bradzacher bradzacher added the enhancement New feature or request label Nov 10, 2023
@@ -9,7 +13,15 @@ const createStubFileWatcher = (): ts.FileWatcher => ({

export type TypeScriptProjectService = ts.server.ProjectService;

export function createProjectService(): TypeScriptProjectService {
export interface ProjectServiceSettings {
allowDefaultProjectForFiles: ReadonlySet<string>;
Copy link
Member Author

Choose a reason for hiding this comment

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

This name is not particularly good but it's under an experimental option so I'd expect we'll rethink all names for v7.

bradzacher
bradzacher previously approved these changes Dec 23, 2023
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.

approving - pending that last convo being resolved

@JoshuaKGoldberg JoshuaKGoldberg merged commit 7ddadda into typescript-eslint:main Dec 24, 2023
@JoshuaKGoldberg JoshuaKGoldberg deleted the project-service-allow-no-client-file branch December 24, 2023 22:40
auvred pushed a commit to auvred/typescript-eslint that referenced this pull request Dec 29, 2023
…ice allowlist option (typescript-eslint#7752)

* fix(typescript-estree): allow project service for unknown client file

* Fixed up project throwing tests

* Added allowDefaultProjectForFiles as nested option

* Added a bit more testing

* fix: only throw on missing file path if hasFullTypeInformation

* Fix test snapshot

* Remove unnecessary assertion

* TypeScript_ESTree.mdx docs

* Absolute and canonical file paths

* Use minimatch instead of fs globbing

* lint: import sorting, missing return type

* Ignore some tests
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: Allow project service to provide type information for out-of-project files
4 participants