Skip to content

fix: claude hook lint/format should use eslint/prettier#1071

Merged
carlosthe19916 merged 2 commits into
guacsec:mainfrom
carlosthe19916:hotfix/claude-hook
May 29, 2026
Merged

fix: claude hook lint/format should use eslint/prettier#1071
carlosthe19916 merged 2 commits into
guacsec:mainfrom
carlosthe19916:hotfix/claude-hook

Conversation

@carlosthe19916
Copy link
Copy Markdown
Collaborator

@carlosthe19916 carlosthe19916 commented May 29, 2026

Summary

This PR aligns tooling usage in the lint/format hook of claude code. Not it is using eslint/prettier instead of biome

Type of Change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation
  • Other (describe below)

Summary by Sourcery

Enhancements:

  • Run eslint and prettier on TypeScript, JavaScript, and JSON files in the Claude lint-and-format hook, replacing the previous Biome-based check.

Signed-off-by: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com>
@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented May 29, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR updates the Claude lint/format hook to stop using Biome and instead run ESLint and Prettier directly on changed files, with behavior varying by file type while preserving existing workspace-based TypeScript type checking.

Sequence diagram for updated Claude lint-and-format hook using ESLint/Prettier

sequenceDiagram
  actor ClaudeHook
  participant lint_and_format_sh
  participant ESLint
  participant Prettier

  ClaudeHook->>lint_and_format_sh: run_lint_and_format
  activate lint_and_format_sh

  alt TypeScript_file_ts_tsx
    lint_and_format_sh->>ESLint: npx_eslint_fix
    ESLint-->>lint_and_format_sh: eslint_output
    lint_and_format_sh->>Prettier: npx_prettier_write
    Prettier-->>lint_and_format_sh: prettier_output
  else JavaScript_or_JSON_file_js_json
    lint_and_format_sh->>Prettier: npx_prettier_write
    Prettier-->>lint_and_format_sh: prettier_output
  end

  lint_and_format_sh-->>ClaudeHook: lint_and_format_result
Loading

File-Level Changes

Change Details Files
Replace Biome-based lint/format step in Claude hook with eslint/prettier flows based on file extension.
  • Remove Biome check/format invocation that previously ran on the modified file
  • Introduce a case statement that routes .ts/.tsx files through eslint --fix followed by prettier with project .prettierignore
  • Add a Prettier-only path for .js and .json files using the same .prettierignore configuration
  • Keep existing workspace detection and TypeScript type-checking logic unchanged
.claude/hooks/lint-and-format.sh

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown
Contributor

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 1 issue, and left some high level feedback:

  • Since the repo appears to be workspace-based (client/server), consider running eslint and prettier from the detected workspace root (e.g., cd "$WORKSPACE") so they pick up workspace-specific configs instead of only the repo root configuration.
  • The new case statement only formats .ts, .tsx, .js, and .json; if Biome previously handled additional extensions (e.g., .cjs, .mjs, config files), it may be worth explicitly deciding whether those should still be linted/formatted and updating the patterns accordingly.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Since the repo appears to be workspace-based (client/server), consider running `eslint` and `prettier` from the detected workspace root (e.g., `cd "$WORKSPACE"`) so they pick up workspace-specific configs instead of only the repo root configuration.
- The new case statement only formats `.ts`, `.tsx`, `.js`, and `.json`; if Biome previously handled additional extensions (e.g., `.cjs`, `.mjs`, config files), it may be worth explicitly deciding whether those should still be linted/formatted and updating the patterns accordingly.

## Individual Comments

### Comment 1
<location path=".claude/hooks/lint-and-format.sh" line_range="45-52" />
<code_context>
+      echo "⚠️  Prettier found issues in $FILE_PATH" >&2
+    fi
+    ;;
+  *.js|*.json)
+    echo "🎨 Formatting: $FILE_PATH" >&2
+    if ! npx prettier --write --ignore-path "$CLAUDE_PROJECT_DIR/.prettierignore" "$FILE_PATH" 2>&1; then
+      echo "⚠️  Prettier found issues in $FILE_PATH" >&2
+    fi
+    ;;
+esac
+
</code_context>
<issue_to_address>
**suggestion:** Consider running ESLint on .js files as well to keep linting behavior consistent.

