8000 Bug: Upgrade to 8.5.0 breaks linting setup with NX and `projectService: true` · Issue #9985 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

Bug: Upgrade to 8.5.0 breaks linting setup with NX and projectService: true #9985 < 8000 /h1>
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

Closed
4 tasks done
hoi4 opened this issue Sep 13, 2024 · 7 comments · Fixed by #9989
Closed
4 tasks done

Bug: Upgrade to 8.5.0 breaks linting setup with NX and projectService: true #9985

hoi4 opened this issue Sep 13, 2024 · 7 comments · Fixed by #9989
Labels
awaiting response Issues waiting for a reply from the OP or another party bug Something isn't working locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.

Comments

@hoi4
Copy link
hoi4 commented Sep 13, 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

After upgrading typescript-eslint to the latest version 8.5.0 my linting setup with NX broke.

The respective error message is Parsing error: Could not read project service default project 'tsconfig.json': error TS5012: Cannot read file 'tsconfig.json': ENOENT: no such file or directory. The respective files are included in a tsconfig.lib.json file which is being referenced from tsconfig.json. The same applies to files included by tsconfig.spec.ts (also referenced by tsconfig.json).

I am using projectService: true with a NX monorepo (see reproduction repo). The same setup worked fine with version 8.4.0. The breaking change seems to be #9893.

Reproduction Repository Link

https://github.com/hoi4/typescript-eslint-issue

Repro Steps

  1. clone the repo
  2. npm i
  3. npx nx lint nx19 --skip-nx-cache

Alternatively, when using eslint directly with an example file: npx eslint apps/nx19/src/app/app.component.ts

The latest commit uses version 8.5.0 which has the described issue. The previous commit holds a working state with version 8.4.0.

Versions

package version
@typescript-eslint/eslint-plugin 8.5.0
@typescript-eslint/parser 8.5.0
@typescript-eslint/utils 8.5.0
TypeScript ~5.5.2
ESLint 9.10.0
node 20.15.0
@hoi4 hoi4 added bug Something isn't working triage Waiting for team members to take a look labels Sep 13, 2024
@hoi4 hoi4 changed the title Bug: Upgrade to 8.5.0 breaks linting setup with NX and parserProject: true Bug: Upgrade to 8.5.0 breaks linting setup with NX and projectService: true Sep 13, 2024
@JoshuaKGoldberg
Copy link
Member

Could not read project service default project 'tsconfig.json': error TS5012: Cannot read file 'tsconfig.json': ENOENT: no such file or directory

Aha! This is from #9893. That PR landed under the assumption if that the cwd being linted should generally have a tsconfig.json in that directory. Which https://github.com/hoi4/typescript-eslint-issue does not. It just has a tsconfig.base.json that other TSConfigs fall under.

Which brings up a question: why is there not a root-level tsconfig.json? Are you just relying on the default editor type info for root-level files such as eslint.config.js and jest.config.ts?

@JoshuaKGoldberg JoshuaKGoldberg added awaiting response Issues waiting for a reply from the OP or another party and removed triage Waiting for team members to take a look labels Sep 13, 2024
@cuquo
Copy link
cuquo commented Sep 14, 2024

the same happened to me with 8.5, cli works great but vscode could not locate the root tsconfig.json in a turbo monorepo. Eslint configuration is in another package /rigs/eslint where it doesn't has a tsconfig

@JavaScriptBach
Copy link
Contributor

I also ran into this issue in a Turbo monorepo when trying to upgrade to 8.5.0. CLI works great, but VSCode linting broke.

I'm not the OP, but I'll add my 2c here in case it helps:

Which brings up a question: why is there not a root-level tsconfig.json? Are you just relying on the default editor type info for root-level files such as eslint.config.js and jest.config.ts?

This is what we do, although I won't claim it's optimal. But the idea is that in our mono-repo, all the "real" Typescript files live in a workspace, and different workspaces may need different Typescript compiler settings. So the root workspace contains a partial tsconfig.json and workspaces will extend it to create complete ones.

@hoi4
Copy link
Author
hoi4 commented Sep 14, 2024

Exactly, having a root tsconfig.base.json and project-specific tsconfig.json files which extend the base config is just the way NX works.
It is true that there might be some top-level files, e.g. jest.config.ts which are not included in any tsconfig.json. Imo, it would be perfectly fine if typescript-eslint errors for files like these (without the respective configuration of a defaultProject). I would just add files like these to the ignore list.

This issue is all about files that are included in a tsconfig, the respective tsconfig just doesn't live in the cwd.
In the previous version (8.4.0), typescript-eslint was able to correctly find the closest tsconfig.json file for project/lib files that are included in e.g. a tsconfig.app.json file being referenced from a tsconfig.json file in the respective app/lib folder.

@JoshuaKGoldberg
Copy link
Member

Thanks all, this is helpful! I'd underestimated how common+desirable it is for projects to not include a root-level tsconfig.json. What you're showing makes sense - that for those root-level config files, there's no need for a full tsconfig.json. #9989 changes the project service to not throw an error about a missing default project (TSConfig) if projectService.defaultProject isn't set.

@JoshuaKGoldberg
Copy link
Member

With #9989 merged, this issue should be resolved. Per https://typescript-eslint.io/users/releases/#canary:

Please let us know if that doesn't fix things for you 🙂. And thanks for using the new project service & latest versions all!

@hoi4
Copy link
Author
hoi4 commented Sep 15, 2024

Quickly tested my reproduction project with typescript-eslint@8.5.1-alpha.10 --> Works again! Thank you very much for the quick fix! @JoshuaKGoldberg ❤️

@github-actions github-actions bot added the locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing. label Sep 23, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
awaiting response Issues waiting for a reply from the OP or another party bug Something isn't working locked due to age Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.
Projects
None yet
4 participants
0