Browse Source

Format files before commit (#4155)

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.
Sarah Fortune 7 months ago
parent
commit
0fade12e8e
3 changed files with 790 additions and 14 deletions
  1. 4 4
      .husky/pre-commit
  2. 780 10
      package-lock.json
  3. 6 0
      package.json

+ 4 - 4
.husky/pre-commit

@@ -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!"

File diff suppressed because it is too large
+ 780 - 10
package-lock.json


+ 6 - 0
package.json

@@ -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",

Some files were not shown because too many files changed in this diff