Linting Fixes Plan
Summary
Rust Linting Status: β PASSED
cargo fmt --check: No formatting issuescargo clippy --workspace --all-targets --all-features: No clippy errors- Only minor dependency warnings (future incompatibility in
opendalandredis)
Frontend Linting Status: β FAILED
svelte-check: 17 errors, 3 warnings- Multiple type errors, module resolution issues, and accessibility warnings
Rust Issues (Low Priority)
Issue 1: Future Incompatibility Warnings
Files: Dependencies opendal v0.44.2, redis v0.23.3
Severity: Low (future-facing, not blocking)
Description: These dependencies contain code that will be rejected by future Rust versions.
Fix Strategy:
- Update
opendalto latest version (check for v0.45+) - Update
redisto latest version (check for v0.24+) - Run
cargo updateand test compatibility - Consider using
redistacklibrary per project guidelines
Frontend Issues (High Priority)
Issue 1: Missing Type Definitions in Generated Types β οΈ CRITICAL
File: desktop/src/lib/generated/types.ts
Lines: 49, 62
Severity: Critical - Breaks type system
Errors:
Line 49: Cannot find name 'AHashMap'
Line 49: Cannot find name 'Value'
Line 62: Cannot find name 'AHashMap'Root Cause: The generated TypeScript types reference Rust types (AHashMap, Value) that don't have TypeScript equivalents defined.
Fix Strategy:
-
Option A: Update the Rust type generation (tsify) to properly export these types
- Check
crates/terraphim_types/src/lib.rsor wherever types are generated - Ensure
AHashMapis mapped to TypeScriptRecord<K, V>orMap<K, V> - Ensure
Valuetype is properly exported
- Check
-
Option B: Add missing type definitions manually to
types.ts:
// Add at top of file:
export type Value = string | number | boolean | null | Value[] | { [key: string]: Value };
export type AHashMap<K extends string | number, V> = Record<K, V>;- Option C: Modify generated types to use standard TypeScript types:
// Line 49: Change from
export interface Role extends AHashMap<string, Value> {
// To:
export interface Role {Recommended Approach: Option B (quick fix) + Option A (long-term fix)
Issue 2: Module Import Errors in FetchTabs.svelte
File: desktop/src/lib/Fetchers/FetchTabs.svelte
Lines: 9, 64
Severity: High
Errors:
Line 9: Cannot find module '$lib/stores' or its corresponding type declarations
Line 64: Cannot find module '$workers/postmessage.ts' or its corresponding type declarationsRoot Cause:
- TypeScript path aliases (
$lib,$workers) not properly configured intsconfig.json - Files may be missing or misnamed
Fix Strategy:
- Check
desktop/tsconfig.jsonfor path mappings:
- Verify
src/workers/postmessage.tsexists, or update import path - Check if
svelte.config.jshas proper alias configuration
Issue 3: @tomic/lib Agent Type Incompatibility
File: desktop/src/lib/Fetchers/FetchTabs.svelte
Line: 52
Severity: Medium
Error: Different versions of @tomic/lib in dependencies causing type conflicts
Root Cause: @tomic/svelte has its own bundled version of @tomic/lib that differs from the direct dependency.
Fix Strategy:
- Check
package.jsonversions:@tomic/lib: ^0.40.0@tomic/svelte: ^0.35.2
- Try to align versions or use only one source
- Alternative: Use
$store.setAgent(agent as any)with type assertion (not ideal) - Better: Update both packages to latest compatible versions
Issue 4: Route Component Type Errors (Svelte Routing)
File: desktop/src/lib/Fetchers/FetchTabs.svelte
Lines: 110, 135, 161
Severity: Medium
Error: svelte-routing Route component not compatible with type checking
Root Cause: Project uses Svelte 3 without proper TypeScript definitions for svelte-routing
Fix Strategy:
- Add type augmentation file
desktop/src/types/svelte-routing.d.ts:
declare module 'svelte-routing' {
import type { SvelteComponentTyped } from 'svelte';
export class Route extends SvelteComponentTyped<{
path?: string;
component?: any;
}> {}
export class Router extends SvelteComponentTyped<{}> {}
export class Link extends SvelteComponentTyped<{ to: string }> {}
}- Alternatively: Consider migrating to
tinro(already in dependencies) which has better TypeScript support
Issue 5: ThemeSwitcher Role Import and Type Errors
File: desktop/src/lib/ThemeSwitcher.svelte
Lines: 5, 148, 160
Severity: High
Errors:
Line 5: '"./stores"' has no exported member named 'Role'
Line 148: This comparison appears to be unintentional because the types 'RoleName' and 'string' have no overlap
Line 160: Type 'string' is not assignable to type 'RoleName'Root Cause:
- Trying to import
Roletype from stores, but stores exports it from generated types - Mixing
stringandRoleNametypes
Fix Strategy:
- Fix import on line 5:
// Change from:
import { ..., type Role as RoleInterface } from "./stores";
// To:
import type { Role as RoleInterface } from "./generated/types";- Fix type handling:
// Line 148-160: Instead of comparing string to RoleName
const roleSettings = $roles.find((r) => r.name.lowercase === newRoleName.toLowerCase());
// Or convert string to RoleName:
const roleNameObj: RoleName = {
original: newRoleName,
lowercase: newRoleName.toLowerCase()
};
cfg.selected_role = roleNameObj;Issue 6: DOM Type Errors in ResultItem.svelte
File: desktop/src/lib/Search/ResultItem.svelte
Lines: 442, 445, 447, 458
Severity: Medium
Errors:
Line 442: Property 'createElement' does not exist on type 'Document'
Line 445: Property 'appendChild' does not exist on type 'string'
Line 447: Property 'removeChild' does not exist on type 'string'Root Cause: TypeScript not recognizing DOM types properly - likely document shadowed by a local variable or type
Fix Strategy:
- Check for variable shadowing:
// Look for: let document = ...
// Rename to: let documentData = ...- Add explicit DOM lib reference in
tsconfig.json:
- Use explicit window reference:
const a = window.document.createElement('a');
window.document.body.appendChild(a);Issue 7: NovelWrapper Import Error in ArticleModal
File: desktop/src/lib/Search/ArticleModal.svelte
Line: 3
Severity: Medium
Error: Cannot find module '$lib/Editor/NovelWrapper.svelte'
Fix Strategy:
- Check if file exists:
desktop/src/lib/Editor/NovelWrapper.svelte - If missing, create wrapper component for
@paralect/novel-svelte - If exists but path wrong, update import path
- If not needed, remove import
Issue 8: Accessibility Warnings (A11y)
Files:
desktop/src/lib/Search/ArticleModal.svelte:320desktop/src/lib/Search/AtomicSaveModal.svelte:281, 366Severity: Low (warnings, not errors)
Warnings:
- Line 320: Clickable div needs keyboard handler
- Lines 281, 366: Form labels not associated with controls
Fix Strategy:
For ArticleModal.svelte:320:
<!-- Add keyboard event handler -->
<div
class="content-viewer"
on:click={handleContentClick}
on:keydown={(e) => e.key === 'Enter' && handleContentClick(e)}
tabindex="0"
role="button"
aria-label="KG document content - click KG links to explore further"
>For AtomicSaveModal.svelte labels:
<!-- Option 1: Add for attribute -->
<label class="label" for="document-preview">Document to Save</label>
<div id="document-preview" class="box document-preview">
<!-- Option 2: Wrap input in label -->
<label class="label">
Parent Collection
<div class="control">
<!-- input here -->
</div>
</label>Issue 9: Package.json License Field Warning
Files: Root package.json, desktop/package.json
Severity: Low
Warning: No license field
Fix Strategy: Add license field matching LICENSE files (Apache-2.0 OR MIT):
Issue 10: Sass Deprecation Warnings
Severity: Low (future-facing)
Warning: Legacy JS API deprecated in Sass
Fix Strategy:
Update sass dependency when Dart Sass 2.0 stable is available. Current version (1.92.1) is modern, just using legacy API through build tools.
Implementation Priority
Phase 1: Critical Type Fixes (Required for build)
- β
Fix missing type definitions (
AHashMap,Value) - Issue 1 - Fix ThemeSwitcher type errors - Issue 5
- Fix module import errors - Issue 2
Phase 2: Component Fixes (Required for functionality)
- Fix NovelWrapper import - Issue 7
- Fix DOM type errors in ResultItem - Issue 6
- Fix Route component types - Issue 4
Phase 3: Dependency & Compatibility
- Fix @tomic Agent incompatibility - Issue 3
- Update Rust dependencies - Rust Issue 1
Phase 4: Quality & Standards
- Fix accessibility warnings - Issue 8
- Add license fields - Issue 9
Testing Strategy
After each phase:
- Run
yarn run checkin desktop directory - Run
cargo clippy --workspacein root - Test affected components in browser
- Run relevant e2e tests
Commands Reference
# Rust linting
# Frontend linting
&&
# Run tests after fixes
&&
Notes
- Most issues are TypeScript configuration and type generation related
- Core functionality likely works at runtime despite type errors
- Generated types file is the root cause of cascade failures
- Consider regenerating TypeScript bindings from Rust after fixing type definitions