Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.prettierignore ignore everything except specific folder #578

Closed
tlareg opened this issue Sep 5, 2018 · 5 comments
Closed

.prettierignore ignore everything except specific folder #578

tlareg opened this issue Sep 5, 2018 · 5 comments
Labels
bug locked Please open a new issue and fill out the template instead of commenting.
Milestone

Comments

@tlareg
Copy link

tlareg commented Sep 5, 2018

.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?

@tlareg
Copy link
Author

tlareg commented Sep 5, 2018

ok, maybe this is my fault, works ok with:

# Ignore everything:
/*

# Except myapp:
!/myapp

@CiGit
Copy link
Member

CiGit commented Sep 12, 2018

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)

@CiGit CiGit added the bug label Sep 12, 2018
@michael13491
Copy link

michael13491 commented Jul 22, 2019

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"

@ntotten ntotten added this to the Version 3.0 milestone Oct 21, 2019
@ntotten
Copy link
Member

ntotten commented Oct 22, 2019

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.

@ntotten ntotten closed this as completed Oct 22, 2019
@github-actions
Copy link

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.

@github-actions github-actions bot added the locked Please open a new issue and fill out the template instead of commenting. label Apr 12, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug locked Please open a new issue and fill out the template instead of commenting.
Projects
None yet
Development

No branches or pull requests

4 participants