Skip to content

Enhancement: Include projectService: true in type-checked configs #10507

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

Open
4 tasks done
kirkwaiblinger opened this issue Dec 16, 2024 · 4 comments
Open
4 tasks done
Labels
blocked by external API Blocked by a tool we depend on exposing an API, such as TypeScript's Type Relationship API enhancement New feature or request preset config change Proposal for an addition, removal, or general change to a preset config

Comments

@kirkwaiblinger
Copy link
Member

kirkwaiblinger commented Dec 16, 2024

Before You File a Proposal Please Confirm You Have Done The Following...

Relevant Package

typescript-eslint

My proposal is suitable for this project

  • I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).

Description

I propose that a config should be created identical to recommendedTypeChecked (as well as for its *TypeChecked friends) but with projectService: true specified. That way, just as tseslint.configs.recommended enables TS language support in tseslint.configs.recommended[0], the proposed config would enable TS language support with typed linting support that more-or-less works out of the box for Most™️ projects. I think this could significantly reduce the burden on users for setting up typed linting.

I think it would be breaking to modify the existing configs, so we'd have to come up with a name for the projectService: true variant. Maybe tseslint.configs.recommendedPreconfiguredTypeChecked? Idk what a good name would be 🤷‍♂️

Additional Info

Refs:

@kirkwaiblinger kirkwaiblinger added enhancement New feature or request triage Waiting for team members to take a look preset config change Proposal for an addition, removal, or general change to a preset config labels Dec 16, 2024
@JoshuaKGoldberg
Copy link
Member

JoshuaKGoldberg commented Feb 17, 2025

This is ... kind of scary at first 😅 to my knowledge we've never set up type checking for users before. My first big fear is that by hiding away the parserOptions.projectService setting, we'll further help users avoid knowing how these configs are different from the normal recommended ones. ...but I think that fear isn't right. Users still have to opt into it anyway with a config that includes "TypeChecked" . So that's fine. 👍

A more technical blocker would be that we still want people to set tsconfigRootDir. #10826 is a recent question around it. Quoting @bradzacher's #10826 (comment):

tsconfigRootDir is how we orient ourselves in disk for all of our type-aware linting. Without it there are only two absolute paths that we know - the CWD and the file being linted (and in some cases the latter isn't even absolute!!).

If we could get the directory being linted from ESLint, then I think we could remove the need to strongly recommend tsconfigRootDir. Related: #251 (what a throwback!). That was closed as noted in #251 (comment) because ESLint doesn't tell parsers the eslintrc path(s). But, now that we're on flat config, maybe there's a way to get the single flat config file / directory? Filed: #10841.

IMO we should mark this as blocked on ☝ #10841. But if unblocked this would be really nice and I'd be very much in favor of it. 👍

@kirkwaiblinger
Copy link
Member Author

kirkwaiblinger commented Feb 17, 2025

This is one the areas where having config factories rather than prefab objects/arrays would be really nice (see also eslint/rfcs#126 (comment), for example). Would let us provide an API like

export default tseslint.config(
    // etc
    tseslint.configs.enableTypedLinting({ 
        // with intellisense, etc. Maybe even a required property.
        tsconfigRootDir: import.meta.dirname;
    });
)

@bradzacher
Copy link
Member

With the advent of flat configs we could probably request that ESLint passes the config path as configPath: string | undefined to parsers. Each file has 0..1 flat config files now so that would be a way to do-away with tsconfigRootDir for 99.99% of cases.

@JoshuaKGoldberg
Copy link
Member

👍 filed eslint/eslint#19438. Marking this blocked on that.

@JoshuaKGoldberg JoshuaKGoldberg added blocked by external API Blocked by a tool we depend on exposing an API, such as TypeScript's Type Relationship API and removed triage Waiting for team members to take a look labels Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked by external API Blocked by a tool we depend on exposing an API, such as TypeScript's Type Relationship API enhancement New feature or request preset config change Proposal for an addition, removal, or general change to a preset config
Projects
None yet
Development

No branches or pull requests

3 participants