The documentation doesn't specify which containing workspace folder is returned, but it seems to be the innermost one. This causes .prettierignore to not be found if it is in an outer workspace folder, a common situation with Lerna.
The file gets formatted with Prettier. Note that it is not a solution to simply move .prettierignore into packages/foo/ and remove the packages/foo/ prefix from all the lines, because then it would not be picked up by yarn format run from the repository root.
Summary
Currently this extension uses
getWorkspaceRelativePath
to find.prettierignore
:https://github.com/prettier/prettier-vscode/blob/991a53f27df9f6d2abc782d8065512310c120983/src/PrettierEditService.ts#L401-L404
That function calls
getWorkspaceFolder
from the VS Code API:https://github.com/prettier/prettier-vscode/blob/991a53f27df9f6d2abc782d8065512310c120983/src/util.ts#L20
The documentation doesn't specify which containing workspace folder is returned, but it seems to be the innermost one. This causes
.prettierignore
to not be found if it is in an outer workspace folder, a common situation with Lerna.Github Repository to Reproduce Issue
https://github.com/samestep/prettier-vscode-ignore
Steps To Reproduce:
foo.code-workspace
from the cloned repository in VS Code.packages/foo/tsconfig.json
.Expected result
Nothing happens, because
packages/foo/tsconfig.json
is in.prettierignore
at the repository root.Actual result
The file gets formatted with Prettier. Note that it is not a solution to simply move
.prettierignore
intopackages/foo/
and remove thepackages/foo/
prefix from all the lines, because then it would not be picked up byyarn format
run from the repository root.Additional information
VS Code Version: 1.66.2 (Universal)
Prettier Extension Version: 9.5.0
OS and version: macOS Monterey 12.3.1
Prettier Log Output