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

Bug: Project service doesn't infer compilerOptions for files not included in a tsconfig.json #8206

Closed
4 tasks done
JoshuaKGoldberg opened this issue Jan 6, 2024 · 3 comments · Fixed by #8815
Closed
4 tasks done
Assignees
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working package: typescript-estree Issues related to @typescript-eslint/typescript-estree
Milestone

Comments

@JoshuaKGoldberg
Copy link
Member

JoshuaKGoldberg commented Jan 6, 2024

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.
  • I have searched for related issues and found none that matched my issue.
  • I have read the FAQ and my problem is not listed.

Issue Description

Moving #8030 (reply in thread) into a standalone issue: users are going to want to be able to lint .eslintrc.cjs files without including them in the tsconfig.json compilerOptions.allow and include. But the project service as-is provides a "blank slate" set of default compiler options when a file isn't included in a loaded tsconfig.json.

Proposal: if a file is included in allowDefaultProjectForFiles (added in #7752) and isn't given compiler options from a loaded TSConfig, instead give it the compiler options for the nearest tsconfig.json?

Reproduction Repository Link

https://github.com/JoshuaKGoldberg/repros/tree/ts-eslint-project-service-not-included

Repro Steps

  1. clone the repo
  2. npm install
  3. npm lint

Versions

package version
@typescript-eslint/parser 6.18.0
@typescript-eslint/typescript-estree 6.18.0
TypeScript 5.3.3
@JoshuaKGoldberg JoshuaKGoldberg added bug Something isn't working package: typescript-estree Issues related to @typescript-eslint/typescript-estree triage Waiting for maintainers to take a look labels Jan 6, 2024
@JoshuaKGoldberg JoshuaKGoldberg added this to the 7.0.0 milestone Jan 6, 2024
@JoshuaKGoldberg JoshuaKGoldberg added package: parser Issues related to @typescript-eslint/parser and removed package: parser Issues related to @typescript-eslint/parser labels Jan 6, 2024
@bradzacher
Copy link
Member

I dunno if we should magically infer the options like that. I kinda hate black-box magic like that.

I'd be happy with an option to set the tsconfig used for extra files - so people could configure it from their eslint config. Then if they wanted to explicitly use a specific config then they could require it in place.

As an example the closest tsconfig might be one for Web files and include like the DOM libs or have a really restricted es version. An explicit config would let someone tweak things for their node env

@mrazauskas
Copy link
Contributor

mrazauskas commented Jan 7, 2024

Some defaultTSConfig option makes sense for me. It could take a path to tsconfig.json and use compiler options found there for inferred projects. Also the default value could be './tsconfig.json'. This is some magic too, but with a possibility to opt out.

I was thinking about the motivation for './tsconfig.json' default value. Probably typescript-eslint is mostly used in TypeScript projects. These often have tsconfig.json at the root and very likely this is the default TSConfig. Files which are not included in the project would be something like eslint.config.js. I would be fine to use options from tsconfig.json on these. Of course, this is just a single option with many assumptions in it (;

@JoshuaKGoldberg JoshuaKGoldberg added accepting prs Go ahead, send a pull request that resolves this issue and removed triage Waiting for maintainers to take a look labels Feb 4, 2024
@JoshuaKGoldberg
Copy link
Member Author

Note for reference: #8460 (review). Once this is in, we'll want to breaking change remove the main entry from typescript-eslint.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepting prs Go ahead, send a pull request that resolves this issue bug Something isn't working package: typescript-estree Issues related to @typescript-eslint/typescript-estree
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants