From 5f42886e71d82678f6ec3deb6436e8b91b0b5045 Mon Sep 17 00:00:00 2001 From: guyoron1 Date: Sun, 27 Sep 2026 06:43:24 +0300 Subject: [PATCH 1/2] fix(lint): remove `lint` script name from lint rewrite rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `pnpm lint` and `npm run lint` were rewritten to `rtk lint`, discarding the package.json script's own flags, chains, and exit code. Direct linter invocations (`eslint`, `biome`) continue to route through rtk lint; only the bare script-name variants are dropped from the rule. Fixes #2094 Split out of a larger commit that also removed NPM_SUBCOMMANDS from npm_cmd.rs (fixes #2663) — that half is dropped here since #2663 was independently closed by 56519c49 (extending the allowlist instead of removing it), and unconditionally deleting the allowlist would also regress the "assume script name" convenience 56519c49's approach kept. --- src/discover/registry.rs | 75 ++++++++++++++++++++++++++++------------ src/discover/rules.rs | 13 +------ 2 files changed, 54 insertions(+), 34 deletions(-) diff --git a/src/discover/registry.rs b/src/discover/registry.rs index 6c59b9946e..8cc8390d67 100644 --- a/src/discover/registry.rs +++ b/src/discover/registry.rs @@ -5482,16 +5482,12 @@ mod tests { "npm exec eslint", "npm rum biome", "npm rum eslint", - "npm rum lint", "npm run biome", "npm run eslint", - "npm run lint", "npm run-script biome", "npm run-script eslint", - "npm run-script lint", "npm urn biome", "npm urn eslint", - "npm urn lint", "npm x biome", "npm x eslint", "pnpm dlx biome", @@ -5500,25 +5496,18 @@ mod tests { "pnpm exec eslint", "pnpm run biome", "pnpm run eslint", - "pnpm run lint", "pnpm run-script biome", "pnpm run-script eslint", - "pnpm run-script lint", "npm biome", "npm eslint", - "npm lint", "npx biome", "npx eslint", - "npx lint", "pnpm biome", "pnpm eslint", - "pnpm lint", "pnpx biome", "pnpx eslint", - "pnpx lint", "biome", "eslint", - "lint", ]; for command in commands { assert!( @@ -5535,6 +5524,36 @@ mod tests { } } + #[test] + fn test_classify_lint_scripts_not_rewritten() { + let script_commands = vec![ + "lint", + "npm lint", + "npm run lint", + "npm rum lint", + "npm urn lint", + "npm run-script lint", + "npx lint", + "pnpm lint", + "pnpm run lint", + "pnpm run-script lint", + "pnpx lint", + ]; + for command in script_commands { + assert!( + !matches!( + classify_command(command), + Classification::Supported { + rtk_equivalent: "rtk lint", + .. + } + ), + "'{}' should NOT classify as rtk lint (it's a script, not a linter binary)", + command + ); + } + } + #[test] fn test_rewrite_lint() { let commands = vec![ @@ -5542,16 +5561,12 @@ mod tests { "npm exec eslint", "npm rum biome", "npm rum eslint", - "npm rum lint", "npm run biome", "npm run eslint", - "npm run lint", "npm run-script biome", "npm run-script eslint", - "npm run-script lint", "npm urn biome", "npm urn eslint", - "npm urn lint", "npm x biome", "npm x eslint", "pnpm dlx biome", @@ -5560,25 +5575,18 @@ mod tests { "pnpm exec eslint", "pnpm run biome", "pnpm run eslint", - "pnpm run lint", "pnpm run-script biome", "pnpm run-script eslint", - "pnpm run-script lint", "npm biome", "npm eslint", - "npm lint", "npx biome", "npx eslint", - "npx lint", "pnpm biome", "pnpm eslint", - "pnpm lint", "pnpx biome", "pnpx eslint", - "pnpx lint", "biome", "eslint", - "lint", ]; for command in commands { assert_eq!( @@ -5590,6 +5598,29 @@ mod tests { } } + #[test] + fn test_rewrite_lint_scripts_not_rewritten_to_rtk_lint() { + let script_commands = vec![ + "lint", + "npm lint", + "npm run lint", + "pnpm lint", + "pnpm run lint", + "npx lint", + "pnpx lint", + ]; + for command in script_commands { + let result = rewrite_command_no_prefixes(command, &[]); + assert_ne!( + result, + Some("rtk lint".into()), + "'{}' should NOT be rewritten to rtk lint (got {:?})", + command, + result + ); + } + } + #[test] fn test_classify_jest() { let commands = vec![ diff --git a/src/discover/rules.rs b/src/discover/rules.rs index 1f4025af60..d07a911cb1 100644 --- a/src/discover/rules.rs +++ b/src/discover/rules.rs @@ -206,51 +206,40 @@ pub const RULES: &[RtkRule] = &[ ..RtkRule::DEFAULT }, RtkRule { - pattern: r"^((p?np(m|x)|p?npm\s+(exec|run|run-script)|npm\s+(rum|urn|x)|pnpm\s+dlx)\s+)?(biome|eslint|lint)(\s|$)", + pattern: r"^((p?np(m|x)|p?npm\s+(exec|run|run-script)|npm\s+(rum|urn|x)|pnpm\s+dlx)\s+)?(biome|eslint)(\s|$)", rtk_cmd: "rtk lint", pipeline_safety: PipelineSafety::ProducerOnly, rewrite_prefixes: &[ "biome", "eslint", - "lint", "npm biome", "npm eslint", "npm exec biome", "npm exec eslint", - "npm lint", "npm rum biome", "npm rum eslint", - "npm rum lint", "npm run biome", "npm run eslint", - "npm run lint", "npm run-script biome", "npm run-script eslint", - "npm run-script lint", "npm urn biome", "npm urn eslint", - "npm urn lint", "npm x biome", "npm x eslint", "npx biome", "npx eslint", - "npx lint", "pnpm biome", "pnpm dlx biome", "pnpm dlx eslint", "pnpm eslint", "pnpm exec biome", "pnpm exec eslint", - "pnpm lint", "pnpm run biome", "pnpm run eslint", - "pnpm run lint", "pnpm run-script biome", "pnpm run-script eslint", - "pnpm run-script lint", "pnpx biome", "pnpx eslint", - "pnpx lint", ], category: "Build", savings_pct: 84.0, From 8a38ae4af5de418e3d6b0621390850171f63eae2 Mon Sep 17 00:00:00 2001 From: guyoron1 Date: Mon, 13 Jul 2026 15:41:24 +0300 Subject: [PATCH 2/2] fix(pnpm): add generic script routing so bare pnpm