In my Next project I'm trying to use husky pre-commit to reformat my code before committing. Whenever I commit, the code is reformatted but it is only applied after the commit. So after this reformat I have to commit again.
This is the pre-commit file
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npm run lint:fix
My package.json
{
"scripts": {
"lint": "next lint",
"lint:fix": "next lint --fix",
},
"devDependencies": {
"eslint": "8.10.0",
"eslint-config-next": "12.1.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.4"
}
}
Is there a way to make the pre-commit hook finish before the actual commit?