Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions src/discover/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -3206,7 +3200,6 @@ mod tests {
"npx lint",
"pnpm biome",
"pnpm eslint",
"pnpm lint",
"pnpx biome",
"pnpx eslint",
"pnpx lint",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -3266,7 +3253,6 @@ mod tests {
"npx lint",
"pnpm biome",
"pnpm eslint",
"pnpm lint",
"pnpx biome",
"pnpx eslint",
"pnpx lint",
Expand All @@ -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![
Expand Down
11 changes: 2 additions & 9 deletions src/discover/rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down
Loading