fix(rewrite): route npm lint scripts through rtk npm (biome-safe)#1491
fix(rewrite): route npm lint scripts through rtk npm (biome-safe)#1491LukaPrebil wants to merge 1 commit intortk-ai:developfrom
Conversation
`npm run lint`, `npm lint`, `npm [rum|urn|x] lint`, and `npx lint` previously rewrote to `rtk lint`, which defaults to running ESLint via `npx eslint`. On Biome projects the JSON parse fails silently with exit 0, hiding real lint failures from agents. Route these through `rtk npm` / `rtk npx` instead - the generic npm filter is script-agnostic and preserves biome's real output and exit code. Mirrors rtk-ai#678's pattern for the pnpm side. Scope: - new early-return block in rewrite_segment_inner handles the npm/npx `lint` variants with env prefix and redirect suffix preserved - `split_npm_dispatch` + `match_lint_script` helpers keep the block compact - npm rule pattern extended with `|lint` + `(\s|$)` suffix so bare `npm lint` still classifies as `rtk npm` - `npm lint` / `npm run lint` / `npm run-script lint` / `npm rum|urn lint` / `npx lint` removed from lint rule's rewrite_prefixes - 12 new unit tests (incl. env-prefix, redirect, word-boundary regression against `npm lint-staged`, and asserts that bare biome / eslint still route to rtk lint) - `test_classify_lint` intentionally unchanged: classify still picks the lint rule (last-match wins), the rewrite now short-circuits to rtk npm/npx. Documented classify/rewrite drift. Out of scope (filed separately): - biome check routing through the biome TOML filter - rtk lint exit-0 on auto-defaulted ESLint JSON parse failure - package.json-aware filter dispatch for npm run scripts
Smoke test (buggy 0.37.2 vs this PR)Scratch
And rewrite coverage (
Accepted tradeoff: classify/rewrite drift
The same drift already exists for Token-savings tradeoffFor projects that really do use ESLint, Follow-up issues (will file separately)
|
📊 Automated PR Analysis
SummaryFixes a bug where Review Checklist
Linked issues: #1489 Analyzed automatically by wshm · This is an automated analysis, not a human review. |
Summary
npm [run|run-script|rum|urn|x] lint,npm lint, andnpx lintthroughrtk npm/rtk npxinstead ofrtk lint, so the ESLint JSON adapter never runs on Biome projects (was silently exiting 0 on parse failure)rewrite_segment_inner+ remove stale npm/npx entries from the lint rule'srewrite_prefixes+ extend the npm rule regex so barenpm lintstill classifies asrtk npm"lint" => lint_cmd::run(...)dispatch inmain.rswould re-introduce this bug if merged as-is; please fall through tonpm_cmd::run_scriptfor thelintscript before mergingTest plan
cargo fmt --all && cargo clippy --all-targets && cargo testrtk <command>output inspected