Claude-skill-registry fix-lint
Helps fix oxlint errors and warnings in the OneKey codebase. Use when running yarn lint and encountering warnings, cleaning up code before committing, or fixing spellcheck, unused variable, or other linting warnings.
git clone https://github.com/majiayu000/claude-skill-registry
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/fix-lint" ~/.claude/skills/majiayu000-claude-skill-registry-fix-lint-bd605e && rm -rf "$T"
skills/data/fix-lint/SKILL.mdFix 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
and encountering warningsyarn lint - Cleaning up code before committing
- Fixing spellcheck, unused variable, or other ESLint warnings
Workflow
Step 1: Run Lint and Analyze Warnings
yarn lint:only 2>&1 | tail -100
Step 2: Categorize Warnings
Warnings typically fall into these categories:
| Category | Rule | Fix Strategy |
|---|---|---|
| Spellcheck | | Add to skip list or fix typo |
| Unused vars | | Remove import or prefix with |
| Non-null assertion | | Add type guard or cast |
| Nested components | | Extract component |
| Import order | | Fix import ordering |
Step 3: Fix Each Category
Spellcheck Warnings (@cspell/spellchecker
)
@cspell/spellchecker-
Evaluate the word: Is it a legitimate technical term or a typo?
-
For legitimate technical terms, add to skip list:
# File: development/spellCheckerSkipWords.txt # Add the word on a new line at the end of the file newTechnicalTerm -
For known typos that can't be fixed (e.g., in translation keys), add with a comment above:
# Known typo - exsited -> existed (ETranslations.some_key) exsited -
Common legitimate terms to add:
- Build tools:
,chunkhash
,minimizerrspack - Blockchain:
,lovelace
,Kusama
,workchainfeebump - UI:
,Virtualized
,overscanoverscrolling - Crypto:
,nacl
,Bech32secp256k1
- Build tools:
Unused Variable Warnings (@typescript-eslint/no-unused-vars
)
@typescript-eslint/no-unused-vars-
Unused imports - Remove the import:
// Before import { Used, Unused } from 'package'; // After import { Used } from 'package'; -
Unused function parameters - Prefix with underscore:
// Before function foo(used: string, unused: number) { return used; } // After function foo(used: string, _unused: number) { return used; } -
Unused destructured variables - Prefix with underscore:
// Before const { used, unused } = obj; // After const { used, unused: _unused } = obj; -
Unused assigned variables - Prefix with underscore:
// Before const unused = getValue(); // After const _unused = getValue();
Non-null Assertion Warnings (@typescript-eslint/no-non-null-assertion
)
@typescript-eslint/no-non-null-assertionAdd type assertions or guards:
// Before const value = obj.prop!.name; // After const value = (obj.prop as { name: string } | undefined)?.name;
Nested Component Warnings (react/no-unstable-nested-components
)
react/no-unstable-nested-componentsExtract the component outside the parent:
// Before function Parent() { const NestedComponent = () => <div />; return <NestedComponent />; } // After const ExtractedComponent = () => <div />; function Parent() { return <ExtractedComponent />; }
Step 4: Verify Fixes
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:
# Known typo in translation key - invaild -> invalid invaild
Provider API Methods
Methods like
openInMobileApp that throw NotImplemented() often have unused parameters:
public async openInMobileApp( _request: IJsBridgeMessagePayload, _params: ISignMessagePayload, ): Promise<void> { throw new NotImplemented(); }
Destructuring from Hooks
When destructuring from hooks but not using all values:
const { used, unused: _unused } = usePromiseResult(...);
Tips
-
Run lint with increased memory for large codebases:
yarn lint:only -
Check if word is in skip list before adding:
grep -i "wordToCheck" development/spellCheckerSkipWords.txt -
For bulk fixes, use Task agents to parallelize work across multiple files
-
Verify no regressions after fixes:
yarn tsc:only
Files Modified During Lint Fixes
- Add technical terms and known typos (one word per line, usedevelopment/spellCheckerSkipWords.txt
for comments)#- Various
and.ts
files - Fix unused variables and imports.tsx