Currently .ts/.tsx files are linted with ESLint and formatted with Prettier, while .js files are only formatted. If JS is expected to follow the same rules, consider including .js in the ESLint case (or adding a separate one) so JS changes don’t skip lint checks.

```suggestion
  *.js)
    echo "🎨 Linting and formatting: $FILE_PATH" >&2
    if ! npx eslint --fix "$FILE_PATH" 2>&1; then
      echo "⚠️  ESLint found issues in $FILE_PATH" >&2
    fi
    if ! npx prettier --write --ignore-path "$CLAUDE_PROJECT_DIR/.prettierignore" "$FILE_PATH" 2>&1; then
      echo "⚠️  Prettier found issues in $FILE_PATH" >&2
    fi
    ;;
  *.json)
    echo "🎨 Formatting: $FILE_PATH" >&2
    if ! npx prettier --write --ignore-path "$CLAUDE_PROJECT_DIR/.prettierignore" "$FILE_PATH" 2>&1; then
      echo "⚠️  Prettier found issues in $FILE_PATH" >&2
    fi
    ;;
esac

```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +45 to +52
*.js|*.json)
echo "🎨 Formatting: $FILE_PATH" >&2
if ! npx prettier --write --ignore-path "$CLAUDE_PROJECT_DIR/.prettierignore" "$FILE_PATH" 2>&1; then
echo "⚠️ Prettier found issues in $FILE_PATH" >&2
fi
;;
esac

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider running ESLint on .js files as well to keep linting behavior consistent.

Currently .ts/.tsx files are linted with ESLint and formatted with Prettier, while .js files are only formatted. If JS is expected to follow the same rules, consider including .js in the ESLint case (or adding a separate one) so JS changes don’t skip lint checks.

Suggested change
*.js|*.json)
echo "🎨 Formatting: $FILE_PATH" >&2
if ! npx prettier --write --ignore-path "$CLAUDE_PROJECT_DIR/.prettierignore" "$FILE_PATH" 2>&1; then
echo "⚠️ Prettier found issues in $FILE_PATH" >&2
fi
;;
esac
*.js)
echo "🎨 Linting and formatting: $FILE_PATH" >&2
if ! npx eslint --fix "$FILE_PATH" 2>&1; then
echo "⚠️ ESLint found issues in $FILE_PATH" >&2
fi
if ! npx prettier --write --ignore-path "$CLAUDE_PROJECT_DIR/.prettierignore" "$FILE_PATH" 2>&1; then
echo "⚠️ Prettier found issues in $FILE_PATH" >&2
fi
;;
*.json)
echo "🎨 Formatting: $FILE_PATH" >&2
if ! npx prettier --write --ignore-path "$CLAUDE_PROJECT_DIR/.prettierignore" "$FILE_PATH" 2>&1; then
echo "⚠️ Prettier found issues in $FILE_PATH" >&2
fi
;;
esac

@codecov
Copy link
Copy Markdown

codecov Bot commented May 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.66%. Comparing base (16a6bec) to head (00c2c68).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1071      +/-   ##
==========================================
- Coverage   50.68%   50.66%   -0.02%     
==========================================
  Files         253      253              
  Lines        5499     5499              
  Branches     1660     1660              
==========================================
- Hits         2787     2786       -1     
- Misses       2440     2441       +1     
  Partials      272      272              
Flag Coverage Δ
e2e 68.91% <ø> (-0.03%) ⬇️
unit 2.01% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@carlosthe19916 carlosthe19916 enabled auto-merge May 29, 2026 11:51
@carlosthe19916 carlosthe19916 added this pull request to the merge queue May 29, 2026
Merged via the queue into guacsec:main with commit 746ee90 May 29, 2026
14 checks passed
@github-project-automation github-project-automation Bot moved this to Done in Trustify May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants