fix: claude hook lint/format should use eslint/prettier#1071
Conversation
Signed-off-by: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThis 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/PrettiersequenceDiagram
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
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- Since the repo appears to be workspace-based (client/server), consider running
eslintandprettierfrom 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>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| *.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 | ||
|
|
There was a problem hiding this comment.
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.
| *.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 Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
Summary by Sourcery
Enhancements: