prettier / prettier-vscode

Visual Studio Code extension for Prettier
https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
MIT License
5.04k stars 446 forks source link

Prettier does not format in multi-folder repositories whilst using the .code-workspace config. #3201

Closed aidanm1999 closed 3 months ago

aidanm1999 commented 6 months ago

Summary

Prettier does not format in multi-folder repositories whilst using the .code-workspace config.

Github Repository to Reproduce Issue

https://github.com/aidanm1999/prettier-vscode-multi-workspace-config

This repository is set up like so:

Steps To Reproduce:

  1. Open the repository through the repo.code-workspace
  2. This will open the repo with workspaces
  3. Open the Prettier output pane
  4. Open repo.code-workspace and comment out folders 1, 2 and 3
    • This is to ensure the files open through the 'Root' folder
  5. Then open any of the JSON documents and format the file
  6. Should format successfully
  7. Uncomment the folders in the repo.code-workspace
  8. Now re-open the document and try to format

Expected result

The Prettier output should have logged a successful reformat

Actual result

The prettier output errors out:

["INFO" - 17:04:20] Formatting file:///Users/me/Developer/prettier-vscode-multi-workspace-config/group-1/workspace-2/doc.json
["ERROR" - 17:04:20] Invalid prettier configuration file detected.
["ERROR" - 17:04:20] ENOENT: no such file or directory, open '/Users/me/Developer/prettier-vscode-multi-workspace-config/group-1/workspace-2/.prettierrc'
Error: ENOENT: no such file or directory, open '/Users/me/Developer/prettier-vscode-multi-workspace-config/group-1/workspace-2/.prettierrc'

Now this would be fine if you could write ${workspaceFolder:Root}/.prettier, however this does not resolve:

Error: ENOENT: no such file or directory, open '/Users/me/Developer/prettier-vscode-multi-workspace-config/group-1/workspace-2/${workspaceFolder:Root}/.prettierrc'

It would be ideal if the Prettier extension could resolve the workspaceFolder or bubble up a search to look at parent, grandparent or great-grandparent directories.

Additional information

VS Code Version: 1.84.2

Prettier Extension Version: 10.1.0

OS and version: MacOS Sonoma 14.1

Prettier Log Output

Relevant logs logged above

github-actions[bot] commented 4 months ago

This issue has been labeled as stale due to inactivity. Reply to keep this issue open.

aidanm1999 commented 3 months ago

Still an issue

jhgeluk commented 3 months ago

Still an issue

github-actions[bot] commented 3 weeks ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.