coc-prettier
coc-prettier copied to clipboard
prettier.ignorePath setting is not respected
Content of coc-settings.json file:
{
"coc.preferences.formatOnSaveFiletypes": ["*"]
}
or
{
"coc.preferences.formatOnSaveFiletypes": ["*"],
"prettier.ignorePath": "./.prettierignore"
}
Repository folder structure:
repository-folder/ --.prettierignore --subfolder/ ----.prettierignore ----index.html
Content of repository-folder/.prettierignore file:
subfolder/
Content of repository-folder/subfolder/.prettierignore file:
(empty)
Repro steps:
- Run
vim repository-folder/subfolder/index.html
- Modify the index.html to make Prettier attempt to format the file when the file is saved
- Save the file
Expected: 4. Prettier formats index.html
Actual: 4. Prettier does not format index.html
Issue: The Readme.md file describes:
prettier.ignorePath (default: .prettierignore)
Supply the path to an ignore file such as
.gitignore
or.prettierignore
. Files which match will not be formatted. Set tonull
to not read ignore files. Restart required.
Setting the "prettier.ignorePath" setting to ".prettierignore" (default) or "./.prettierignore" should make Prettier use the .prettierignore file in the same directory as the file that is open.
Visual Studio Code does not have this issue when opening the subfolder folder.
I'm only using the .prettierignore file in the repository-folder to make Prettier ignore the subfolder folders of my project. The goal is that using Prettier in the repository-folder folder will only run Prettier on files in that folder, and not subfolders. If anyone else is running into this issue, a mitigation is to modify the Prettier script in your package.json file:
{
...
"scripts": {
"prettier": "prettier --write . \"!subfolder-1/**\" \"!subfolder-2/**\" \"!subfolder-3/**\"",
},
...
}
Content of coc-settings.json file:
{ "coc.preferences.formatOnSaveFiletypes": ["*"] }
or
{ "coc.preferences.formatOnSaveFiletypes": ["*"], "prettier.ignorePath": "./.prettierignore" }
Repository folder structure:
repository-folder/ --.prettierignore --subfolder/ ----.prettierignore ----index.html
Content of repository-folder/.prettierignore file:
subfolder/
Content of repository-folder/subfolder/.prettierignore file:
(empty)
Repro steps:
- Run
vim repository-folder/subfolder/index.html
- Modify the index.html to make Prettier attempt to format the file when the file is saved
- Save the file
Expected: 4. Prettier formats index.html
Actual: 4. Prettier does not format index.html
Issue: The Readme.md file describes:
prettier.ignorePath (default: .prettierignore)
Supply the path to an ignore file such as
.gitignore
or.prettierignore
. Files which match will not be formatted. Set tonull
to not read ignore files. Restart required.Setting the "prettier.ignorePath" setting to ".prettierignore" (default) or "./.prettierignore" should make Prettier use the .prettierignore file in the same directory as the file that is open.
Visual Studio Code does not have this issue when opening the subfolder folder.
if you are still having an issue drop log of :CocCommand prettier.openOutput
, because I have been having this issue myself just to realise that I have been using prettier.forceFormatDocument
on my binding, rather than just prettier.formatFile