JS: use clang-format-launcher to clang-format your project with ease

Canhua Li
Dec 8, 2021

--

If your project is very complex, you may run into these situation:

  1. Aglob pattern is not enough to filter the files in your project. For example, it has a lot of generated files need to be excluded.
  2. The formatting is very slow.

If that’s the case, you may try clang-format-launcher which is a wrapper of clang-format, but ease you from handling complex glob rules by yourself.

clang-format-launcher runs git ls-tree -r — name-only — full-tree HEAD first to get the list of files which is checked into, then filter the files with predefined rules in package.json or clang.format.json. Below is an example to support npm run format to format your project and npm run verify to verify the format in pipeline.

clang-format-launcher config in package.json
clang-format-launcher scripts
dependencies

--

--