From 81d658a87105434835016ae20b24ef3cb7617d86 Mon Sep 17 00:00:00 2001 From: Noel Sabia Date: Sun, 18 Oct 2026 19:25:06 +0200 Subject: [PATCH] fix: pass staged filenames to the eslint pre-commit hook Validated from review comment 82 on this PR: the 'bash -c' wrapper consumed the first staged filename as $0 and the command never referenced $@, so eslint received zero file arguments and linted the whole repo - --fix silently rewrote unstaged files and WIP lint errors blocked unrelated commits. The entry now receives filenames directly from pre-commit (empirically verified with an arg probe); documented the re-stage loop for --fix and dropped the redundant 'types: [file]' filter. --- .pre-commit-config.yaml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 958fb03..a38845b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -55,15 +55,22 @@ repos: # --------------------------------------------------------- ESLint (Nuxt) - # Local hook: needs `pnpm install` to have run in this repo. --fix makes - # it a helper; only staged files are linted (fast). + # it a helper; only staged files are linted (fast). When --fix rewrites + # a staged file, pre-commit aborts the commit ("files were modified") - + # re-stage and commit again; that re-stage loop is the standard price + # of a fixer hook. - repo: local hooks: - id: eslint name: eslint --fix (staged files) - entry: bash -c 'pnpm exec eslint --fix' + # no shell wrapper: pre-commit appends the staged filenames to the + # entry itself. A 'bash -c' wrapper would eat the first filename + # as $0 and eslint would get no file arguments at all (linting the + # whole repo instead - review finding on this PR, empirically + # verified). + entry: pnpm exec eslint --fix language: system files: \.(vue|ts|js|mjs|cjs)$ - types: [file] # When Go services arrive, add: # - repo: https://github.com/dnephin/pre-commit-golang