Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to base .prettierignore file on .gitignore

Looking at the Prettier docs, there is a tip to base your .prettierignore file on your .gitignore file.

https://prettier.io/docs/en/install.html

Tip! Base your .prettierignore on .gitignore and .eslintignore (if you have one).

Can someone explain what this means and how to do this? Is there a way to automatically add everything to your .prettierignore included in your .gitignore?

like image 789
alanrzhang Avatar asked Dec 13 '22 07:12

alanrzhang


2 Answers

You can actually pass a flag to your prettier command --ignore-path and then give it the path of your .gitignore file so it will use that instead of the .prettierignore file.

prettier --ignore-path .gitignore
like image 144
Stanley Thijssen Avatar answered Dec 18 '22 00:12

Stanley Thijssen


They're not implying there's an automatic way to do this, but you could cp .gitignore .prettierignore (or copy it some other way, such as in your IDE). There is a proposal to include other ignore files as well as a node tool to automate this for you if you want to, though.

like image 25
Zac Anger Avatar answered Dec 17 '22 23:12

Zac Anger