Use with husky
and lint-staged
Ensuring that changes to your code are properly formatted is an important part of your development workflow. Use husky
and lint-staged
for your continuous integration process.
husky
v8.x
sh
npx lint-staged
lint-staged
v15.x
Check
TIP
If
example1.cpp
andexample2.c
are staged, thennpx clang-format -Werror -n example1.cpp example2.c
will be excuted.json{ // ... "lint-staged": { "*.{c,cpp,h}": "npx clang-format -Werror -n", } // ... }
Fix
json{ // ... "lint-staged": { "*.{c,cpp,h}": "npx clang-format -i", } // ... }