0

I've been researching option three of this document:

enter image description here

My goal is to run prettier on commit.

The thing is, the root directory of my project looks like this:

root/
   .git/
       ...
   subdir/
       directory_with_javascript/
                  .prettierrc.json
   ...

I haven't been able to find an example anywhere that explains how to run pre-commit in a subdirectory. I've tried a bunch of things like setting up pre-commit in the subdirectory, but when I commit, it says it can't find the .pre-commit-config.yaml file. And if I put it at the root, it complains about not being able to find code to pretty-ify.

Can someone show me an example of using pre-commit to run prettier in a subdirectory?

anthony sottile
  • 61,815
  • 15
  • 148
  • 207
Daniel Kaplan
  • 62,768
  • 50
  • 234
  • 356
  • 1
    Do you mean specifically the [pre-commit.com](https://pre-commit.com/) Git pre-commit hooks here? The name `pre-commit` could refer to just any old Git pre-commit hook; Git itself doesn't use yaml at all, and doesn't come with fancy pre-commit hooks like this. ... Aha, yes, clicking through the links shows that you *do* mean pre-commit.com. Go there and read the documentation. I don't know how to configure it properly myself, but the docs look extensive and clear. – torek Aug 10 '21 at 19:57
  • @torek pre-commit.com. I've already read the documentation. They are clear, but I'd argue not very extensive. – Daniel Kaplan Aug 10 '21 at 20:59
  • 1
    @AnthonySottile it does. Thanks – Daniel Kaplan Aug 10 '21 at 23:04

0 Answers0