When I git commit. Pre-commit Husky doesn't run npx lint-staged.
In Package.json, I add husky and lint-staged.
{
"name": "bookstore",
"version": "0.1.0",
"private": true,
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"lint": "eslint src --ext .js,.jsx,.ts,.tsx",
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx}\"",
"preinstall": "npx only-allow pnpm",
"prepare": "husky install"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"lint-staged": {
"*.{html, css, tsx, jsx, ts, js}": "prettier --write",
"*.tsx": [
"eslint"
]
},
"devDependencies": {
"@types/node": "^16.18.52",
"@types/react": "^18.2.22",
"@types/react-dom": "^18.2.7",
"husky": "^8.0.3",
"lint-staged": "^14.0.1",
"prettier": "^3.0.3"
}
}
.husky/pre-commit:
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged
When I make some error and run command: npx lint-staged I got warning errors as I expected.
But when I commit the code with an error, Husky doesn't trigger git hooks npx lint-staged like it is supposed to run.

