I am referring to a tutorial on how to set up a Husky pre-commit hook for Prettier in a new Angular project. I want the project files to be automatically formatted to match the committed files, but it seems like something may be missing.
The tutorial suggests configuring Husky like this:
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.ts": [
"prettier - write",
"git add"
]
},
After installing Husky and Prettier with npm i -D husky prettier, I created a src/app/test.ts file to test it out. However, nothing happened when I tried to commit the unformatted content of test.ts file.
How can we make sure that the pre-commit hook is triggered to format the files before committing?