Skip to content

chore: auto-fix eslint issues in post-edit hook#2313

Merged
rahmanunver merged 1 commit into
mainfrom
chore/post-edit-hook-eslint-fix
Jul 8, 2026
Merged

chore: auto-fix eslint issues in post-edit hook#2313
rahmanunver merged 1 commit into
mainfrom
chore/post-edit-hook-eslint-fix

Conversation

@rahmanunver

Copy link
Copy Markdown
Contributor

Pull request type

Refactoring (e.g. file rename, variable rename, etc.)


Description

What: The Claude Code / Copilot PostToolUse hook (.claude/hooks/post-edit.sh) now runs eslint --fix on the edited file after prettier --write and before the report-only lint pass.

Why: The hook previously ran prettier --write (which does not reorder imports) then a report-only pnpm run lint. Fixable eslint issues at warning severity — notably import/order — were never auto-corrected and never failed lint (warnings keep the exit code at 0). They leaked into commits and had to be fixed manually with eslint --fix.

Change: Add a single-file eslint --fix "$FILE_PATH" step, scoped and cd-ed the same way as the existing prettier step. It auto-corrects every eslint-fixable rule (import order, prefer-const, etc.) on each edit; the final pnpm run lint still gates on errors.

Verified by piping a simulated PostToolUse payload ({"tool_input":{"file_path":"…"}}) for a file with out-of-order imports through the hook — imports were reordered and the hook exited 0.

What should be covered while testing?

  1. Edit a .ts/.tsx file in a widget package so it has a fixable eslint issue (e.g. imports out of order).
  2. The hook should auto-reorder/fix on save without manual intervention.
  3. A file with a non-fixable eslint error should still be reported back (hook exits 2), unchanged behavior.

The PostToolUse hook ran prettier --write then a report-only `pnpm run lint`.
Fixable eslint issues at warning severity (e.g. import/order) were never
corrected and never failed lint, so they leaked into commits and had to be
fixed manually with `eslint --fix`.

Add an `eslint --fix "$FILE_PATH"` pass after prettier and before the
report-only lint, scoped to the edited file (matching the prettier step). This
auto-corrects all eslint-fixable rules on each edit while the final lint pass
still gates on errors.
@rahmanunver rahmanunver requested a review from a team as a code owner July 7, 2026 15:23
@rahmanunver rahmanunver merged commit 4948b71 into main Jul 8, 2026
13 of 15 checks passed
@rahmanunver rahmanunver deleted the chore/post-edit-hook-eslint-fix branch July 8, 2026 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants