I have the following pre-commit hook:
repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.6
hooks:
- id: clang-format
While in the past I have seen pre-commit skip over non-CPP files, a coworker just showed me an example with many .js files where it did try to format all of them - resulting in a complete mess.
How do I prevent pre-commit or the clang-format itself from running on these files?
Or preferably just have it only run on certain extensions (.c/.cpp/.h/.hpp/.cxx/etc)
Pre-commit has files
but I don't understand how to use it for this (would it be regex?), and I always seem to get something about the formatting wrong. Does it go a nested level under the clang-format line? Or at the same level as it? Or at the uppermost level of "repos"?
Would it just be the following?
repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.6
hooks:
- id: clang-format
files: '(some regex here)'