diff --git a/src/discover/registry.rs b/src/discover/registry.rs index 81b170785a..3b5498fd91 100644 --- a/src/discover/registry.rs +++ b/src/discover/registry.rs @@ -3176,16 +3176,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", @@ -3194,10 +3190,8 @@ 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", @@ -3206,7 +3200,6 @@ mod tests { "npx lint", "pnpm biome", "pnpm eslint", - "pnpm lint", "pnpx biome", "pnpx eslint", "pnpx lint", @@ -3236,16 +3229,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", @@ -3254,10 +3243,8 @@ 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", @@ -3266,7 +3253,6 @@ mod tests { "npx lint", "pnpm biome", "pnpm eslint", - "pnpm lint", "pnpx biome", "pnpx eslint", "pnpx lint", @@ -3284,6 +3270,26 @@ mod tests { } } + #[test] + fn test_rewrite_lint_scripts_delegate_to_package_manager() { + let commands = vec![ + ("npm run lint", "rtk npm run lint"), + ("npm run-script lint", "rtk npm run-script lint"), + ("pnpm run lint", "rtk pnpm run lint"), + ("pnpm run-script lint", "rtk pnpm run-script lint"), + ("pnpm lint", "rtk pnpm lint"), + ]; + + for (command, expected) in commands { + assert_eq!( + rewrite_command_no_prefixes(command, &[]), + Some(expected.into()), + "Failed for command: {}", + command + ); + } + } + #[test] fn test_classify_jest() { let commands = vec![ diff --git a/src/discover/rules.rs b/src/discover/rules.rs index 49c0ff740a..1997f89dad 100644 --- a/src/discover/rules.rs +++ b/src/discover/rules.rs @@ -79,7 +79,7 @@ pub const RULES: &[RtkRule] = &[ ..RtkRule::DEFAULT }, RtkRule { - pattern: r"^pnpm\s+(exec|i|install|list|ls|outdated|run|run-script)", + pattern: r"^pnpm\s+(exec|i|install|list|ls|outdated|run|run-script|lint)(\s|$)", rtk_cmd: "rtk pnpm", rewrite_prefixes: &["pnpm"], category: "PackageManager", @@ -168,7 +168,7 @@ 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"^((npx|pnpx|p?npm\s+exec|npm\s+x|pnpm\s+dlx)\s+)?(biome|eslint|lint)(\s|$)|^(?:npm|pnpm)\s+(?:biome|eslint)(\s|$)|^npm\s+lint(\s|$)|^p?npm\s+(?:run|run-script|rum|urn)\s+(?:biome|eslint)(\s|$)", rtk_cmd: "rtk lint", rewrite_prefixes: &[ "biome", @@ -181,16 +181,12 @@ pub const RULES: &[RtkRule] = &[ "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", @@ -202,13 +198,10 @@ pub const RULES: &[RtkRule] = &[ "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",