Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

chore: Allow skipping lint in pre-commit hook (#14118)

Ben Bachemad480f404010
diff --git a/.husky/pre-commit b/.husky/pre-commit
index 0576858393..49a544abc5 100755
--- a/.husky/pre-commit
+++ b/.husky/pre-commit
@@ -6,6 +6,15 @@ current_branch=$(git rev-parse --abbrev-ref HEAD)
# Define the protected branch
protected_branch="main"
+run_lint() {
+ if [ -n "${LANGFUSE_PRE_COMMIT_SKIP_LINT-}" ]; then
+ echo "Skipping lint because LANGFUSE_PRE_COMMIT_SKIP_LINT is set."
+ return 0
+ fi
+
+ pnpm run lint
+}
+
# Check if the current branch is the protected branch
if [ "$current_branch" = "$protected_branch" ]; then
echo "🚨 You are about to commit to the $protected_branch branch. Are you sure? (y/n)"
@@ -13,7 +22,7 @@ if [ "$current_branch" = "$protected_branch" ]; then
if [ "$answer" != "${answer#[Yy]}" ]; then
# Commit approved, run checks
pnpm run format:check
- pnpm run lint
+ run_lint
else
echo "Commit to $protected_branch branch has been canceled."
exit 1 # Commit will be blocked
@@ -22,4 +31,4 @@ fi
# If not the protected branch, run checks
pnpm run format:check
-pnpm run lint
+run_lint
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 8a057929c6..c1ea23ccc2 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -211,6 +211,15 @@ When you change the shared MCP setup:
pnpm run prepare # Sets up Husky pre-commit hooks for code formatting
```
+ The pre-commit hook runs formatting and lint checks. To skip only the lint
+ check for a commit, set `LANGFUSE_PRE_COMMIT_SKIP_LINT`, for example:
+
+ ```bash
+ LANGFUSE_PRE_COMMIT_SKIP_LINT=1 git commit -m "your commit message"
+ ```
+
+ CI still runs the required checks for pull requests.
+
4. Create an env file
```bash