Fix lint errors and update typescript-coding skill with lessons learned. Use when fixing Biome lint errors, resolving linting issues, or when lint check fails...
Fix lint errors and contribute prevention tips back to the typescript-coding skill so future code avoids the same issues.
Run the lint check to see current errors:
npm run lint:check
Parse the output to identify:
noExplicitAny, useImportType, noUnusedVariables)Determine if this is:
--writeFor auto-fixable errors:
npm run lint
For manual fixes, apply the appropriate correction based on the rule:
| Rule | Fix Pattern |
|---|---|
noExplicitAny |
Replace any with proper type, unknown, or generic |
useImportType |
Change import { Foo } to import type { Foo } for type-only imports |
useExportType |
Change export { Foo } to export type { Foo } for type-only exports |
noUnusedVariables |
Remove the variable or use it |
noUnusedImports |
Remove the import |
useConst |
Change let to const for non-reassigned variables |
noNonNullAssertion |
Use proper null checks, optional chaining, or invariant |
noUselessTypeConstraint |
Remove redundant extends unknown or extends any |
For each fix, ask:
If the fix represents a valuable lesson not already in the typescript-coding skill:
Read the current skill:
.claude/skills/typescript-coding/SKILL.md
Check if a similar tenet already exists. If yes, skip.
If novel, append a new tenet following this format:
### Tenet: [Concise principle statement]
DON'T:
\`\`\`ts
// Brief comment explaining the anti-pattern
[code that triggers the lint error]
\`\`\`
DO:
\`\`\`ts
// Brief comment explaining the correct approach
[corrected code]
\`\`\`
> [Optional note about edge cases or additional context]
Add a tenet when:
Do NOT add a tenet when:
// DON'T: Import types as values (larger bundle, confusing semantics)
import { MyInterface } from './types';
// DO: Use type-only imports for types
import type { MyInterface } from './types';
// DON'T: Use any (defeats type checking)
function process(data: any) { ... }
// DO: Use unknown and narrow, or define proper types
function process(data: unknown) {
if (isValidData(data)) { ... }
}
// DON'T: Assert non-null without proof
const value = maybeNull!;
// DO: Use invariant or proper null handling
invariant(maybeNull, 'Expected value to be defined');
const value = maybeNull;
After fixing lint errors, run the full verification:
./verify.sh --ui=false
This ensures:
$ npm run lint:check
src/parser.ts:42:10 - lint/suspicious/noExplicitAny - Unexpected any. Specify a different type.
> Analysis: The function accepts `any` because the input type wasn't defined.
> Fix: Create a proper input type and use type guards.
> Lesson: This pattern (typing unknown external data) is already covered in typescript-coding skill under "Precise type guards to refine unknown data safely". No new tenet needed.
$ npm run lint:check
src/utils.ts:15:1 - lint/style/useImportType - All these imports are only used as types.
> Analysis: Importing types as values causes unnecessary runtime code.
> Fix: Change to `import type { ... }`.
> Lesson: Already covered by Biome auto-fix. No tenet needed (too trivial).
$ npm run lint:check
src/cache.ts:88:5 - lint/correctness/noUnusedVariables - Variable 'temp' is declared but never used.
> Analysis: Dead code from refactoring.
> Fix: Remove the variable.
> Lesson: No tenet needed (trivial cleanup).
If a lint fix reveals that an existing tenet is incomplete or unclear: