Automate formatting during commit with Husky

From Logic Wiki
Jump to: navigation, search


Installing Husky

https://typicode.github.io/husky/get-started.html

bun add --dev husky
bunx husky init
bun add -d lint-staged

create a file in the root named : .lintstagedrc

{
    "*.{js,ts,tsx,json,css,md}": "prettier --write"
}

When a commit happens for the given extensions, run prettier for them

And in /.husky/pre-commit file write this

bunx lint-staged