fix: v5.1 代码审查修复 — ESLint/CSV/测试隔离/CLI 去重

- ESLint: 迁移到 flat config ignores,删除已废弃的 .eslintignore
- CSV: Rust/TS 格式对齐,统一 type,path,enabled 3 列
- JSON: 导入导出统一为 {path, enabled} 对象格式
- scanner: 移除未使用的 max_threads 死代码 + TempDirGuard 测试清理
- profiles: rename_profile 添加目标存在检查
- CLI: 抽取 load_operate_save helper,简化 cmd_remove/cmd_edit
- PathTable: 抽取 usePathValidation hook,消除 set-state-in-effect
- 测试隔离: disabled/profiles 通过 #[cfg(test)] 重定向到 temp dir
- toolchain: 新增 rust-toolchain.toml 固定 stable-x86_64-pc-windows-gnu
- docs: 更新 CLAUDE.md/README.md 测试计数 + 架构树

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-30 17:31:04 +08:00
parent bce2dc8641
commit 21da3b2930
14 changed files with 430 additions and 214 deletions
+10 -1
View File
@@ -3,6 +3,7 @@ use serde::{Deserialize, Serialize};
use std::fs;
use std::path::PathBuf;
#[cfg(not(test))]
fn profiles_dir() -> PathBuf {
dirs::home_dir()
.unwrap_or_else(|| PathBuf::from("."))
@@ -10,6 +11,11 @@ fn profiles_dir() -> PathBuf {
.join("profiles")
}
#[cfg(test)]
fn profiles_dir() -> PathBuf {
std::env::temp_dir().join("patheditor_test_profiles")
}
fn validate_profile_name(name: &str) -> Result<(), String> {
if name.is_empty() {
return Err("配置名称不能为空".into());
@@ -155,9 +161,13 @@ pub fn rename_profile(old_name: &str, new_name: &str) -> Result<(), String> {
validate_profile_name(old_name)?;
validate_profile_name(new_name)?;
let old_path = profile_path(old_name);
let new_path = profile_path(new_name);
if !old_path.exists() {
return Err(format!("配置文件不存在: {}", old_name));
}
if old_path != new_path && new_path.exists() {
return Err(format!("目标配置名已存在: {}", new_name));
}
let mut data: ProfileData = serde_json::from_str(
&fs::read_to_string(&old_path).map_err(|e| format!("无法读取配置文件: {}", e))?,
@@ -167,7 +177,6 @@ pub fn rename_profile(old_name: &str, new_name: &str) -> Result<(), String> {
data.name = new_name.to_string();
data.modified = chrono::Local::now().format("%Y-%m-%dT%H:%M:%S").to_string();
let new_path = profile_path(new_name);
let json =
serde_json::to_string_pretty(&data).map_err(|e| format!("JSON 序列化失败: {}", e))?;
atomic_write(&new_path, &json).map_err(|e| format!("无法写入配置文件: {}", e))?;