Skip to content

Commit 49a3cdd

Browse files
committed
chore(tooling): enable desktop eslint and pnpm make targets
1 parent 946fa9e commit 49a3cdd

File tree

4 files changed

+42
-55
lines changed

4 files changed

+42
-55
lines changed

Makefile

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ help: ## 显示帮助信息
1313
install: ## 安装所有依赖
1414
@echo "安装 Rust 依赖..."
1515
cargo fetch
16-
@echo "安装桌面应用依赖..."
17-
cd desktop && npm install
16+
@echo "安装 JS 依赖 (pnpm workspace)..."
17+
pnpm install
1818
@echo "安装移动应用依赖..."
1919
cd mobile && flutter pub get
2020
@echo "依赖安装完成!"
@@ -45,7 +45,7 @@ build: ## 构建所有组件
4545
@echo "构建核心库 (workspace)..."
4646
cargo build --workspace --release
4747
@echo "构建桌面应用..."
48-
cd desktop && npm run tauri build
48+
pnpm --filter persona-desktop run tauri:build
4949
@echo "构建移动应用..."
5050
cd mobile && flutter build apk
5151
@echo "构建完成!"
@@ -61,7 +61,7 @@ dev: ## 启动开发模式
6161
make docs-serve
6262

6363
dev-desktop: ## 启动桌面应用开发模式
64-
cd desktop && npm run tauri dev
64+
pnpm --filter persona-desktop run tauri:dev
6565

6666
dev-mobile: ## 启动移动应用开发模式
6767
cd mobile && flutter run
@@ -71,7 +71,7 @@ test: ## 运行所有测试
7171
@echo "运行 Rust 测试 (workspace, all features)..."
7272
cargo test --workspace --all-features
7373
@echo "运行桌面应用测试..."
74-
cd desktop && npm test
74+
pnpm --filter persona-desktop run test
7575
@echo "运行移动应用测试..."
7676
cd mobile && flutter test
7777
@echo "测试完成!"
@@ -82,7 +82,7 @@ test-rust: ## 运行 Rust 测试
8282
cargo test
8383

8484
test-desktop: ## 运行桌面应用测试
85-
cd desktop && npm test
85+
pnpm --filter persona-desktop run test
8686

8787
test-mobile: ## 运行移动应用测试
8888
cd mobile && flutter test
@@ -92,7 +92,7 @@ lint: ## 运行代码检查
9292
@echo "检查 Rust 代码 (workspace, all targets/features)..."
9393
cargo clippy --workspace --all-targets --all-features -- -D warnings
9494
@echo "检查桌面应用代码..."
95-
cd desktop && npm run lint
95+
pnpm --filter persona-desktop run lint
9696
@echo "检查移动应用代码..."
9797
cd mobile && flutter analyze
9898
@echo "代码检查完成!"
@@ -104,7 +104,7 @@ format: ## 格式化代码
104104
@echo "格式化 Rust 代码 (workspace)..."
105105
cargo fmt --all
106106
@echo "格式化桌面应用代码..."
107-
cd desktop && npm run format
107+
pnpm --filter persona-desktop run format
108108
@echo "格式化移动应用代码..."
109109
cd mobile && dart format .
110110
@echo "代码格式化完成!"
@@ -156,7 +156,7 @@ security-audit: ## 运行安全审计
156156
@echo "运行 Rust 安全审计..."
157157
cargo audit
158158
@echo "运行 Node.js 安全审计..."
159-
cd desktop && npm audit
159+
pnpm --filter persona-desktop audit
160160
@echo "安全审计完成!"
161161

162162
security-check: ## 运行完整安全检查(audit + deny)
@@ -167,7 +167,7 @@ security-check: ## 运行完整安全检查(audit + deny)
167167
cargo audit
168168
@echo ""
169169
@echo "=== 运行 npm audit ==="
170-
cd desktop && npm audit || true
170+
pnpm --filter persona-desktop audit || true
171171
@echo ""
172172
@echo "安全检查完成!"
173173

@@ -223,21 +223,20 @@ check-deps: ## 检查依赖更新
223223
@echo "检查 Rust 依赖更新..."
224224
cargo outdated
225225
@echo "检查 Node.js 依赖更新..."
226-
cd desktop && npm outdated
226+
pnpm --filter persona-desktop outdated
227227
@echo "检查 Flutter 依赖更新..."
228228
cd mobile && flutter pub outdated
229229

