Instead of doing a prettier check in the pre-commit, just format the staged changes. Use the package lint-stage to handle only formatting staged changes.
@@ -9,9 +9,9 @@ npm run lint || {
# Run Prettier
echo "Running Prettier..."
-npm run format || {
- echo "❌ Prettier check failed. Run 'npm run format:fix' to automatically fix formatting issues."
- exit 1
-}
+npx lint-staged --verbose || {
+ echo "❌ Prettier failed. Please fix the errors and try committing again."
+ exit 1
+ }
echo "✅ All checks passed!"
@@ -358,6 +358,11 @@
"docs:rename-file": "cd docs && mintlify rename",
"report-issue": "node scripts/report-issue.js"
},
+ "lint-staged": {
+ "*": [
+ "prettier --write --ignore-unknown --log-level=log"
+ ]
+ },
"devDependencies": {
"@changesets/cli": "^2.27.12",
"@types/chai": "^5.0.1",
@@ -384,6 +389,7 @@
"eslint-plugin-eslint-rules": "file:eslint-rules",
"grpc-tools": "^1.13.0",
"husky": "^9.1.7",
+ "lint-staged": "^16.1.0",
"mintlify": "^4.0.515",
"npm-run-all": "^4.1.5",
"prettier": "^3.3.3",