| name | lint-fixer |
| description | Expert assistant for analyzing and fixing linting and formatting issues in the KR92 Bible Voice project using Biome and TypeScript. Use when fixing lint errors, resolving TypeScript issues, applying code formatting, or reviewing code quality. |
Lint Fixer
Capabilities
- Analyze Biome lint errors, warnings, and infos
- Auto-fix safe linting issues
- Review and apply TypeScript strict mode fixes
- Explain linting rules and best practices
- Batch fix common patterns
Linting Tools
Biome
The project uses Biome for linting and formatting:
npx @biomejs/biome lint .
npx @biomejs/biome lint . --write
npx @biomejs/biome format .
npx @biomejs/biome check --write .
TypeScript
npx tsc --noEmit
npm run typecheck
Common Biome Issues
1. Template Literals (useTemplate)
Issue: String concatenation should use template literals
Before:
alert('Error: ' + err.message);
const url = baseUrl + '/' + endpoint;
After:
alert(`Error: ${err.message}`);
const url = `${baseUrl}/${endpoint}`;
2. Const Declarations (useConst)
Issue: Variables that are never reassigned should use const
Before:
let value = 10;
let result = calculate();
After:
const value = 10;
const result = calculate();
3. Unused Variables (noUnusedVariables)
Issue: Variables declared but never used
Fix:
const _intentionallyUnused = value;
4. Console Statements (noConsole)
Issue: Console statements in production code
Fix:
if (process.env.NODE_ENV === 'development') {
console.log('Debug info');
}
logger.debug('Debug info');
5. Any Type (noExplicitAny)
Issue: Using any type instead of specific types
Before:
function process(data: any) {
return data.value;
}
After:
interface Data {
value: string;
}
function process(data: Data) {
return data.value;
}
function process(data: unknown) {
if (isData(data)) {
return data.value;
}
}
6. Non-Null Assertions (noNonNullAssertion)
Issue: Using ! non-null assertion
Before:
const element = document.getElementById('app')!;
After:
const element = document.getElementById('app');
if (!element) {
throw new Error('Element not found');
}
Usage Examples
Example 1: Auto-Fix Safe Issues
User: "Fix all safe linting issues"
Assistant:
npx @biomejs/biome check --write .
git diff
git add .
git commit -m "fix: apply Biome auto-fixes"
Example 2: Fix Template Literal Issues
User: "Fix the template literal warnings"
Assistant:
I'll fix the string concatenation issues. Looking at the error:
alert('Audion toisto epäonnistui: ' + err.message);
Let me fix this:
alert(`Audion toisto epäonnistui: ${err.message}`);
For batch fixing similar issues, I can use Find & Replace pattern:
- Find:
'([^']*?)'\s*\+\s*([^;]+)
- Replace:
`$1${$2}`
Example 3: Fix TypeScript Errors
User: "I have TypeScript errors in my component"
Assistant:
Let me check the TypeScript errors:
npx tsc --noEmit 2>&1 | head -20
Common fixes:
Missing type annotations:
const handleClick = (e) => {
console.log(e);
};
const handleClick = (e: React.MouseEvent<HTMLButtonElement>) => {
console.log(e);
};
Implicit any:
const data = await response.json();
interface ApiResponse {
success: boolean;
data: any;
}
const data: ApiResponse = await response.json();
Example 4: Batch Fix Const Issues
User: "Convert all let to const where possible"
Assistant:
npx @biomejs/biome check --write .
Example 5: Clean Up Console Statements
User: "Remove or fix console.log statements"
Assistant:
Strategy:
- Development logs - Wrap in environment check
- Debug logs - Remove or convert to proper logging
- Error logs - Keep but use console.error
if (import.meta.env.DEV) {
console.log('Debug:', data);
}
console.error('Failed to load:', error);
try {
await operation();
} catch (error) {
console.error('Operation failed:', error);
toast({
title: "Error",
description: error.message,
variant: "destructive"
});
}
Biome Configuration
The project likely has a biome.json config file:
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": false,
"ignore": ["node_modules", "dist", ".next", "build"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
Workflow for Fixing Lint Issues
Step 1: Assess the Damage
npx @biomejs/biome lint .
npx @biomejs/biome lint . 2>&1 | grep -c "error"
npx @biomejs/biome lint . 2>&1 | grep -c "warn"
Step 2: Auto-Fix Safe Issues
npx @biomejs/biome check --write .
git diff --stat
Step 3: Manual Fixes
npx @biomejs/biome lint . > lint-report.txt
Step 4: Verify
npx @biomejs/biome check .
npx tsc --noEmit
git add .
git commit -m "fix: resolve linting issues"
Priority Fix Order
- TypeScript errors - Breaks builds
- Biome errors - Critical issues
- Biome warnings - Important issues
- Biome infos - Nice to have
Common Patterns by File Type
React Components (.tsx)
interface Props {
data: DataType;
onUpdate: (value: string) => void;
}
export const Component = ({ data, onUpdate }: Props) => {
return <div>...</div>;
};
Edge Functions (.ts)
interface RequestBody {
field: string;
}
interface ResponseData {
success: boolean;
data: ResultType;
}
serve(async (req: Request) => {
try {
const body: RequestBody = await req.json();
return new Response(
JSON.stringify({ success: true, data }),
{ headers: corsHeaders }
);
} catch (error) {
return new Response(
JSON.stringify({
success: false,
error: error instanceof Error ? error.message : 'Unknown error'
}),
{ status: 500, headers: corsHeaders }
);
}
});
Test Files
{
"linter": {
"rules": {
"suspicious": {
"noExplicitAny": "off"
}
}
}
}
Ignoring Specific Issues
Inline Comments
const message = 'Error: ' + error;
const data: any = externalLibrary.getData();
File-Level Ignore
CI/CD Integration
Your GitHub Actions already runs these checks:
- name: Lint
run: |
if npx -y @biomejs/biome --version > /dev/null 2>&1; then
npx @biomejs/biome lint .
npx @biomejs/biome format . --check
fi
- name: TypeScript
run: npm run typecheck --if-present || npx tsc --noEmit
Quick Reference
| Issue Type | Command to Fix | Manual Review? |
|---|
| Template literals | --write | No |
| Const declarations | --write | No |
| Formatting | --write | No |
| Unused variables | --write | Yes - verify not needed |
| Any types | Manual | Yes - add proper types |
| Console statements | Manual | Yes - keep errors only |
| Non-null assertions | Manual | Yes - add null checks |
Related Documentation