.prettierignore file:
# Ignore everything:
*
# Except myapp folder:
!myapp/
When running prettier from console - works great, changes in myapp folder are formatted by prettier and changes in other folders are ignored (I am using commit hook with husky and lint-staged configured exactly like in prettier docs).
When I run "Format document" from vscode on file inside myapp folder, it is not working.
After removing .prettierignore file, "Format document" works great.
I think prettier-vscode is ignoring everything without exceptions when I use such prettierignore file?
ok, maybe this is my fault, works ok with:
# Ignore everything:
/*
# Except myapp:
!/myapp
We should check if we run the same version of ignore than prettier.
The behavior should be the same in both case (cli and extension)
I have a similar problem to this, except my project is a monorepo. The solution that tlareg has does not seem to work for me.
Project structure:
root/
.git
other-app/
web-app/
package.json
.prettierignore
I want to specify prettierignore so that only web-app dir files get formatted on save.
.prettierignore file:
# Ignore everything:
/*
# Except web-app:
!/web-app
When I run "Format document" from vscode on file inside web-app folder, it is not working.
After removing .prettierignore file, "Format document" works great.
However, with pretty-quick pre-commit hook, the staged files inside web-app will be formatted. So it seems the prettierignore syntax is problematic only on prettier-vscode?
Update
The above .prettierignore will work with prettier-vscode if I open the project from root, but does not work if it is opened from web-app directory
Update again
Fixed this myself. Resolved by moving .prettierignore to root, and add files to ignore. In web-app, create a workspace setting to include prettier.ignorePath
Final result.
Project structure:
root/
.git
.prettierignore
other-app/
web-app/
package.json
.prettierignore file:
# Ignore everything:
/*
# Except web-app:
!/**/web-app
vscode settings.json in web-app dir includes
"editor.formatOnSave": true,
"prettier.ignorePath": "../.prettierignore"
We are using prettier to determine the ignored files in version 3.0 so there should be no difference in prettier's behavior vs ours.
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.
Most helpful comment
ok, maybe this is my fault, works ok with: