`npm run lint` is rewritten to `rtk lint`, which discards the script's target and lints gitignored paths (false exit 1 on a tree whose own gate exits 0)
The hook rewrites npm run lint to rtk lint. rtk lint does not run the script the package defines; it runs its own eslint invocation over the working directory. On a repo whose lint script scopes eslint to one directory, that means rtk lints paths the project deliberately excludes, including gitignored build output, and reports errors against files the project's gate never looks at.
The project gate passes and rtk reports four errors on the same tree, in the same second.
Repro
package.json:
"lint": "eslint packages --max-warnings=0"
$ npm run lint
> eslint packages --max-warnings=0
$ echo $?
0
$ rtk lint
ESLint: 4 errors, 0 warnings in 3 files
═══════════════════════════════════════
Top rules:
@typescript-eslint/no-unused-vars (4x)
Top files:
curve.mts (2 issues)
@typescript-eslint/no-unused-vars (2)
measure.mts (1 issues)
@typescript-eslint/no-unused-vars (1)
sweep.mts (1 issues)
@typescript-eslint/no-unused-vars (1)
$ echo $?
1
The three files it blames are scratch output, excluded from the repo:
$ git check-ignore -v out/scratch-setgen/sweep.mts
.gitignore:48:out/ out/scratch-setgen/sweep.mts
None of them is under packages/, which is the only path the lint script passes to eslint.
Confirming the rewrite is what produces this:
$ rtk hook check "npm run lint"
rtk lint
$ rtk hook check "npx eslint packages"
rtk lint packages
Why this one bites harder than a formatting difference
The output is not noisy, it is wrong, and it is wrong in the direction that costs work. An agent running the repo's gates reads four eslint errors, goes looking for sweep.mts, and finds a file that is not in the repository. In my case four parallel build agents were each about to run this gate against a tree whose real lint status was clean.
npm test is not rewritten, so test counts stayed trustworthy the whole time. That contrast is the useful signal: the commands rtk passes through are the ones that kept their meaning.
Root cause, as far as I can see from the outside
rtk lint appears to be a standalone eslint runner keyed on the command name rather than a filter wrapped around the script the project defined. The script's target (packages) and its flags (--max-warnings=0) are both dropped. rtk hook check "npx eslint packages" keeps the positional argument, so the argument handling exists; the npm run <script> path never reaches it, because the script body is never read.
Two candidate fixes
-
Run the script, filter the output. Execute
npm run lintas written and apply the eslint output filter to what it prints. This is whatnpm testalready does by not being rewritten, and it is correct for every repo regardless of which linter the script drives, which also closes the class in #3010 and #3398 rather than one instance of it. -
Read the script body and carry its arguments across. If the substitution stays, resolve
lintinpackage.json, confirm it invokes eslint, and pass its targets and flags through tortk lint. Falling back to passthrough when the script is anything other than a plain eslint call keeps the astro/oxlint/Biome cases correct.
Failing both, rtk lint should at minimum respect .gitignore, which would have removed all four errors here.
Adjacent, not the same
- #3010 (closed as duplicate) is
rtk linthardcoding eslint against repos that use oxlint or Biome. This repo does use eslint; the substitute runs the right tool over the wrong scope. - #3398 (closed) is the filter assuming eslint JSON when the script is
astro check. - #3516 is the
pnpm run <script>rewrite producing an invalid subcommand. Same seam, opposite symptom: that one applies no filtering, this one applies a different command.
Environment
- rtk 0.39.0, installed at
~/.local/bin/rtk - Linux, bash, npm workspaces, eslint flat config, TypeScript
- Hook active:
rtk hook claudeas a Claude Code PreToolUse hook
Workaround
[hooks]
exclude_commands = ["npm run lint", "npx eslint", "eslint"]
That restores the real gate and gives up the filtering on it.
wshm · Automated triage by AI
🔍 Automated Triage
| 🐛 Category | bug |
| 🟠 Priority | high |
| 🎯 Confidence | 90% |
Summary
npm run lint hook rewrite substitutes a standalone rtk lint that ignores the script's target/flags and .gitignore, producing false eslint failures on a clean tree; needs to either passthrough+filter or carry script args into the substitute command.
📁 Relevant files
src/hook/rewrite.rssrc/commands/lint.rs
Triaged automatically by wshm · This is an automated analysis, not a human review.
Closing as a duplicate of #1489, which tracks the same problem with the more complete discussion. Please follow up there; if your case differs in a way that issue does not cover, comment here and it can be reopened.