Location detection logic differs between .prettierignore and .prettierrc
See original GitHub issueSummary
I have one directory where I put all my Git projects. Let’s say it’s called workspace
. I open this in VS Code using File > Open Folder. Then any repo I git clone
into that folder automatically gets added to my VS Code workspace.
Whenever I use this plugin, it appropriately finds the .prettierrc in the folder of the specific git repo. So if the git repo is named prettier-test
:
Using config file at '/home/user/workspace/prettier-test/.prettierrc'
However it only looks for .prettierignore at the root level of the entire VS Code workspace:
Using ignore file (if present) at /home/user/workspace/.prettierignore
So any .prettierignore files in my Git repos are completely ignored.
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"prettier.requireConfig": true,
Expected result
I would’ve expected .prettierignore in /home/user/workspace/prettier-test/ to be used, as this seems to be the behaviour for .prettierrc
Actual result
The plugin looked for .prettierignore in /home/user/workspace/ which seems to be inconsistent behaviour
Additional information
VS Code Version: 1.51.1
Prettier Extension Version: 5.8.0
OS and version: Ubuntu 20.04
Prettier Log Output
["INFO" - 3:38:58 p.m.] Formatting /home/user/workspace/prettier-test/test.yaml
["INFO" - 3:38:58 p.m.] Using ignore file (if present) at /home/user/workspace/.prettierignore
["INFO" - 3:38:58 p.m.] Using bundled version of prettier.
["INFO" - 3:38:58 p.m.] File Info:
{
"ignored": false,
"inferredParser": "yaml"
}
["INFO" - 3:38:58 p.m.] Detected local configuration (i.e. .prettierrc or .editorconfig), VS Code configuration will not be used
["INFO" - 3:38:58 p.m.] Using config file at '/home/user/workspace/prettier-test/.prettierrc'
["INFO" - 3:38:58 p.m.] Prettier Options:
{
"filepath": "/home/user/workspace/prettier-test/test.yaml",
"parser": "yaml"
}
["INFO" - 3:38:58 p.m.] Formatting completed in 19.610672ms.
Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:8 (3 by maintainers)
Top GitHub Comments
I originally didn’t create a git repo since it doesn’t fully replicate my situation. But it seems whether a particular directory is a git repo seems to bet seems to be irrelevant in this case so I went ahead and created a test repo here: https://github.com/bmaupin/prettier-vscode-1694
So for this test:
Steps to reproduce:
git clone https://github.com/bmaupin/prettier-vscode-1694.git
In vscode, go to File > Open Folder and browse to prettier-vscode-1694
Open project1/test.yaml
Save the file and observe that the single quotes are changed to double quotes
Open the prettier log and observe that inconsistent logic is used in determining the location of .prettierignore vs .prettierrc:
The same behaviour can also be observed if the folder is added to the current workspace using File > Add Folder to Workspace
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.