230230
# 生成文档
231231
generate-docs: ## 生成 API 文档
232232
@echo "生成 Rust API 文档..."
233233
cargo doc --no-deps --open
234-
@echo "生成 TypeScript 文档..."
235-
cd desktop && npm run docs
234+
@echo "跳过桌面 TypeScript 文档(未配置)"
236235

237236
# 国际化
238237
i18n-extract: ## 提取国际化字符串
239238
@echo "提取国际化字符串..."
240-
cd desktop && npm run i18n:extract
239+
@echo "跳过桌面 i18n 提取(未配置)"
241240
cd mobile && flutter gen-l10n
242241

243242
# 全面检查

desktop/.eslintrc.cjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
browser: true,
5+
es2021: true,
6+
node: true,
7+
},
8+
parser: '@typescript-eslint/parser',
9+
parserOptions: {
10+
ecmaVersion: 'latest',
11+
sourceType: 'module',
12+
ecmaFeatures: { jsx: true },
13+
},
14+
plugins: ['@typescript-eslint', 'react-hooks', 'react-refresh'],
15+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:react-hooks/recommended'],
16+
rules: {
17+
'@typescript-eslint/no-unused-vars': [
18+
'error',
19+
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_', ignoreRestSiblings: true },
20+
],
21+
'@typescript-eslint/no-explicit-any': 'off',
22+
'react-hooks/exhaustive-deps': 'off',
23+
'react-refresh/only-export-components': 'off',
24+
},
25+
ignorePatterns: ['dist/', 'node_modules/', 'src-tauri/target/'],
26+
};

desktop/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"tauri:build": "tauri build",
1414
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
1515
"lint:fix": "eslint . --ext ts,tsx --fix",
16+
"format": "eslint . --ext ts,tsx --fix",
1617
"test": "jest",
1718
"test:watch": "jest --watch",
1819
"test:coverage": "jest --coverage"
@@ -55,4 +56,4 @@
5556
"@testing-library/jest-dom": "^6.1.4",
5657
"ts-jest": "^29.1.1"
5758
}
58-
}
59+
}

desktop/src/components/WalletPanel.tsx

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import {
66
ArrowDownTrayIcon,
77
ArrowUpTrayIcon,
88
QrCodeIcon,
9-
CurrencyDollarIcon,
109
ArrowTrendingUpIcon,
11-
ArrowTrendingDownIcon,
1210
} from '@heroicons/react/24/outline';
1311
import { usePersonaService } from '@/hooks/usePersonaService';
1412
import { LoadingSpinner, ErrorDisplay, ErrorBoundary } from '@/components/ErrorHandling';
@@ -77,43 +75,6 @@ const WalletPanel: React.FC = () => {
7775
}
7876
};
7977

80-
const generateNewWallet = async (params: {
81-
name: string;
82-
network: string;
83-
type: string;
84-
mnemonic?: string;
85-
}) => {
86-
try {
87-
setIsLoading(true);
88-
await invoke('wallet_generate', params);
89-
await loadWallets();
90-
setShowCreateModal(false);
91-
} catch (err: any) {
92-
setError(err.message || 'Failed to generate wallet');
93-
} finally {
94-
setIsLoading(false);
95-
}
96-
};
97-
98-
const importWallet = async (params: {
99-
name: string;
100-
network: string;
101-
type: string;
102-
mnemonic?: string;
103-
privateKey?: string;
104-
}) => {
105-
try {
106-
setIsLoading(true);
107-
await invoke('wallet_import', params);
108-
await loadWallets();
109-
setShowImportModal(false);
110-
} catch (err: any) {
111-
setError(err.message || 'Failed to import wallet');
112-
} finally {
113-
setIsLoading(false);
114-
}
115-
};
116-
11778
const exportWallet = async (walletId: string) => {
11879
try {
11980
const result = await invoke('wallet_export', { walletId });
@@ -489,4 +450,4 @@ const WalletPanel: React.FC = () => {
489450
);
490451
};
491452

492-
export default WalletPanel;
453+
export default WalletPanel;

0 commit comments

Comments
 (0)