Skills.MD
# Fix Lint Skill
This skill helps fix oxlint warnings in the OneKey app-monorepo codebase.
**IMPORTANT**: This project uses **oxlint** (not ESLint). The active linting configuration is in `.oxlintrc.json`.
## Usage
Use this skill when:
- Running `yarn lint` and encountering warnings
- Cleaning up code before committing
- Fixing spellcheck, unused variable, or other ESLint warnings
## Workflow
### Step 1: Run Lint and Analyze Warnings
```bash
yarn lint:only 2>&1 | tail -100
```
### Step 2: Categorize Warnings
Warnings typically fall into these categories:
| Category | Rule | Fix Strategy |
|----------|------|--------------|
| Spellcheck | `@cspell/spellchecker` | Add to skip list or fix typo |
| Unused vars | `@typescript-eslint/no-unused-vars` | Remove import or prefix with `_` |
| Non-null assertion | `@typescript-eslint/no-non-null-assertion` | Add type guard or cast |
| Nested components | `react/no-unstable-nested-components` | Extract component |
| Import order | `import/order` | Fix import ordering |
### Step 3: Fix Each Category
#### Spellcheck Warnings (`@cspell/spellchecker`)
1. **Evaluate the word**: Is it a legitimate technical term or a typo?
2. **For legitimate technical terms**, add to skip list:
```text
# File: development/spellCheckerSkipWords.txt
# Add the word on a new line at the end of the file
newTechnicalTerm
```
3. **For known typos** that can't be fixed (e.g., in translation keys), add with a comment above:
```text
# Known typo - exsited -> existed (ETranslations.some_key)
exsited
```
4. **Common legitimate terms to add**:
- Build tools: `chunkhash`, `minimizer`, `rspack`
- Blockchain: `lovelace`, `Kusama`, `workchain`, `feebump`
- UI: `Virtualized`, `overscan`, `overscrolling`
- Crypto: `nacl`, `Bech32`, `secp256k1`
#### Unused Variable Warnings (`@typescript-eslint/no-unused-vars`)
1. **Unused imports** - Remove the import:
```typescript
// Before
import { Used, Unused } from 'package';
// After
import { Used } from 'package';
```
2. **Unused function parameters** - Prefix with underscore:
```typescript
// Before
function foo(used: string, unused: number) { return used; }
// After
function foo(used: string, _unused: number) { return used; }
```
3. **Unused destructured variables** - Prefix with underscore:
```typescript
// Before
const { used, unused } = obj;
// After
const { used, unused: _unused } = obj;
```
4. **Unused assigned variables** - Prefix with underscore:
```typescript
// Before
const unused = getValue();
// After
const _unused = getValue();
```
#### Non-null Assertion Warnings (`@typescript-eslint/no-non-null-assertion`)
Add type assertions or guards:
```typescript
// Before
const value = obj.prop!.name;
// After
const value = (obj.prop as { name: string } | undefined)?.name;
```
#### Nested Component Warnings (`react/no-unstable-nested-components`)
Extract the component outside the parent:
```typescript
// Before
function Parent() {
const NestedComponent = () => <div />;
return <NestedComponent />;
}
// After
const ExtractedComponent = () => <div />;
function Parent() {
return <ExtractedComponent />;
}
```
### Step 4: Verify Fixes
```bash
yarn lint:only 2>&1 | tail -50
```
## Common Patterns in This Codebase
### Translation Key Typos
Translation enum keys (e.g., `ETranslations.perp_invaild_tp_sl`) cannot be easily renamed as they're managed externally. Add to skip list with a comment:
```text
# Known typo in translation key - invaild -> invalid
invaild
```
### Provider API Methods
Methods like `openInMobileApp` that throw `NotImplemented()` often have unused parameters:
```typescript
public async openInMobileApp(
_request: IJsBridgeMessagePayload,
_params: ISignMessagePayload,
): Promise<void> {
throw new NotImplemented();
}
```
### Destructuring from Hooks
When destructuring from hooks but not using all values:
```typescript
const { used, unused: _unused } = usePromiseResult(...);
```
## Tips
1. **Run lint with increased memory** for large codebases:
```bash
yarn lint:only
```
2. **Check if word is in skip list** before adding:
```bash
grep -i "wordToCheck" development/spellCheckerSkipWords.txt
```
3. **For bulk fixes**, use Task agents to parallelize work across multiple files
4. **Verify no regressions** after fixes:
```bash
yarn tsc:only
```
## Files Modified During Lint Fixes
- `development/spellCheckerSkipWords.txt` - Add technical terms and known typos (one word per line, use `#` for comments)
- Various `.ts` and `.tsx` files - Fix unused variables and imports
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「fix-lint」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次