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

vscode + ts + monorepo - issues with resolving parserOptions files in IDE (but not cli) #463

Closed
5 tasks done
timfee opened this issue Apr 28, 2024 · 3 comments
Closed
5 tasks done

Comments

@timfee
Copy link

timfee commented Apr 28, 2024

Describe the bug

When I have several eslint instances in my monorepo that reference a common package, Visual Studio seems to get "stuck" in resolving the project directory to the first path I open in a session, and uses that path to validate all other packages.

I tried "auto" as well as explicitly listing workingDirectories in my config file, and have used the nightly version of ESLint with flat-file support, as well as the prod version with the experimental enable flag set to true.

Repro

Screen.Shot.2024-04-28.at.13.13.13.mp4
  1. Open the workspace root in VSCode then open a file in a sub-directory that ESLint would validate.
  2. Observe it works fine.
  3. Open a file in a different sub-directory and observe that the resolved project parser is pointing to the cwd of the file in step 1.
  4. Run turbo lint from the workspace root and observe no errors.

Not sure if this is an issue with the IDE, or if maybe my strategy to implement this cleanly is wrong, but wanted to share in case the issue was something here. (Cross-posted to microsoft/vscode-eslint#1840 in case it was the extension)

Reproduction

https://github.com/timfee/eslint-repro

System Info

System:
    OS: macOS 14.4.1
    CPU: (16) arm64 Apple M3 Max
    Memory: 12.12 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 21.6.1 - ~/.local/share/asdf/installs/nodejs/21.6.1/bin/node
    Yarn: 1.22.22 - /opt/homebrew/bin/yarn
    npm: 10.2.4 - ~/.local/share/asdf/plugins/nodejs/shims/npm
    pnpm: 8.15.2 - ~/.local/share/asdf/installs/pnpm/8.15.2/bin/pnpm
    bun: 1.1.4 - /opt/homebrew/bin/bun
  Browsers:
    Chrome: 123.0.6312.87
    Safari: 17.4.1

Used Package Manager

pnpm

Validations

  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.
@timfee timfee changed the title vscode + ts + monorepo causes - resolving parser errors in IDE (but not cli) vscode + ts + monorepo - issues with resolving parserOptions files in IDE (but not cli) Apr 28, 2024
@thenbe
Copy link
Contributor

thenbe commented Apr 28, 2024

See if the "vscode eslint extension" logs can help you track this down. You might be able to access them through the command palette. Otherwise they're accessible through that bottom panel somewhere (the one with ports, output, terminal, ...). I'd also look to see if there is a verbose mode you can toggle for the eslint extension.

Either way, if you're seeing the issue only through the vscode (while usage through the cli is as expected) then it's likely to be an issue with the extension/its configuration.

seems to get "stuck" in resolving the project directory to the first path I open in a session, and uses that path to validate all other packages

Can this help give you more control over the faulty auto behavior? https://github.com/microsoft/vscode-eslint/blob/553e632fb4cf073fce1549fb6c3c1b5140a52ebb/README.md?plain=1#L262

@timfee
Copy link
Author

timfee commented Apr 28, 2024

Thank you for the note :)

Yeah, I've tried the different tweaks at the extension level - leading me to believe it may be something weird with the extension and/or latest ESLint.

I wasn't sure if I was doing something wrong with this config.

For example, I wanted to have an eslint for typescript, one for Nextjs apps, and one generic node - and to have them extendable and stackable (sort of like the default create-turbo setup), so this is the meta context behind this quest :)

@timfee
Copy link
Author

timfee commented Apr 30, 2024

Ah, so I found the culprit:

When I specify my project directory this way, it works:

  typescript: {
-      tsconfigPath: "./tsconfig.json",
+      parserOptions: {
+        project: "./tsconfig.json",
+      },
    },

@antfu antfu closed this as completed May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants