@hasna/terminal 2.3.0 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/App.js +404 -0
- package/dist/Browse.js +79 -0
- package/dist/FuzzyPicker.js +47 -0
- package/dist/Onboarding.js +51 -0
- package/dist/Spinner.js +12 -0
- package/dist/StatusBar.js +49 -0
- package/dist/ai.js +322 -0
- package/dist/cache.js +41 -0
- package/dist/cli.js +64 -16
- package/dist/command-rewriter.js +64 -0
- package/dist/command-validator.js +86 -0
- package/dist/compression.js +107 -0
- package/dist/context-hints.js +275 -0
- package/dist/diff-cache.js +107 -0
- package/dist/discover.js +212 -0
- package/dist/economy.js +123 -0
- package/dist/expand-store.js +38 -0
- package/dist/file-cache.js +72 -0
- package/dist/file-index.js +62 -0
- package/dist/history.js +62 -0
- package/dist/lazy-executor.js +54 -0
- package/dist/line-dedup.js +59 -0
- package/dist/loop-detector.js +75 -0
- package/dist/mcp/install.js +98 -0
- package/dist/mcp/server.js +569 -0
- package/dist/noise-filter.js +86 -0
- package/dist/output-processor.js +129 -0
- package/dist/output-router.js +41 -0
- package/dist/output-store.js +111 -0
- package/dist/parsers/base.js +2 -0
- package/dist/parsers/build.js +64 -0
- package/dist/parsers/errors.js +101 -0
- package/dist/parsers/files.js +78 -0
- package/dist/parsers/git.js +99 -0
- package/dist/parsers/index.js +48 -0
- package/dist/parsers/tests.js +89 -0
- package/dist/providers/anthropic.js +39 -0
- package/dist/providers/base.js +4 -0
- package/dist/providers/cerebras.js +95 -0
- package/dist/providers/groq.js +95 -0
- package/dist/providers/index.js +73 -0
- package/dist/providers/xai.js +95 -0
- package/dist/recipes/model.js +20 -0
- package/dist/recipes/storage.js +136 -0
- package/dist/search/content-search.js +68 -0
- package/dist/search/file-search.js +61 -0
- package/dist/search/filters.js +34 -0
- package/dist/search/index.js +5 -0
- package/dist/search/semantic.js +320 -0
- package/dist/session-boot.js +59 -0
- package/dist/session-context.js +55 -0
- package/dist/sessions-db.js +173 -0
- package/dist/smart-display.js +286 -0
- package/dist/snapshots.js +51 -0
- package/dist/supervisor.js +112 -0
- package/dist/test-watchlist.js +131 -0
- package/dist/tool-profiles.js +122 -0
- package/dist/tree.js +94 -0
- package/dist/usage-cache.js +65 -0
- package/package.json +8 -1
- package/src/ai.ts +8 -0
- package/src/cli.tsx +57 -18
- package/src/output-processor.ts +6 -1
- package/src/output-store.ts +58 -12
- package/src/tool-profiles.ts +139 -0
- package/.claude/scheduled_tasks.lock +0 -1
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -20
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -14
- package/CONTRIBUTING.md +0 -80
- package/benchmarks/benchmark.mjs +0 -115
- package/imported_modules.txt +0 -0
- package/temp/rtk/.claude/agents/code-reviewer.md +0 -221
- package/temp/rtk/.claude/agents/debugger.md +0 -519
- package/temp/rtk/.claude/agents/rtk-testing-specialist.md +0 -461
- package/temp/rtk/.claude/agents/rust-rtk.md +0 -511
- package/temp/rtk/.claude/agents/technical-writer.md +0 -355
- package/temp/rtk/.claude/commands/diagnose.md +0 -352
- package/temp/rtk/.claude/commands/test-routing.md +0 -362
- package/temp/rtk/.claude/hooks/bash/pre-commit-format.sh +0 -16
- package/temp/rtk/.claude/hooks/rtk-rewrite.sh +0 -70
- package/temp/rtk/.claude/hooks/rtk-suggest.sh +0 -152
- package/temp/rtk/.claude/rules/cli-testing.md +0 -526
- package/temp/rtk/.claude/skills/issue-triage/SKILL.md +0 -348
- package/temp/rtk/.claude/skills/issue-triage/templates/issue-comment.md +0 -134
- package/temp/rtk/.claude/skills/performance.md +0 -435
- package/temp/rtk/.claude/skills/pr-triage/SKILL.md +0 -315
- package/temp/rtk/.claude/skills/pr-triage/templates/review-comment.md +0 -71
- package/temp/rtk/.claude/skills/repo-recap.md +0 -206
- package/temp/rtk/.claude/skills/rtk-tdd/SKILL.md +0 -78
- package/temp/rtk/.claude/skills/rtk-tdd/references/testing-patterns.md +0 -124
- package/temp/rtk/.claude/skills/security-guardian.md +0 -503
- package/temp/rtk/.claude/skills/ship.md +0 -404
- package/temp/rtk/.github/workflows/benchmark.yml +0 -34
- package/temp/rtk/.github/workflows/dco-check.yaml +0 -12
- package/temp/rtk/.github/workflows/release-please.yml +0 -51
- package/temp/rtk/.github/workflows/release.yml +0 -343
- package/temp/rtk/.github/workflows/security-check.yml +0 -135
- package/temp/rtk/.github/workflows/validate-docs.yml +0 -78
- package/temp/rtk/.release-please-manifest.json +0 -3
- package/temp/rtk/ARCHITECTURE.md +0 -1491
- package/temp/rtk/CHANGELOG.md +0 -640
- package/temp/rtk/CLAUDE.md +0 -605
- package/temp/rtk/CONTRIBUTING.md +0 -199
- package/temp/rtk/Cargo.lock +0 -1668
- package/temp/rtk/Cargo.toml +0 -64
- package/temp/rtk/Formula/rtk.rb +0 -43
- package/temp/rtk/INSTALL.md +0 -390
- package/temp/rtk/LICENSE +0 -21
- package/temp/rtk/README.md +0 -386
- package/temp/rtk/README_es.md +0 -159
- package/temp/rtk/README_fr.md +0 -197
- package/temp/rtk/README_ja.md +0 -159
- package/temp/rtk/README_ko.md +0 -159
- package/temp/rtk/README_zh.md +0 -167
- package/temp/rtk/ROADMAP.md +0 -15
- package/temp/rtk/SECURITY.md +0 -217
- package/temp/rtk/TEST_EXEC_TIME.md +0 -102
- package/temp/rtk/build.rs +0 -57
- package/temp/rtk/docs/AUDIT_GUIDE.md +0 -432
- package/temp/rtk/docs/FEATURES.md +0 -1410
- package/temp/rtk/docs/TROUBLESHOOTING.md +0 -309
- package/temp/rtk/docs/filter-workflow.md +0 -102
- package/temp/rtk/docs/images/gain-dashboard.jpg +0 -0
- package/temp/rtk/docs/tracking.md +0 -583
- package/temp/rtk/hooks/opencode-rtk.ts +0 -39
- package/temp/rtk/hooks/rtk-awareness.md +0 -29
- package/temp/rtk/hooks/rtk-rewrite.sh +0 -61
- package/temp/rtk/hooks/test-rtk-rewrite.sh +0 -442
- package/temp/rtk/install.sh +0 -124
- package/temp/rtk/release-please-config.json +0 -10
- package/temp/rtk/scripts/benchmark.sh +0 -592
- package/temp/rtk/scripts/check-installation.sh +0 -162
- package/temp/rtk/scripts/install-local.sh +0 -37
- package/temp/rtk/scripts/rtk-economics.sh +0 -137
- package/temp/rtk/scripts/test-all.sh +0 -561
- package/temp/rtk/scripts/test-aristote.sh +0 -227
- package/temp/rtk/scripts/test-tracking.sh +0 -79
- package/temp/rtk/scripts/update-readme-metrics.sh +0 -32
- package/temp/rtk/scripts/validate-docs.sh +0 -73
- package/temp/rtk/src/aws_cmd.rs +0 -880
- package/temp/rtk/src/binlog.rs +0 -1645
- package/temp/rtk/src/cargo_cmd.rs +0 -1727
- package/temp/rtk/src/cc_economics.rs +0 -1157
- package/temp/rtk/src/ccusage.rs +0 -340
- package/temp/rtk/src/config.rs +0 -187
- package/temp/rtk/src/container.rs +0 -855
- package/temp/rtk/src/curl_cmd.rs +0 -134
- package/temp/rtk/src/deps.rs +0 -268
- package/temp/rtk/src/diff_cmd.rs +0 -367
- package/temp/rtk/src/discover/mod.rs +0 -274
- package/temp/rtk/src/discover/provider.rs +0 -388
- package/temp/rtk/src/discover/registry.rs +0 -2022
- package/temp/rtk/src/discover/report.rs +0 -202
- package/temp/rtk/src/discover/rules.rs +0 -667
- package/temp/rtk/src/display_helpers.rs +0 -402
- package/temp/rtk/src/dotnet_cmd.rs +0 -1771
- package/temp/rtk/src/dotnet_format_report.rs +0 -133
- package/temp/rtk/src/dotnet_trx.rs +0 -593
- package/temp/rtk/src/env_cmd.rs +0 -204
- package/temp/rtk/src/filter.rs +0 -462
- package/temp/rtk/src/filters/README.md +0 -52
- package/temp/rtk/src/filters/ansible-playbook.toml +0 -34
- package/temp/rtk/src/filters/basedpyright.toml +0 -47
- package/temp/rtk/src/filters/biome.toml +0 -45
- package/temp/rtk/src/filters/brew-install.toml +0 -37
- package/temp/rtk/src/filters/composer-install.toml +0 -40
- package/temp/rtk/src/filters/df.toml +0 -16
- package/temp/rtk/src/filters/dotnet-build.toml +0 -64
- package/temp/rtk/src/filters/du.toml +0 -16
- package/temp/rtk/src/filters/fail2ban-client.toml +0 -15
- package/temp/rtk/src/filters/gcc.toml +0 -49
- package/temp/rtk/src/filters/gcloud.toml +0 -22
- package/temp/rtk/src/filters/hadolint.toml +0 -24
- package/temp/rtk/src/filters/helm.toml +0 -29
- package/temp/rtk/src/filters/iptables.toml +0 -27
- package/temp/rtk/src/filters/jj.toml +0 -28
- package/temp/rtk/src/filters/jq.toml +0 -24
- package/temp/rtk/src/filters/make.toml +0 -41
- package/temp/rtk/src/filters/markdownlint.toml +0 -24
- package/temp/rtk/src/filters/mix-compile.toml +0 -27
- package/temp/rtk/src/filters/mix-format.toml +0 -15
- package/temp/rtk/src/filters/mvn-build.toml +0 -44
- package/temp/rtk/src/filters/oxlint.toml +0 -43
- package/temp/rtk/src/filters/ping.toml +0 -63
- package/temp/rtk/src/filters/pio-run.toml +0 -40
- package/temp/rtk/src/filters/poetry-install.toml +0 -50
- package/temp/rtk/src/filters/pre-commit.toml +0 -35
- package/temp/rtk/src/filters/ps.toml +0 -16
- package/temp/rtk/src/filters/quarto-render.toml +0 -41
- package/temp/rtk/src/filters/rsync.toml +0 -48
- package/temp/rtk/src/filters/shellcheck.toml +0 -27
- package/temp/rtk/src/filters/shopify-theme.toml +0 -29
- package/temp/rtk/src/filters/skopeo.toml +0 -45
- package/temp/rtk/src/filters/sops.toml +0 -16
- package/temp/rtk/src/filters/ssh.toml +0 -44
- package/temp/rtk/src/filters/stat.toml +0 -34
- package/temp/rtk/src/filters/swift-build.toml +0 -41
- package/temp/rtk/src/filters/systemctl-status.toml +0 -33
- package/temp/rtk/src/filters/terraform-plan.toml +0 -35
- package/temp/rtk/src/filters/tofu-fmt.toml +0 -16
- package/temp/rtk/src/filters/tofu-init.toml +0 -38
- package/temp/rtk/src/filters/tofu-plan.toml +0 -35
- package/temp/rtk/src/filters/tofu-validate.toml +0 -17
- package/temp/rtk/src/filters/trunk-build.toml +0 -39
- package/temp/rtk/src/filters/ty.toml +0 -50
- package/temp/rtk/src/filters/uv-sync.toml +0 -37
- package/temp/rtk/src/filters/xcodebuild.toml +0 -99
- package/temp/rtk/src/filters/yamllint.toml +0 -25
- package/temp/rtk/src/find_cmd.rs +0 -598
- package/temp/rtk/src/format_cmd.rs +0 -386
- package/temp/rtk/src/gain.rs +0 -723
- package/temp/rtk/src/gh_cmd.rs +0 -1651
- package/temp/rtk/src/git.rs +0 -2012
- package/temp/rtk/src/go_cmd.rs +0 -592
- package/temp/rtk/src/golangci_cmd.rs +0 -254
- package/temp/rtk/src/grep_cmd.rs +0 -288
- package/temp/rtk/src/gt_cmd.rs +0 -810
- package/temp/rtk/src/hook_audit_cmd.rs +0 -283
- package/temp/rtk/src/hook_check.rs +0 -171
- package/temp/rtk/src/init.rs +0 -1859
- package/temp/rtk/src/integrity.rs +0 -537
- package/temp/rtk/src/json_cmd.rs +0 -231
- package/temp/rtk/src/learn/detector.rs +0 -628
- package/temp/rtk/src/learn/mod.rs +0 -119
- package/temp/rtk/src/learn/report.rs +0 -184
- package/temp/rtk/src/lint_cmd.rs +0 -694
- package/temp/rtk/src/local_llm.rs +0 -316
- package/temp/rtk/src/log_cmd.rs +0 -248
- package/temp/rtk/src/ls.rs +0 -324
- package/temp/rtk/src/main.rs +0 -2482
- package/temp/rtk/src/mypy_cmd.rs +0 -389
- package/temp/rtk/src/next_cmd.rs +0 -241
- package/temp/rtk/src/npm_cmd.rs +0 -236
- package/temp/rtk/src/parser/README.md +0 -267
- package/temp/rtk/src/parser/error.rs +0 -46
- package/temp/rtk/src/parser/formatter.rs +0 -336
- package/temp/rtk/src/parser/mod.rs +0 -311
- package/temp/rtk/src/parser/types.rs +0 -119
- package/temp/rtk/src/pip_cmd.rs +0 -302
- package/temp/rtk/src/playwright_cmd.rs +0 -479
- package/temp/rtk/src/pnpm_cmd.rs +0 -573
- package/temp/rtk/src/prettier_cmd.rs +0 -221
- package/temp/rtk/src/prisma_cmd.rs +0 -482
- package/temp/rtk/src/psql_cmd.rs +0 -382
- package/temp/rtk/src/pytest_cmd.rs +0 -384
- package/temp/rtk/src/read.rs +0 -217
- package/temp/rtk/src/rewrite_cmd.rs +0 -50
- package/temp/rtk/src/ruff_cmd.rs +0 -402
- package/temp/rtk/src/runner.rs +0 -271
- package/temp/rtk/src/summary.rs +0 -297
- package/temp/rtk/src/tee.rs +0 -405
- package/temp/rtk/src/telemetry.rs +0 -248
- package/temp/rtk/src/toml_filter.rs +0 -1655
- package/temp/rtk/src/tracking.rs +0 -1416
- package/temp/rtk/src/tree.rs +0 -209
- package/temp/rtk/src/tsc_cmd.rs +0 -259
- package/temp/rtk/src/utils.rs +0 -432
- package/temp/rtk/src/verify_cmd.rs +0 -47
- package/temp/rtk/src/vitest_cmd.rs +0 -385
- package/temp/rtk/src/wc_cmd.rs +0 -401
- package/temp/rtk/src/wget_cmd.rs +0 -260
- package/temp/rtk/tests/fixtures/dotnet/build_failed.txt +0 -11
- package/temp/rtk/tests/fixtures/dotnet/format_changes.json +0 -31
- package/temp/rtk/tests/fixtures/dotnet/format_empty.json +0 -1
- package/temp/rtk/tests/fixtures/dotnet/format_success.json +0 -12
- package/temp/rtk/tests/fixtures/dotnet/test_failed.txt +0 -18
- package/tsconfig.json +0 -15
package/temp/rtk/src/lint_cmd.rs
DELETED
|
@@ -1,694 +0,0 @@
|
|
|
1
|
-
use crate::mypy_cmd;
|
|
2
|
-
use crate::ruff_cmd;
|
|
3
|
-
use crate::tracking;
|
|
4
|
-
use crate::utils::{package_manager_exec, truncate};
|
|
5
|
-
use anyhow::{Context, Result};
|
|
6
|
-
use regex::Regex;
|
|
7
|
-
use serde::{Deserialize, Serialize};
|
|
8
|
-
use std::collections::HashMap;
|
|
9
|
-
use std::process::Command;
|
|
10
|
-
|
|
11
|
-
#[derive(Debug, Deserialize, Serialize)]
|
|
12
|
-
struct EslintMessage {
|
|
13
|
-
#[serde(rename = "ruleId")]
|
|
14
|
-
rule_id: Option<String>,
|
|
15
|
-
severity: u8,
|
|
16
|
-
message: String,
|
|
17
|
-
line: usize,
|
|
18
|
-
column: usize,
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
#[derive(Debug, Deserialize, Serialize)]
|
|
22
|
-
struct EslintResult {
|
|
23
|
-
#[serde(rename = "filePath")]
|
|
24
|
-
file_path: String,
|
|
25
|
-
messages: Vec<EslintMessage>,
|
|
26
|
-
#[serde(rename = "errorCount")]
|
|
27
|
-
error_count: usize,
|
|
28
|
-
#[serde(rename = "warningCount")]
|
|
29
|
-
warning_count: usize,
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
#[derive(Debug, Deserialize)]
|
|
33
|
-
struct PylintDiagnostic {
|
|
34
|
-
#[serde(rename = "type")]
|
|
35
|
-
msg_type: String, // "warning", "error", "convention", "refactor"
|
|
36
|
-
#[allow(dead_code)]
|
|
37
|
-
module: String,
|
|
38
|
-
#[allow(dead_code)]
|
|
39
|
-
obj: String,
|
|
40
|
-
line: usize,
|
|
41
|
-
#[allow(dead_code)]
|
|
42
|
-
column: usize,
|
|
43
|
-
path: String,
|
|
44
|
-
symbol: String, // rule code like "unused-variable"
|
|
45
|
-
message: String,
|
|
46
|
-
#[serde(rename = "message-id")]
|
|
47
|
-
message_id: String, // e.g., "W0612"
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/// Check if a linter is Python-based (uses pip/pipx, not npm/pnpm)
|
|
51
|
-
fn is_python_linter(linter: &str) -> bool {
|
|
52
|
-
matches!(linter, "ruff" | "pylint" | "mypy" | "flake8")
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/// Strip package manager prefixes (npx, bunx, pnpm, pnpm exec, yarn) from args.
|
|
56
|
-
/// Returns the number of args to skip.
|
|
57
|
-
fn strip_pm_prefix(args: &[String]) -> usize {
|
|
58
|
-
let pm_names = ["npx", "bunx", "pnpm", "yarn"];
|
|
59
|
-
let mut skip = 0;
|
|
60
|
-
for arg in args {
|
|
61
|
-
if pm_names.contains(&arg.as_str()) || arg == "exec" {
|
|
62
|
-
skip += 1;
|
|
63
|
-
} else {
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
skip
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/// Detect the linter name from args (after stripping PM prefixes).
|
|
71
|
-
/// Returns the linter name and whether it was explicitly specified.
|
|
72
|
-
fn detect_linter(args: &[String]) -> (&str, bool) {
|
|
73
|
-
let is_path_or_flag = args.is_empty()
|
|
74
|
-
|| args[0].starts_with('-')
|
|
75
|
-
|| args[0].contains('/')
|
|
76
|
-
|| args[0].contains('.');
|
|
77
|
-
|
|
78
|
-
if is_path_or_flag {
|
|
79
|
-
("eslint", false)
|
|
80
|
-
} else {
|
|
81
|
-
(&args[0], true)
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
pub fn run(args: &[String], verbose: u8) -> Result<()> {
|
|
86
|
-
let timer = tracking::TimedExecution::start();
|
|
87
|
-
|
|
88
|
-
let skip = strip_pm_prefix(args);
|
|
89
|
-
let effective_args = &args[skip..];
|
|
90
|
-
|
|
91
|
-
let (linter, explicit) = detect_linter(effective_args);
|
|
92
|
-
|
|
93
|
-
// Python linters use Command::new() directly (they're on PATH via pip/pipx)
|
|
94
|
-
// JS linters use package_manager_exec (npx/pnpm exec)
|
|
95
|
-
let mut cmd = if is_python_linter(linter) {
|
|
96
|
-
Command::new(linter)
|
|
97
|
-
} else {
|
|
98
|
-
package_manager_exec(linter)
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
// Add format flags based on linter
|
|
102
|
-
match linter {
|
|
103
|
-
"eslint" => {
|
|
104
|
-
cmd.arg("-f").arg("json");
|
|
105
|
-
}
|
|
106
|
-
"ruff" => {
|
|
107
|
-
// Force JSON output for ruff check
|
|
108
|
-
if !effective_args.contains(&"--output-format".to_string()) {
|
|
109
|
-
cmd.arg("check").arg("--output-format=json");
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
"pylint" => {
|
|
113
|
-
// Force JSON2 output for pylint
|
|
114
|
-
if !effective_args.contains(&"--output-format".to_string()) {
|
|
115
|
-
cmd.arg("--output-format=json2");
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
"mypy" => {
|
|
119
|
-
// mypy uses default text output (no special flags)
|
|
120
|
-
}
|
|
121
|
-
_ => {
|
|
122
|
-
// Other linters: no special formatting
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Add user arguments (skip first if it was the linter name, and skip "check" for ruff if we added it)
|
|
127
|
-
let start_idx = if !explicit {
|
|
128
|
-
0
|
|
129
|
-
} else if linter == "ruff" && !effective_args.is_empty() && effective_args[0] == "ruff" {
|
|
130
|
-
// Skip "ruff" and "check" if we already added "check"
|
|
131
|
-
if effective_args.len() > 1 && effective_args[1] == "check" {
|
|
132
|
-
2
|
|
133
|
-
} else {
|
|
134
|
-
1
|
|
135
|
-
}
|
|
136
|
-
} else {
|
|
137
|
-
1
|
|
138
|
-
};
|
|
139
|
-
|
|
140
|
-
for arg in &effective_args[start_idx..] {
|
|
141
|
-
// Skip --output-format if we already added it
|
|
142
|
-
if linter == "ruff" && arg.starts_with("--output-format") {
|
|
143
|
-
continue;
|
|
144
|
-
}
|
|
145
|
-
if linter == "pylint" && arg.starts_with("--output-format") {
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
cmd.arg(arg);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
// Default to current directory if no path specified (for ruff/pylint/mypy/eslint)
|
|
152
|
-
if matches!(linter, "ruff" | "pylint" | "mypy" | "eslint") {
|
|
153
|
-
let has_path = effective_args
|
|
154
|
-
.iter()
|
|
155
|
-
.skip(start_idx)
|
|
156
|
-
.any(|a| !a.starts_with('-') && !a.contains('='));
|
|
157
|
-
if !has_path {
|
|
158
|
-
cmd.arg(".");
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if verbose > 0 {
|
|
163
|
-
eprintln!("Running: {} with structured output", linter);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
let output = cmd.output().context(format!(
|
|
167
|
-
"Failed to run {}. Is it installed? Try: pip install {} (or npm/pnpm for JS linters)",
|
|
168
|
-
linter, linter
|
|
169
|
-
))?;
|
|
170
|
-
|
|
171
|
-
// Check if process was killed by signal (SIGABRT, SIGKILL, etc.)
|
|
172
|
-
if !output.status.success() && output.status.code().is_none() {
|
|
173
|
-
let stderr = String::from_utf8_lossy(&output.stderr);
|
|
174
|
-
eprintln!("⚠️ Linter process terminated abnormally (possibly out of memory)");
|
|
175
|
-
if !stderr.is_empty() {
|
|
176
|
-
eprintln!(
|
|
177
|
-
"stderr: {}",
|
|
178
|
-
stderr.lines().take(5).collect::<Vec<_>>().join("\n")
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
return Ok(());
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
let stdout = String::from_utf8_lossy(&output.stdout);
|
|
185
|
-
let stderr = String::from_utf8_lossy(&output.stderr);
|
|
186
|
-
let raw = format!("{}\n{}", stdout, stderr);
|
|
187
|
-
|
|
188
|
-
// Dispatch to appropriate filter based on linter
|
|
189
|
-
let filtered = match linter {
|
|
190
|
-
"eslint" => filter_eslint_json(&stdout),
|
|
191
|
-
"ruff" => {
|
|
192
|
-
// Reuse ruff_cmd's JSON parser
|
|
193
|
-
if !stdout.trim().is_empty() {
|
|
194
|
-
ruff_cmd::filter_ruff_check_json(&stdout)
|
|
195
|
-
} else {
|
|
196
|
-
"✓ Ruff: No issues found".to_string()
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
"pylint" => filter_pylint_json(&stdout),
|
|
200
|
-
"mypy" => mypy_cmd::filter_mypy_output(&raw),
|
|
201
|
-
_ => filter_generic_lint(&raw),
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
let exit_code = output
|
|
205
|
-
.status
|
|
206
|
-
.code()
|
|
207
|
-
.unwrap_or(if output.status.success() { 0 } else { 1 });
|
|
208
|
-
if let Some(hint) = crate::tee::tee_and_hint(&raw, "lint", exit_code) {
|
|
209
|
-
println!("{}\n{}", filtered, hint);
|
|
210
|
-
} else {
|
|
211
|
-
println!("{}", filtered);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
timer.track(
|
|
215
|
-
&format!("{} {}", linter, args.join(" ")),
|
|
216
|
-
&format!("rtk lint {} {}", linter, args.join(" ")),
|
|
217
|
-
&raw,
|
|
218
|
-
&filtered,
|
|
219
|
-
);
|
|
220
|
-
|
|
221
|
-
if !output.status.success() {
|
|
222
|
-
std::process::exit(output.status.code().unwrap_or(1));
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
Ok(())
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
/// Filter ESLint JSON output - group by rule and file
|
|
229
|
-
fn filter_eslint_json(output: &str) -> String {
|
|
230
|
-
let results: Result<Vec<EslintResult>, _> = serde_json::from_str(output);
|
|
231
|
-
|
|
232
|
-
let results = match results {
|
|
233
|
-
Ok(r) => r,
|
|
234
|
-
Err(e) => {
|
|
235
|
-
// Fallback if JSON parsing fails
|
|
236
|
-
return format!(
|
|
237
|
-
"ESLint output (JSON parse failed: {})\n{}",
|
|
238
|
-
e,
|
|
239
|
-
truncate(output, 500)
|
|
240
|
-
);
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
|
|
244
|
-
// Count total issues
|
|
245
|
-
let total_errors: usize = results.iter().map(|r| r.error_count).sum();
|
|
246
|
-
let total_warnings: usize = results.iter().map(|r| r.warning_count).sum();
|
|
247
|
-
let total_files = results.iter().filter(|r| !r.messages.is_empty()).count();
|
|
248
|
-
|
|
249
|
-
if total_errors == 0 && total_warnings == 0 {
|
|
250
|
-
return "✓ ESLint: No issues found".to_string();
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
// Group messages by rule
|
|
254
|
-
let mut by_rule: HashMap<String, usize> = HashMap::new();
|
|
255
|
-
for result in &results {
|
|
256
|
-
for msg in &result.messages {
|
|
257
|
-
if let Some(rule) = &msg.rule_id {
|
|
258
|
-
*by_rule.entry(rule.clone()).or_insert(0) += 1;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// Group by file
|
|
264
|
-
let mut by_file: Vec<(&EslintResult, usize)> = results
|
|
265
|
-
.iter()
|
|
266
|
-
.filter(|r| !r.messages.is_empty())
|
|
267
|
-
.map(|r| (r, r.messages.len()))
|
|
268
|
-
.collect();
|
|
269
|
-
by_file.sort_by(|a, b| b.1.cmp(&a.1));
|
|
270
|
-
|
|
271
|
-
// Build output
|
|
272
|
-
let mut result = String::new();
|
|
273
|
-
result.push_str(&format!(
|
|
274
|
-
"ESLint: {} errors, {} warnings in {} files\n",
|
|
275
|
-
total_errors, total_warnings, total_files
|
|
276
|
-
));
|
|
277
|
-
result.push_str("═══════════════════════════════════════\n");
|
|
278
|
-
|
|
279
|
-
// Show top rules
|
|
280
|
-
let mut rule_counts: Vec<_> = by_rule.iter().collect();
|
|
281
|
-
rule_counts.sort_by(|a, b| b.1.cmp(a.1));
|
|
282
|
-
|
|
283
|
-
if !rule_counts.is_empty() {
|
|
284
|
-
result.push_str("Top rules:\n");
|
|
285
|
-
for (rule, count) in rule_counts.iter().take(10) {
|
|
286
|
-
result.push_str(&format!(" {} ({}x)\n", rule, count));
|
|
287
|
-
}
|
|
288
|
-
result.push('\n');
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
// Show top files with most issues
|
|
292
|
-
result.push_str("Top files:\n");
|
|
293
|
-
for (file_result, count) in by_file.iter().take(10) {
|
|
294
|
-
let short_path = compact_path(&file_result.file_path);
|
|
295
|
-
result.push_str(&format!(" {} ({} issues)\n", short_path, count));
|
|
296
|
-
|
|
297
|
-
// Show top 3 rules in this file
|
|
298
|
-
let mut file_rules: HashMap<String, usize> = HashMap::new();
|
|
299
|
-
for msg in &file_result.messages {
|
|
300
|
-
if let Some(rule) = &msg.rule_id {
|
|
301
|
-
*file_rules.entry(rule.clone()).or_insert(0) += 1;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
let mut file_rule_counts: Vec<_> = file_rules.iter().collect();
|
|
306
|
-
file_rule_counts.sort_by(|a, b| b.1.cmp(a.1));
|
|
307
|
-
|
|
308
|
-
for (rule, count) in file_rule_counts.iter().take(3) {
|
|
309
|
-
result.push_str(&format!(" {} ({})\n", rule, count));
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
if by_file.len() > 10 {
|
|
314
|
-
result.push_str(&format!("\n... +{} more files\n", by_file.len() - 10));
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
result.trim().to_string()
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
/// Filter pylint JSON2 output - group by symbol and file
|
|
321
|
-
fn filter_pylint_json(output: &str) -> String {
|
|
322
|
-
let diagnostics: Result<Vec<PylintDiagnostic>, _> = serde_json::from_str(output);
|
|
323
|
-
|
|
324
|
-
let diagnostics = match diagnostics {
|
|
325
|
-
Ok(d) => d,
|
|
326
|
-
Err(e) => {
|
|
327
|
-
// Fallback if JSON parsing fails
|
|
328
|
-
return format!(
|
|
329
|
-
"Pylint output (JSON parse failed: {})\n{}",
|
|
330
|
-
e,
|
|
331
|
-
truncate(output, 500)
|
|
332
|
-
);
|
|
333
|
-
}
|
|
334
|
-
};
|
|
335
|
-
|
|
336
|
-
if diagnostics.is_empty() {
|
|
337
|
-
return "✓ Pylint: No issues found".to_string();
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
// Count by type
|
|
341
|
-
let mut errors = 0;
|
|
342
|
-
let mut warnings = 0;
|
|
343
|
-
let mut conventions = 0;
|
|
344
|
-
let mut refactors = 0;
|
|
345
|
-
|
|
346
|
-
for diag in &diagnostics {
|
|
347
|
-
match diag.msg_type.as_str() {
|
|
348
|
-
"error" => errors += 1,
|
|
349
|
-
"warning" => warnings += 1,
|
|
350
|
-
"convention" => conventions += 1,
|
|
351
|
-
"refactor" => refactors += 1,
|
|
352
|
-
_ => {}
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
// Count unique files
|
|
357
|
-
let unique_files: std::collections::HashSet<_> = diagnostics.iter().map(|d| &d.path).collect();
|
|
358
|
-
let total_files = unique_files.len();
|
|
359
|
-
|
|
360
|
-
// Group by symbol (rule code)
|
|
361
|
-
let mut by_symbol: HashMap<String, usize> = HashMap::new();
|
|
362
|
-
for diag in &diagnostics {
|
|
363
|
-
let key = format!("{} ({})", diag.symbol, diag.message_id);
|
|
364
|
-
*by_symbol.entry(key).or_insert(0) += 1;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
// Group by file
|
|
368
|
-
let mut by_file: HashMap<&str, usize> = HashMap::new();
|
|
369
|
-
for diag in &diagnostics {
|
|
370
|
-
*by_file.entry(&diag.path).or_insert(0) += 1;
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
let mut file_counts: Vec<_> = by_file.iter().collect();
|
|
374
|
-
file_counts.sort_by(|a, b| b.1.cmp(a.1));
|
|
375
|
-
|
|
376
|
-
// Build output
|
|
377
|
-
let mut result = String::new();
|
|
378
|
-
result.push_str(&format!(
|
|
379
|
-
"Pylint: {} issues in {} files\n",
|
|
380
|
-
diagnostics.len(),
|
|
381
|
-
total_files
|
|
382
|
-
));
|
|
383
|
-
|
|
384
|
-
if errors > 0 || warnings > 0 {
|
|
385
|
-
result.push_str(&format!(" {} errors, {} warnings", errors, warnings));
|
|
386
|
-
if conventions > 0 || refactors > 0 {
|
|
387
|
-
result.push_str(&format!(
|
|
388
|
-
", {} conventions, {} refactors",
|
|
389
|
-
conventions, refactors
|
|
390
|
-
));
|
|
391
|
-
}
|
|
392
|
-
result.push('\n');
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
result.push_str("═══════════════════════════════════════\n");
|
|
396
|
-
|
|
397
|
-
// Show top symbols (rules)
|
|
398
|
-
let mut symbol_counts: Vec<_> = by_symbol.iter().collect();
|
|
399
|
-
symbol_counts.sort_by(|a, b| b.1.cmp(a.1));
|
|
400
|
-
|
|
401
|
-
if !symbol_counts.is_empty() {
|
|
402
|
-
result.push_str("Top rules:\n");
|
|
403
|
-
for (symbol, count) in symbol_counts.iter().take(10) {
|
|
404
|
-
result.push_str(&format!(" {} ({}x)\n", symbol, count));
|
|
405
|
-
}
|
|
406
|
-
result.push('\n');
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
// Show top files
|
|
410
|
-
result.push_str("Top files:\n");
|
|
411
|
-
for (file, count) in file_counts.iter().take(10) {
|
|
412
|
-
let short_path = compact_path(file);
|
|
413
|
-
result.push_str(&format!(" {} ({} issues)\n", short_path, count));
|
|
414
|
-
|
|
415
|
-
// Show top 3 rules in this file
|
|
416
|
-
let mut file_symbols: HashMap<String, usize> = HashMap::new();
|
|
417
|
-
for diag in diagnostics.iter().filter(|d| &d.path == *file) {
|
|
418
|
-
let key = format!("{} ({})", diag.symbol, diag.message_id);
|
|
419
|
-
*file_symbols.entry(key).or_insert(0) += 1;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
let mut file_symbol_counts: Vec<_> = file_symbols.iter().collect();
|
|
423
|
-
file_symbol_counts.sort_by(|a, b| b.1.cmp(a.1));
|
|
424
|
-
|
|
425
|
-
for (symbol, count) in file_symbol_counts.iter().take(3) {
|
|
426
|
-
result.push_str(&format!(" {} ({})\n", symbol, count));
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
if file_counts.len() > 10 {
|
|
431
|
-
result.push_str(&format!("\n... +{} more files\n", file_counts.len() - 10));
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
result.trim().to_string()
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
/// Filter generic linter output (fallback for non-ESLint linters)
|
|
438
|
-
fn filter_generic_lint(output: &str) -> String {
|
|
439
|
-
let mut warnings = 0;
|
|
440
|
-
let mut errors = 0;
|
|
441
|
-
let mut issues: Vec<String> = Vec::new();
|
|
442
|
-
|
|
443
|
-
for line in output.lines() {
|
|
444
|
-
let line_lower = line.to_lowercase();
|
|
445
|
-
if line_lower.contains("warning") {
|
|
446
|
-
warnings += 1;
|
|
447
|
-
issues.push(line.to_string());
|
|
448
|
-
}
|
|
449
|
-
if line_lower.contains("error") && !line_lower.contains("0 error") {
|
|
450
|
-
errors += 1;
|
|
451
|
-
issues.push(line.to_string());
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
if errors == 0 && warnings == 0 {
|
|
456
|
-
return "✓ Lint: No issues found".to_string();
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
let mut result = String::new();
|
|
460
|
-
result.push_str(&format!("Lint: {} errors, {} warnings\n", errors, warnings));
|
|
461
|
-
result.push_str("═══════════════════════════════════════\n");
|
|
462
|
-
|
|
463
|
-
for issue in issues.iter().take(20) {
|
|
464
|
-
result.push_str(&format!("{}\n", truncate(issue, 100)));
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
if issues.len() > 20 {
|
|
468
|
-
result.push_str(&format!("\n... +{} more issues\n", issues.len() - 20));
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
result.trim().to_string()
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
/// Compact file path (remove common prefixes)
|
|
475
|
-
fn compact_path(path: &str) -> String {
|
|
476
|
-
// Remove common prefixes like /Users/..., /home/..., C:\
|
|
477
|
-
let path = path.replace('\\', "/");
|
|
478
|
-
|
|
479
|
-
if let Some(pos) = path.rfind("/src/") {
|
|
480
|
-
format!("src/{}", &path[pos + 5..])
|
|
481
|
-
} else if let Some(pos) = path.rfind("/lib/") {
|
|
482
|
-
format!("lib/{}", &path[pos + 5..])
|
|
483
|
-
} else if let Some(pos) = path.rfind('/') {
|
|
484
|
-
path[pos + 1..].to_string()
|
|
485
|
-
} else {
|
|
486
|
-
path
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
#[cfg(test)]
|
|
491
|
-
mod tests {
|
|
492
|
-
use super::*;
|
|
493
|
-
|
|
494
|
-
#[test]
|
|
495
|
-
fn test_filter_eslint_json() {
|
|
496
|
-
let json = r#"[
|
|
497
|
-
{
|
|
498
|
-
"filePath": "/Users/test/project/src/utils.ts",
|
|
499
|
-
"messages": [
|
|
500
|
-
{
|
|
501
|
-
"ruleId": "prefer-const",
|
|
502
|
-
"severity": 1,
|
|
503
|
-
"message": "Use const instead of let",
|
|
504
|
-
"line": 10,
|
|
505
|
-
"column": 5
|
|
506
|
-
},
|
|
507
|
-
{
|
|
508
|
-
"ruleId": "prefer-const",
|
|
509
|
-
"severity": 1,
|
|
510
|
-
"message": "Use const instead of let",
|
|
511
|
-
"line": 15,
|
|
512
|
-
"column": 5
|
|
513
|
-
}
|
|
514
|
-
],
|
|
515
|
-
"errorCount": 0,
|
|
516
|
-
"warningCount": 2
|
|
517
|
-
},
|
|
518
|
-
{
|
|
519
|
-
"filePath": "/Users/test/project/src/api.ts",
|
|
520
|
-
"messages": [
|
|
521
|
-
{
|
|
522
|
-
"ruleId": "@typescript-eslint/no-unused-vars",
|
|
523
|
-
"severity": 2,
|
|
524
|
-
"message": "Variable x is unused",
|
|
525
|
-
"line": 20,
|
|
526
|
-
"column": 10
|
|
527
|
-
}
|
|
528
|
-
],
|
|
529
|
-
"errorCount": 1,
|
|
530
|
-
"warningCount": 0
|
|
531
|
-
}
|
|
532
|
-
]"#;
|
|
533
|
-
|
|
534
|
-
let result = filter_eslint_json(json);
|
|
535
|
-
assert!(result.contains("ESLint:"));
|
|
536
|
-
assert!(result.contains("prefer-const"));
|
|
537
|
-
assert!(result.contains("no-unused-vars"));
|
|
538
|
-
assert!(result.contains("src/utils.ts"));
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
#[test]
|
|
542
|
-
fn test_compact_path() {
|
|
543
|
-
assert_eq!(
|
|
544
|
-
compact_path("/Users/foo/project/src/utils.ts"),
|
|
545
|
-
"src/utils.ts"
|
|
546
|
-
);
|
|
547
|
-
assert_eq!(
|
|
548
|
-
compact_path("C:\\Users\\project\\src\\api.ts"),
|
|
549
|
-
"src/api.ts"
|
|
550
|
-
);
|
|
551
|
-
assert_eq!(compact_path("simple.ts"), "simple.ts");
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
#[test]
|
|
555
|
-
fn test_filter_pylint_json_no_issues() {
|
|
556
|
-
let output = "[]";
|
|
557
|
-
let result = filter_pylint_json(output);
|
|
558
|
-
assert!(result.contains("✓ Pylint"));
|
|
559
|
-
assert!(result.contains("No issues found"));
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
#[test]
|
|
563
|
-
fn test_filter_pylint_json_with_issues() {
|
|
564
|
-
let json = r#"[
|
|
565
|
-
{
|
|
566
|
-
"type": "warning",
|
|
567
|
-
"module": "main",
|
|
568
|
-
"obj": "",
|
|
569
|
-
"line": 10,
|
|
570
|
-
"column": 0,
|
|
571
|
-
"path": "src/main.py",
|
|
572
|
-
"symbol": "unused-variable",
|
|
573
|
-
"message": "Unused variable 'x'",
|
|
574
|
-
"message-id": "W0612"
|
|
575
|
-
},
|
|
576
|
-
{
|
|
577
|
-
"type": "warning",
|
|
578
|
-
"module": "main",
|
|
579
|
-
"obj": "foo",
|
|
580
|
-
"line": 15,
|
|
581
|
-
"column": 4,
|
|
582
|
-
"path": "src/main.py",
|
|
583
|
-
"symbol": "unused-variable",
|
|
584
|
-
"message": "Unused variable 'y'",
|
|
585
|
-
"message-id": "W0612"
|
|
586
|
-
},
|
|
587
|
-
{
|
|
588
|
-
"type": "error",
|
|
589
|
-
"module": "utils",
|
|
590
|
-
"obj": "bar",
|
|
591
|
-
"line": 20,
|
|
592
|
-
"column": 0,
|
|
593
|
-
"path": "src/utils.py",
|
|
594
|
-
"symbol": "undefined-variable",
|
|
595
|
-
"message": "Undefined variable 'z'",
|
|
596
|
-
"message-id": "E0602"
|
|
597
|
-
}
|
|
598
|
-
]"#;
|
|
599
|
-
|
|
600
|
-
let result = filter_pylint_json(json);
|
|
601
|
-
assert!(result.contains("3 issues"));
|
|
602
|
-
assert!(result.contains("2 files"));
|
|
603
|
-
assert!(result.contains("1 errors, 2 warnings"));
|
|
604
|
-
assert!(result.contains("unused-variable (W0612)"));
|
|
605
|
-
assert!(result.contains("undefined-variable (E0602)"));
|
|
606
|
-
assert!(result.contains("main.py"));
|
|
607
|
-
assert!(result.contains("utils.py"));
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
#[test]
|
|
611
|
-
fn test_strip_pm_prefix_npx() {
|
|
612
|
-
let args: Vec<String> = vec!["npx".into(), "eslint".into(), "src/".into()];
|
|
613
|
-
assert_eq!(strip_pm_prefix(&args), 1);
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
#[test]
|
|
617
|
-
fn test_strip_pm_prefix_bunx() {
|
|
618
|
-
let args: Vec<String> = vec!["bunx".into(), "eslint".into(), ".".into()];
|
|
619
|
-
assert_eq!(strip_pm_prefix(&args), 1);
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
#[test]
|
|
623
|
-
fn test_strip_pm_prefix_pnpm_exec() {
|
|
624
|
-
let args: Vec<String> = vec!["pnpm".into(), "exec".into(), "eslint".into()];
|
|
625
|
-
assert_eq!(strip_pm_prefix(&args), 2);
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
#[test]
|
|
629
|
-
fn test_strip_pm_prefix_none() {
|
|
630
|
-
let args: Vec<String> = vec!["eslint".into(), "src/".into()];
|
|
631
|
-
assert_eq!(strip_pm_prefix(&args), 0);
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
#[test]
|
|
635
|
-
fn test_strip_pm_prefix_empty() {
|
|
636
|
-
let args: Vec<String> = vec![];
|
|
637
|
-
assert_eq!(strip_pm_prefix(&args), 0);
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
#[test]
|
|
641
|
-
fn test_detect_linter_eslint() {
|
|
642
|
-
let args: Vec<String> = vec!["eslint".into(), "src/".into()];
|
|
643
|
-
let (linter, explicit) = detect_linter(&args);
|
|
644
|
-
assert_eq!(linter, "eslint");
|
|
645
|
-
assert!(explicit);
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
#[test]
|
|
649
|
-
fn test_detect_linter_default_on_path() {
|
|
650
|
-
let args: Vec<String> = vec!["src/".into()];
|
|
651
|
-
let (linter, explicit) = detect_linter(&args);
|
|
652
|
-
assert_eq!(linter, "eslint");
|
|
653
|
-
assert!(!explicit);
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
#[test]
|
|
657
|
-
fn test_detect_linter_default_on_flag() {
|
|
658
|
-
let args: Vec<String> = vec!["--max-warnings=0".into()];
|
|
659
|
-
let (linter, explicit) = detect_linter(&args);
|
|
660
|
-
assert_eq!(linter, "eslint");
|
|
661
|
-
assert!(!explicit);
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
#[test]
|
|
665
|
-
fn test_detect_linter_after_npx_strip() {
|
|
666
|
-
// Simulates: rtk lint npx eslint src/ → after strip_pm_prefix, args = ["eslint", "src/"]
|
|
667
|
-
let full_args: Vec<String> = vec!["npx".into(), "eslint".into(), "src/".into()];
|
|
668
|
-
let skip = strip_pm_prefix(&full_args);
|
|
669
|
-
let effective = &full_args[skip..];
|
|
670
|
-
let (linter, _) = detect_linter(effective);
|
|
671
|
-
assert_eq!(linter, "eslint");
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
#[test]
|
|
675
|
-
fn test_detect_linter_after_pnpm_exec_strip() {
|
|
676
|
-
let full_args: Vec<String> =
|
|
677
|
-
vec!["pnpm".into(), "exec".into(), "biome".into(), "check".into()];
|
|
678
|
-
let skip = strip_pm_prefix(&full_args);
|
|
679
|
-
let effective = &full_args[skip..];
|
|
680
|
-
let (linter, _) = detect_linter(effective);
|
|
681
|
-
assert_eq!(linter, "biome");
|
|
682
|
-
}
|
|
683
|
-
|
|
684
|
-
#[test]
|
|
685
|
-
fn test_is_python_linter() {
|
|
686
|
-
assert!(is_python_linter("ruff"));
|
|
687
|
-
assert!(is_python_linter("pylint"));
|
|
688
|
-
assert!(is_python_linter("mypy"));
|
|
689
|
-
assert!(is_python_linter("flake8"));
|
|
690
|
-
assert!(!is_python_linter("eslint"));
|
|
691
|
-
assert!(!is_python_linter("biome"));
|
|
692
|
-
assert!(!is_python_linter("unknown"));
|
|
693
|
-
}
|
|
694
|
-
}
|