重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
1k-code-quality by onekeyhq/app-monorepo
npx skills add https://github.com/onekeyhq/app-monorepo --skill 1k-code-qualityOneKey 的代码检查、文档和通用代码质量标准。
# 预提交检查(快速,仅检查暂存文件)
yarn lint:staged
yarn tsc:staged
# 仅限 CI(全项目检查)
yarn lint # 全面检查:TypeScript、ESLint、文件夹结构、i18n
yarn lint:only # 快速检查:仅 oxlint
yarn tsc:only # 完整类型检查
注意: yarn lint 仅用于 CI。对于预提交检查,请始终使用 yarn lint:staged。
进行快速的预提交验证:
# 仅检查修改的文件(推荐)
yarn lint:staged
# 或包含类型检查
yarn lint:staged && yarn tsc:staged
// 未使用的变量 - 添加下划线前缀
const { used, unused } = obj; // ❌ 错误:'unused' 已定义但从未使用
const { used, unused: _unused } = obj; // ✅ 正确
// 未使用的参数 - 添加下划线前缀
function foo(used: string, unused: number) {} // ❌ 错误
function foo(used: string, _unused: number) {} // ✅ 正确
// 未处理的 Promise - 添加 void 或 await
someAsyncFunction(); // ❌ 错误:Promise 必须被 await 处理
void someAsyncFunction(); // ✅ 正确(触发后不管)
await someAsyncFunction(); // ✅ 正确(等待结果)
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
所有注释必须使用英文编写:
// ✅ 良好:英文注释
// Calculate the total balance including pending transactions
// ❌ 错误:中文注释
// 计算总余额,包括待处理的交易
// ✅ 良好:英文 JSDoc
/**
* Fetches user balance from the blockchain.
* @param address - The wallet address to query
* @returns The balance in native token units
*/
async function fetchBalance(address: string): Promise<bigint> {
// ...
}
// ✅ 良好:解释非显而易见的逻辑
// Use 1.5x gas limit to account for estimation variance on this chain
const gasLimit = estimatedGas * 1.5n;
// ✅ 良好:解释业务逻辑
// Premium users get 50% discount on transaction fees
const fee = isPremium ? baseFee * 0.5 : baseFee;
// ❌ 错误:显而易见的注释
// Set the value to 5
const value = 5;
每个函数应执行单一、原子的任务:
// ✅ 良好:单一职责
async function fetchUserBalance(userId: string): Promise<Balance> {
const user = await getUser(userId);
return await getBalanceForAddress(user.address);
}
// ❌ 错误:多重职责
async function fetchUserBalanceAndUpdateUI(userId: string) {
const user = await getUser(userId);
const balance = await getBalanceForAddress(user.address);
setBalanceState(balance);
showNotification('Balance updated');
logAnalytics('balance_fetched');
}
不要为一次性操作创建辅助函数:
// ❌ 错误:过度抽象
const createUserFetcher = (config: Config) => {
return (userId: string) => {
return fetchWithConfig(config, `/users/${userId}`);
};
};
const fetchUser = createUserFetcher(defaultConfig);
const user = await fetchUser(userId);
// ✅ 良好:简单直接
const user = await fetch(`/api/users/${userId}`).then(r => r.json());
查看 code-quality.md 获取完整指南:
查看 fix-lint.md 获取完整的代码检查修复工作流:
如果技术术语触发拼写检查错误:
# 检查单词是否存在
grep -i "yourword" development/spellCheckerSkipWords.txt
# 如果不存在则添加(先询问团队负责人)
echo "yourword" >> development/spellCheckerSkipWords.txt
yarn lint:staged 通过yarn tsc:staged 通过/1k-sentry-analysis - Sentry 错误分析和修复/1k-test-version - 测试版本创建工作流/1k-coding-patterns - 通用编码模式每周安装次数
60
代码仓库
GitHub 星标数
2.3K
首次出现
2026年2月1日
安全审计
安装于
opencode60
github-copilot60
codex60
gemini-cli60
amp59
kimi-cli59
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
123,700 周安装