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 a local pre-commit check.
husky
sh
npx lint-stagedlint-staged
Check
TIP
If
example1.cppandexample2.care staged, thennpx clang-format -Werror -n example1.cpp example2.cwill be executed.json{ // ... "lint-staged": { "*.{c,cpp,h}": "npx clang-format -Werror -n" } // ... }Fix
json{ // ... "lint-staged": { "*.{c,cpp,h}": "npx clang-format -i" } // ... }